[Android] Use PlayerController.hasRenderer()

Geoffrey Métais git at videolan.org
Wed Jan 31 15:36:53 CET 2018


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Wed Jan 31 15:31:46 2018 +0100| [6f2b2c0de80059c50c29f314912689103185b545] | committer: Geoffrey Métais

Use PlayerController.hasRenderer()

> https://code.videolan.org/videolan/vlc-android/commit/6f2b2c0de80059c50c29f314912689103185b545
---

 vlc-android/src/org/videolan/vlc/PlaybackService.java     | 8 +++-----
 vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt | 6 +++---
 2 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/PlaybackService.java b/vlc-android/src/org/videolan/vlc/PlaybackService.java
index bc8d990a2..1a0d3efad 100644
--- a/vlc-android/src/org/videolan/vlc/PlaybackService.java
+++ b/vlc-android/src/org/videolan/vlc/PlaybackService.java
@@ -157,7 +157,6 @@ public class PlaybackService extends MediaBrowserServiceCompat{
 
     private int mWidget = 0;
     private boolean mHasAudioFocus = false;
-    private boolean mOnRenderer = false;
     // RemoteControlClient-related
     /**
      * RemoteControlClient is for lock screen playback control.
@@ -1760,14 +1759,13 @@ public class PlaybackService extends MediaBrowserServiceCompat{
 
     @MainThread
     public boolean hasRenderer() {
-        return mOnRenderer;
+        return playlistManager.getPlayer().getHasRenderer();
     }
 
     @MainThread
     public void setRenderer(RendererItem item) {
-        final boolean wasOnRenderer = mOnRenderer;
-        mOnRenderer = item != null;
-        if (wasOnRenderer && !mOnRenderer && canSwitchToVideo()) VideoPlayerActivity.startOpened(VLCApplication.getAppContext(),
+        final boolean wasOnRenderer = hasRenderer();
+        if (wasOnRenderer && !hasRenderer() && canSwitchToVideo()) VideoPlayerActivity.startOpened(VLCApplication.getAppContext(),
                 playlistManager.getCurrentMedia().getUri(), playlistManager.getCurrentIndex());
         playlistManager.getPlayer().setRenderer(item);
     }
diff --git a/vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt b/vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt
index d42b185ec..d68c110ae 100644
--- a/vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt
+++ b/vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt
@@ -233,8 +233,8 @@ class PlaylistManager(val service: PlaybackService) : MediaWrapperList.EventList
 
         if (mw.hasFlag(MediaWrapper.MEDIA_FORCE_AUDIO) && player.getAudioTracksCount() == 0) {
             next()
-        } else if (mw.type != MediaWrapper.TYPE_VIDEO || isVideoPlaying || mw.hasFlag(MediaWrapper.MEDIA_FORCE_AUDIO)
-                || RendererDelegate.selectedRenderer !== null) {
+        } else if (mw.type != MediaWrapper.TYPE_VIDEO || isVideoPlaying || player.hasRenderer
+                || mw.hasFlag(MediaWrapper.MEDIA_FORCE_AUDIO)) {
             launch(UI, CoroutineStart.UNDISPATCHED) {
                 val media = Media(VLCInstance.get(), FileUtils.getUri(mw.uri))
                 VLCOptions.setMediaOptions(media, ctx, flags or mw.flags)
@@ -289,7 +289,7 @@ class PlaylistManager(val service: PlaybackService) : MediaWrapperList.EventList
         val media = getCurrentMedia()
         if (media === null || media.hasFlag(MediaWrapper.MEDIA_FORCE_AUDIO) || !player.canSwitchToVideo())
             return false
-        val hasRenderer = RendererDelegate.selectedRenderer !== null
+        val hasRenderer = player.hasRenderer
         videoBackground = false
         if (player.isVideoPlaying() && !hasRenderer) {//Player is already running, just send it an intent
             player.setVideoTrackEnabled(true)



More information about the Android mailing list