Exoplayer

This commit is contained in:
stom79 2019-01-05 17:43:37 +01:00
parent cdcc41ffac
commit 13a818b12d
2 changed files with 16 additions and 3 deletions

View File

@ -84,7 +84,6 @@ dependencies {
implementation 'com.github.GrenderG:Toasty:1.3.1'
implementation 'com.elconfidencial.bubbleshowcase:bubbleshowcase:1.3.1'
implementation 'com.android.support:multidex:1.0.3'
implementation 'com.google.android.exoplayer:exoplayer:2.9.3'
implementation "com.github.TorrentStream:TorrentStream-Android:$torrentstreamVersion"
playstoreImplementation "io.github.kobakei:ratethisapp:$ratethisappLibraryVersion"
}

View File

@ -26,6 +26,7 @@ import android.content.res.Configuration;
import android.database.sqlite.SQLiteDatabase;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.media.AudioManager;
import android.media.MediaPlayer;
import android.net.Uri;
import android.os.AsyncTask;
@ -414,7 +415,7 @@ public class PeertubeActivity extends BaseActivity implements OnRetrievePeertube
@Override
public void onStreamReady(Torrent torrent) {
Log.v(Helper.TAG,"onStreamReady");
videoView.setVideoURI(Uri.fromFile(torrent.getVideoFile()));
videoView.setVideoPath(torrent.getVideoFile().getAbsolutePath());
videoView.getCurrentPosition();
fullScreenMediaController = new FullScreenMediaController(PeertubeActivity.this, peertube);
fullScreenMediaController.setPadding(0, 0, 0, (int) Helper.convertDpToPixel(25, PeertubeActivity.this));
@ -425,6 +426,8 @@ public class PeertubeActivity extends BaseActivity implements OnRetrievePeertube
public void onPrepared(MediaPlayer mp) {
loader.setVisibility(View.GONE);
mediaPlayer = mp;
mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
mp.start();
}
});
@ -433,6 +436,10 @@ public class PeertubeActivity extends BaseActivity implements OnRetrievePeertube
@Override
public void onStreamProgress(Torrent torrent, StreamStatus status) {
Log.v(Helper.TAG,"seeds: " + status.seeds);
Log.v(Helper.TAG,"progress: " + status.progress);
Log.v(Helper.TAG,"bufferProgress: " + status.bufferProgress);
Log.v(Helper.TAG,"downloadSpeed: " + status.downloadSpeed);
}
@Override
@ -563,6 +570,13 @@ public class PeertubeActivity extends BaseActivity implements OnRetrievePeertube
}
}
@Override
public void onStop() {
super.onStop();
if( torrentStream != null && torrentStream.isStreaming())
torrentStream.stopStream();
}
@Override
protected void onPause() {
super.onPause();
@ -634,7 +648,7 @@ public class PeertubeActivity extends BaseActivity implements OnRetrievePeertube
videoView.setVisibility(View.GONE);
videoView.setVisibility(View.VISIBLE);
loader.setVisibility(View.GONE);
videoView.setVideoURI( Uri.fromFile(torrent.getVideoFile()));
videoView.setVideoPath(torrent.getVideoFile().getAbsolutePath());
fullScreenMediaController.setResolutionVal(res);
videoView.seekTo(position);
videoView.start();