From cbe2bb45e30455635b316c01846aa4df14ee0a89 Mon Sep 17 00:00:00 2001 From: lishoujun Date: Tue, 1 Jan 2019 12:40:46 +0800 Subject: [PATCH 1/2] update dependence. minor change --- app/build.gradle | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 8b69e35..a317844 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -9,6 +9,11 @@ android { versionCode 1019 versionName "1.0.19" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + ext { + libVersions = [ + exoplayer: '2.9.3' + ] + } dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) @@ -41,13 +46,13 @@ android { // implementation "com.github.TorrentStream:TorrentStreamServer-Android:1.0.1" // implementation 'org.webrtc:google-webrtc:1.0.+' - // video player - implementation 'com.google.android.exoplayer:exoplayer-core:2.9.2' - implementation 'com.google.android.exoplayer:exoplayer-dash:2.9.2' - implementation 'com.google.android.exoplayer:exoplayer-ui:2.9.2' - implementation 'com.google.android.exoplayer:exoplayer-hls:2.9.2' - implementation 'com.google.android.exoplayer:exoplayer-smoothstreaming:2.9.2' - implementation 'com.google.android.exoplayer:extension-mediasession:2.9.2' + // video player repo:jcenter() + implementation "com.google.android.exoplayer:exoplayer-core:$libVersions.exoplayer" + implementation "com.google.android.exoplayer:exoplayer-dash:$libVersions.exoplayer" + implementation "com.google.android.exoplayer:exoplayer-ui:$libVersions.exoplayer" + implementation "com.google.android.exoplayer:exoplayer-hls:$libVersions.exoplayer" + implementation "com.google.android.exoplayer:exoplayer-smoothstreaming:$libVersions.exoplayer" + implementation "com.google.android.exoplayer:extension-mediasession:$libVersions.exoplayer" // testing testImplementation 'junit:junit:4.12' From 92396200e2e531fce0811eb92cca25766b8675de Mon Sep 17 00:00:00 2001 From: lishoujun Date: Thu, 3 Jan 2019 01:12:17 +0800 Subject: [PATCH 2/2] I think torrentStream should be stoped when activity onDestroy. add some log to debug. handle nullpointer --- .../peertube/activity/VideoPlayActivity.java | 23 ++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java b/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java index b8f0699..118f175 100644 --- a/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java +++ b/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java @@ -66,6 +66,7 @@ import net.schueller.peertube.fragment.VideoOptionsFragment; import net.schueller.peertube.helper.APIUrlHelper; import net.schueller.peertube.helper.MetaDataHelper; import net.schueller.peertube.intents.Intents; +import net.schueller.peertube.model.Account; import net.schueller.peertube.model.Avatar; import net.schueller.peertube.model.Video; import net.schueller.peertube.network.GetVideoDataService; @@ -89,7 +90,7 @@ public class VideoPlayActivity extends AppCompatActivity implements VideoRendere private Context context = this; private TextView fullscreenButton; private Boolean isFullscreen = false; - + private TorrentStream torrentStream; boolean mBound = false; VideoPlayerService mService; @@ -296,7 +297,16 @@ public class VideoPlayActivity extends AppCompatActivity implements VideoRendere String baseUrl = APIUrlHelper.getUrl(context); - Avatar avatar = video.getAccount().getAvatar(); + if(video == null){ + Toast.makeText(VideoPlayActivity.this, "Something went wrong...Please try later!", Toast.LENGTH_SHORT).show(); + return; + } + Account account = video.getAccount(); + if(account == null){ + Toast.makeText(VideoPlayActivity.this, "Something went wrong...Please try later!", Toast.LENGTH_SHORT).show(); + return; + } + Avatar avatar = account.getAvatar(); if (avatar != null) { String avatarPath = avatar.getPath(); Picasso.with(context) @@ -349,6 +359,7 @@ public class VideoPlayActivity extends AppCompatActivity implements VideoRendere videoOptionsFragment.show(getSupportFragmentManager(), "video_options_fragment"); }); + Log.v(TAG, "url : " + video.getFiles().get(0).getFileUrl()); mService.setCurrentStreamUrl(video.getFiles().get(0).getFileUrl()); @@ -357,11 +368,13 @@ public class VideoPlayActivity extends AppCompatActivity implements VideoRendere if (sharedPref.getBoolean("pref_torrent_player", false)) { String stream = video.getFiles().get(0).getTorrentUrl(); - TorrentStream torrentStream = setupTorrentStream(); + Log.v(TAG, "getTorrentUrl : " + video.getFiles().get(0).getTorrentUrl()); + torrentStream = setupTorrentStream(); torrentStream.startStream(stream); } else { startPlayer(); } + Log.v(TAG,"end of load Video"); } @@ -414,6 +427,10 @@ public class VideoPlayActivity extends AppCompatActivity implements VideoRendere protected void onDestroy() { super.onDestroy(); simpleExoPlayerView.setPlayer(null); + if (torrentStream != null){ + torrentStream.stopStream(); + } + Log.v(TAG, "onDestroy..."); } @Override