<div dir="ltr">Yes, better. Thx</div><br><div class="gmail_quote"><div dir="ltr">On Wed, Nov 25, 2015 at 9:35 AM Edward Wang <<a href="mailto:edward.c.wang@compdigitec.com">edward.c.wang@compdigitec.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Video playlists? (for commit title)<br>
<br>
On Tue, Nov 24, 2015 at 8:25 AM, Geoffrey Métais<br>
<<a href="mailto:geoffrey.metais@gmail.com" target="_blank">geoffrey.metais@gmail.com</a>> wrote:<br>
> ---<br>
>  .../src/org/videolan/vlc/PlaybackService.java      | 13 +++++----<br>
>  .../org/videolan/vlc/gui/audio/AudioPlayer.java    | 11 --------<br>
>  .../vlc/gui/video/VideoPlayerActivity.java         | 31 ++++++++++++++--------<br>
>  3 files changed, 28 insertions(+), 27 deletions(-)<br>
><br>
> diff --git a/vlc-android/src/org/videolan/vlc/PlaybackService.java b/vlc-android/src/org/videolan/vlc/PlaybackService.java<br>
> index e9d4cf0..cfb5850 100644<br>
> --- a/vlc-android/src/org/videolan/vlc/PlaybackService.java<br>
> +++ b/vlc-android/src/org/videolan/vlc/PlaybackService.java<br>
> @@ -576,9 +576,12 @@ public class PlaybackService extends Service implements IVLCVout.Callback {<br>
>                      }<br>
><br>
>                      changeAudioFocus(true);<br>
> -                    showNotification();<br>
>                      if (!mWakeLock.isHeld())<br>
>                          mWakeLock.acquire();<br>
> +                    if (switchToVideo())<br>
> +                        hideNotification();<br>
> +                    else<br>
> +                        showNotification();<br>
>                      break;<br>
>                  case MediaPlayer.Event.Paused:<br>
>                      Log.i(TAG, "MediaPlayer.Event.Paused");<br>
> @@ -722,8 +725,8 @@ public class PlaybackService extends Service implements IVLCVout.Callback {<br>
>      public boolean switchToVideo() {<br>
>          if (!canSwitchToVideo())<br>
>              return false;<br>
> -        if (!mMediaPlayer.getVLCVout().areViewsAttached())<br>
> -            VideoPlayerActivity.startOpened(VLCApplication.getAppContext(), mCurrentIndex);<br>
> +        VideoPlayerActivity.startOpened(VLCApplication.getAppContext(),<br>
> +                getCurrentMediaWrapper().getUri(), mCurrentIndex);<br>
>          return true;<br>
>      }<br>
><br>
> @@ -1142,7 +1145,7 @@ public class PlaybackService extends Service implements IVLCVout.Callback {<br>
>          }<br>
><br>
>          playIndex(mCurrentIndex, 0);<br>
> -        onMediaChanged();<br>
> +        saveCurrentMedia();<br>
>      }<br>
><br>
>      @MainThread<br>
> @@ -1161,7 +1164,7 @@ public class PlaybackService extends Service implements IVLCVout.Callback {<br>
>              setPosition(0f);<br>
><br>
>          playIndex(mCurrentIndex, 0);<br>
> -        onMediaChanged();<br>
> +        saveCurrentMedia();<br>
>      }<br>
><br>
>      @MainThread<br>
> diff --git a/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.java b/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.java<br>
> index 3ebdad1..6d7829a 100644<br>
> --- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.java<br>
> +++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.java<br>
> @@ -95,7 +95,6 @@ public class AudioPlayer extends PlaybackServiceFragment implements PlaybackServ<br>
><br>
>      private boolean mShowRemainingTime = false;<br>
>      private boolean mPreviewingSeek = false;<br>
> -    private boolean mSwitchedToVideo = false;<br>
><br>
>      private PlaylistAdapter mPlaylistAdapter;<br>
><br>
> @@ -176,7 +175,6 @@ public class AudioPlayer extends PlaybackServiceFragment implements PlaybackServ<br>
>              public void onClick(View v) {<br>
>                  if (mService != null) {<br>
>                      mService.switchToVideo();<br>
> -                    mSwitchedToVideo = true;<br>
>                  }<br>
>              }<br>
>          });<br>
> @@ -301,7 +299,6 @@ public class AudioPlayer extends PlaybackServiceFragment implements PlaybackServ<br>
>              if (mSettings.getBoolean(PreferencesActivity.VIDEO_RESTORE, false)){<br>
>                  Util.commitPreferences(mSettings.edit().putBoolean(PreferencesActivity.VIDEO_RESTORE, false));<br>
>                  mService.switchToVideo();<br>
> -                mSwitchedToVideo = true;<br>
>                  return;<br>
>              } else<br>
>                  show();<br>
> @@ -383,14 +380,6 @@ public class AudioPlayer extends PlaybackServiceFragment implements PlaybackServ<br>
>      public void onMediaPlayerEvent(MediaPlayer.Event event) {<br>
>          switch (event.type) {<br>
>              case MediaPlayer.Event.Opening:<br>
> -                mSwitchedToVideo = false;<br>
> -                break;<br>
> -            case MediaPlayer.Event.ESAdded:<br>
> -                final boolean forceAudio = (mService.getCurrentMediaWrapper().getFlags() & MediaWrapper.MEDIA_FORCE_AUDIO) != 0;<br>
> -                if (!forceAudio && !mSwitchedToVideo && event.getEsChangedType() == Media.Track.Type.Video) {<br>
> -                    mService.switchToVideo();<br>
> -                    mSwitchedToVideo = true;<br>
> -                }<br>
>                  break;<br>
>              case MediaPlayer.Event.Stopped:<br>
>                  hide();<br>
> diff --git a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java<br>
> index c81357b..cd7e4e0 100644<br>
> --- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java<br>
> +++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java<br>
> @@ -240,9 +240,11 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C<br>
>      private boolean mHardwareAccelerationError;<br>
>      private boolean mEndReached;<br>
>      private boolean mHasSubItems = false;<br>
> +    private boolean mForceStop = false;<br>
><br>
>      // Playlist<br>
>      private int savedIndexPosition = -1;<br>
> +    private boolean mHasNext = false;<br>
><br>
>      // size of the video<br>
>      private int mVideoHeight;<br>
> @@ -536,7 +538,8 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C<br>
>      protected void onNewIntent(Intent intent) {<br>
>          setIntent(intent);<br>
>          if (mPlaybackStarted) {<br>
> -            Uri uri = intent.hasExtra(PLAY_EXTRA_ITEM_LOCATION) ? (Uri) intent.getExtras().getParcelable(PLAY_EXTRA_ITEM_LOCATION) : intent.getData();<br>
> +            Uri uri = intent.hasExtra(PLAY_EXTRA_ITEM_LOCATION) ?<br>
> +                    (Uri) intent.getExtras().getParcelable(PLAY_EXTRA_ITEM_LOCATION) : intent.getData();<br>
>              if (uri == null || uri.equals(mUri))<br>
>                  return;<br>
>              stopPlayback();<br>
> @@ -820,7 +823,8 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C<br>
>              time = 0;<br>
>          else<br>
>              time -= 2000; // go back 2 seconds, to compensate loading time<br>
> -        mService.stop();<br>
> +        if (mForceStop || !mHasNext)<br>
> +            mService.stop();<br>
><br>
>          SharedPreferences.Editor editor = mSettings.edit();<br>
>          // Save position<br>
> @@ -885,8 +889,8 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C<br>
>      public static void start(Context context, Uri uri, String title) {<br>
>          start(context, uri, title, false, -1);<br>
>      }<br>
> -    public static void startOpened(Context context, int openedPosition) {<br>
> -        start(context, null, null, false, openedPosition);<br>
> +    public static void startOpened(Context context, Uri uri, int openedPosition) {<br>
> +        start(context, uri, null, false, openedPosition);<br>
>      }<br>
><br>
>      private static void start(Context context, Uri uri, String title, boolean fromStart, int openedPosition) {<br>
> @@ -895,10 +899,11 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C<br>
>          intent.putExtra(PLAY_EXTRA_ITEM_LOCATION, uri);<br>
>          intent.putExtra(PLAY_EXTRA_ITEM_TITLE, title);<br>
>          intent.putExtra(PLAY_EXTRA_FROM_START, fromStart);<br>
> -        intent.putExtra(PLAY_EXTRA_OPENED_POSITION, openedPosition);<br>
><br>
> -        if (openedPosition != -1)<br>
> -            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_MULTIPLE_TASK);<br>
> +        if (openedPosition != -1) {<br>
> +            intent.putExtra(PLAY_EXTRA_OPENED_POSITION, openedPosition);<br>
> +            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);<br>
> +        }<br>
><br>
>          context.startActivity(intent);<br>
>      }<br>
> @@ -1011,8 +1016,10 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C<br>
>              endDelaySetting();<br>
>          } else if (BuildConfig.tv && mShowing && !mIsLocked) {<br>
>              hideOverlay(true);<br>
> -        } else<br>
> +        } else {<br>
> +            mForceStop = true;<br>
>              exitOK();<br>
> +        }<br>
>      }<br>
><br>
>      @Override<br>
> @@ -1031,13 +1038,13 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C<br>
>          showOverlayTimeout(OVERLAY_TIMEOUT);<br>
>          switch (keyCode) {<br>
>          case KeyEvent.KEYCODE_F:<br>
> -        case KeyEvent.KEYCODE_MEDIA_FAST_FORWARD:<br>
>          case KeyEvent.KEYCODE_MEDIA_NEXT:<br>
> +        case KeyEvent.KEYCODE_MEDIA_FAST_FORWARD:<br>
>              seekDelta(10000);<br>
>              return true;<br>
>          case KeyEvent.KEYCODE_R:<br>
> +            case KeyEvent.KEYCODE_MEDIA_PREVIOUS:<br>
>          case KeyEvent.KEYCODE_MEDIA_REWIND:<br>
> -        case KeyEvent.KEYCODE_MEDIA_PREVIOUS:<br>
>              seekDelta(-10000);<br>
>              return true;<br>
>          case KeyEvent.KEYCODE_BUTTON_R1:<br>
> @@ -1511,7 +1518,7 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C<br>
>              });<br>
>          } else {<br>
>              /* Exit player when reaching the end */<br>
> -            mEndReached = true;<br>
> +            mEndReached = !mService.hasNext();<br>
>              exitOK();<br>
>          }<br>
>      }<br>
> @@ -2795,6 +2802,8 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C<br>
>                      onPlaying();<br>
>              }<br>
><br>
> +            mHasNext = mService.hasNext();<br>
> +<br>
>              // Get possible subtitles<br>
>              String subtitleList_serialized = mSettings.getString(PreferencesActivity.VIDEO_SUBTITLE_FILES, null);<br>
>              ArrayList<String> prefsList = new ArrayList<String>();<br>
> --<br>
> 2.5.0<br>
><br>
> _______________________________________________<br>
> Android mailing list<br>
> <a href="mailto:Android@videolan.org" target="_blank">Android@videolan.org</a><br>
> <a href="https://mailman.videolan.org/listinfo/android" rel="noreferrer" target="_blank">https://mailman.videolan.org/listinfo/android</a><br>
_______________________________________________<br>
Android mailing list<br>
<a href="mailto:Android@videolan.org" target="_blank">Android@videolan.org</a><br>
<a href="https://mailman.videolan.org/listinfo/android" rel="noreferrer" target="_blank">https://mailman.videolan.org/listinfo/android</a><br>
</blockquote></div>