From 875cb0fd5498f158e1088a06f54c0c4dfe80101e Mon Sep 17 00:00:00 2001 From: lishoujun Date: Fri, 4 Jan 2019 23:52:09 +0800 Subject: [PATCH] add log to debug #86 --- .../schueller/peertube/activity/VideoPlayActivity.java | 5 +++-- .../schueller/peertube/service/VideoPlayerService.java | 9 ++++++++- 2 files changed, 11 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 b747553..9b2f471 100644 --- a/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java +++ b/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java @@ -183,8 +183,9 @@ public class VideoPlayActivity extends AppCompatActivity implements VideoRendere torrentStream.addListener(new TorrentListener() { @Override public void onStreamReady(Torrent torrent) { - Log.d(TAG, "Ready"); - mService.setCurrentStreamUrl(Uri.fromFile(torrent.getVideoFile()).toString()); + String videopath = Uri.fromFile(torrent.getVideoFile()).toString(); + Log.d(TAG, "Ready! torrentStream videopath:" + videopath); + mService.setCurrentStreamUrl(videopath); startPlayer(); } diff --git a/app/src/main/java/net/schueller/peertube/service/VideoPlayerService.java b/app/src/main/java/net/schueller/peertube/service/VideoPlayerService.java index bc62ddb..b477948 100644 --- a/app/src/main/java/net/schueller/peertube/service/VideoPlayerService.java +++ b/app/src/main/java/net/schueller/peertube/service/VideoPlayerService.java @@ -35,6 +35,7 @@ import androidx.annotation.Nullable; import android.support.v4.media.MediaDescriptionCompat; import android.support.v4.media.session.MediaSessionCompat; import android.util.Log; +import android.widget.Toast; import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.ExoPlayerFactory; @@ -82,6 +83,8 @@ public class VideoPlayerService extends Service { @Override public void onCreate() { + Log.v(TAG, "onCreate..."); + super.onCreate(); player = ExoPlayerFactory.newSimpleInstance(getApplicationContext(), new DefaultTrackSelector()); @@ -136,7 +139,11 @@ public class VideoPlayerService extends Service { @Override public int onStartCommand(Intent intent, int flags, int startId) { + Context context = this; Log.v(TAG, "onStartCommand..."); + if(currentStreamUrl == null){ + Toast.makeText(context, "currentStreamUrl must not null", Toast.LENGTH_SHORT).show(); + } playVideo(); return START_STICKY; } @@ -150,7 +157,7 @@ public class VideoPlayerService extends Service { public void setCurrentStreamUrl(String streamUrl) { - Log.v(TAG, "setCurrentStreamUrl..."); + Log.v(TAG, "setCurrentStreamUrl..." + streamUrl); currentStreamUrl = streamUrl; }