[Android] [PATCH] Add 'Insert next'

Geoffrey Métais geoffrey at videolan.org
Thu Mar 30 16:00:05 CEST 2017


I don't manage to apply your patch :/

Le ven. 24 mars 2017 à 21:05, Jens Jawer <jade at skygreen.de> a écrit :

> Adds menu entry to insert files after the currently playing (#241).
>
> ---
>   vlc-android/res/menu/audio_list_browser.xml        |  5 +++-
>   vlc-android/res/values-de/strings.xml              |  1 +
>   vlc-android/res/values/strings.xml                 |  1 +
>   .../src/org/videolan/vlc/PlaybackService.java      | 33
> ++++++++++++++++++++++
>   .../src/org/videolan/vlc/gui/PlaylistActivity.java |  3 ++
>   .../vlc/gui/audio/AudioAlbumsSongsFragment.java    |  3 ++
>   .../vlc/gui/audio/AudioBrowserFragment.java        |  3 ++
>   7 files changed, 48 insertions(+), 1 deletion(-)
>
> diff --git a/vlc-android/res/menu/audio_list_browser.xml
> b/vlc-android/res/menu/audio_list_browser.xml
> index f17432c..c4dcdad 100644
> --- a/vlc-android/res/menu/audio_list_browser.xml
> +++ b/vlc-android/res/menu/audio_list_browser.xml
> @@ -7,6 +7,9 @@
>       <item
>           android:id="@+id/audio_list_browser_append"
>           android:title="@string/append" />
> +    <item
> +        android:id="@+id/audio_list_browser_insert_next"
> +        android:title="@string/insert_next" />
>       <group android:id="@+id/songs_view_only">
>           <item
>               android:id="@+id/audio_list_browser_play_all"
> @@ -27,4 +30,4 @@
>               android:title="@string/set_song"/>
>       </group>
>
> -</menu>
> \ No newline at end of file
> +</menu>
> diff --git a/vlc-android/res/values-de/strings.xml
> b/vlc-android/res/values-de/strings.xml
> index 8ea9482..e4463b6 100644
> --- a/vlc-android/res/values-de/strings.xml
> +++ b/vlc-android/res/values-de/strings.xml
> @@ -24,6 +24,7 @@
>       <string name="play_as_audio_background">Videos im Hintergrund
> abspielen</string>
>       <string name="play_as_audio_background_summary">Video-Wiedergabe im
> Hintergund fortsetzen, wenn der Gerätebildschirm ausgeschaltet oder der
> HOME-Button gedrückt wurde.</string>
>       <string name="append">Anhängen</string>
> +    <string name="insert_next">Einfügen als Nächstes</string>
>       <string name="play_all">Alle wiedergeben</string>
>       <string name="append_all">Alle anhängen</string>
>       <string name="last_playlist">Letzte Wiedergabeliste</string>
> diff --git a/vlc-android/res/values/strings.xml
> b/vlc-android/res/values/strings.xml
> index cea6a3f..5a50c75 100644
> --- a/vlc-android/res/values/strings.xml
> +++ b/vlc-android/res/values/strings.xml
> @@ -28,6 +28,7 @@
>       <string name="play_as_audio_background">Play videos in
> background</string>
>       <string name="play_as_audio_background_summary">Continue video
> playback in background when turning device screen off or clicking HOME
> button.</string>
>       <string name="append">Append</string>
> +    <string name="insert_next">Insert next</string>
>       <string name="play_all">Play all</string>
>       <string name="append_all">Append all</string>
>       <string name="last_playlist">Last playlist</string>
> diff --git a/vlc-android/src/org/videolan/vlc/PlaybackService.java
> b/vlc-android/src/org/videolan/vlc/PlaybackService.java
> index 9ad1e17..48f244c 100644
> --- a/vlc-android/src/org/videolan/vlc/PlaybackService.java
> +++ b/vlc-android/src/org/videolan/vlc/PlaybackService.java
> @@ -2051,6 +2051,39 @@ public class PlaybackService extends
> MediaBrowserServiceCompat implements IVLCVo
>       }
>
>       /**
> +     * Insert into the current existing playlist
> +     */
> +
> +    @MainThread
> +    public void insertNext(MediaWrapper[] mediaList) {
> +        insertNext(Arrays.asList(mediaList));
> +    }
> +
> +    @MainThread
> +    public void insertNext(List<MediaWrapper> mediaList) {
> +        if (!hasCurrentMedia()) {
> +            load(mediaList, 0);
> +            return;
> +        }
> +
> +        int startIndex = mCurrentIndex + 1;
> +
> +        for (int i = 0; i < mediaList.size(); i++) {
> +            MediaWrapper mediaWrapper = mediaList.get(i);
> +            mMediaList.insert(startIndex + i, mediaWrapper);
> +        }
> +        onMediaListChanged();
> +        updateMediaQueue();
> +    }
> +
> +    @MainThread
> +    public void insertNext(MediaWrapper media) {
> +        ArrayList<MediaWrapper> arrayList = new ArrayList<>();
> +        arrayList.add(media);
> +        insertNext(arrayList);
> +    }
> +
> +    /**
>        * Move an item inside the playlist.
>        */
>       @MainThread
> diff --git a/vlc-android/src/org/videolan/vlc/gui/PlaylistActivity.java
> b/vlc-android/src/org/videolan/vlc/gui/PlaylistActivity.java
> index 0fdd39e..29745ab 100644
> --- a/vlc-android/src/org/videolan/vlc/gui/PlaylistActivity.java
> +++ b/vlc-android/src/org/videolan/vlc/gui/PlaylistActivity.java
> @@ -315,6 +315,9 @@ public class PlaylistActivity extends
> AudioPlayerContainerActivity implements IE
>           } else if (id == R.id.audio_list_browser_append) {
>               mService.append(media);
>               return true;
> +        } else if (id == R.id.audio_list_browser_insert_next) {
> +            mService.insertNext(media);
> +            return true;
>           } else if (id == R.id.audio_list_browser_delete) {
>               mAdapter.remove(media);
>               UiTools.snackerWithCancel(getWindow().getDecorView(),
> getString(R.string.file_deleted), new Runnable() {
> diff --git
> a/vlc-android/src/org/videolan/vlc/gui/audio/AudioAlbumsSongsFragment.java
> b/vlc-android/src/org/videolan/vlc/gui/audio/AudioAlbumsSongsFragment.java
> index e15e955..b79e774 100644
> ---
> a/vlc-android/src/org/videolan/vlc/gui/audio/AudioAlbumsSongsFragment.java
> +++
> b/vlc-android/src/org/videolan/vlc/gui/audio/AudioAlbumsSongsFragment.java
> @@ -200,6 +200,7 @@ public class AudioAlbumsSongsFragment extends
> BaseAudioBrowser implements SwipeR
>
>           boolean useAllItems = id == R.id.audio_list_browser_play_all;
>           boolean append = id == R.id.audio_list_browser_append;
> +        boolean insert_next = id ==
> R.id.audio_list_browser_insert_next;
>
>           if (id == R.id.audio_list_browser_delete) {
>
> @@ -254,6 +255,8 @@ public class AudioAlbumsSongsFragment extends
> BaseAudioBrowser implements SwipeR
>           if (mService != null) {
>               if (append)
>                   mService.append(medias);
> +            else if (insert_next)
> +                mService.insertNext(medias);
>               else
>                   mService.load(medias, startPosition);
>               return true;
> diff --git
> a/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java
> b/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java
> index 4ae3704..967412f 100644
> ---
> a/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java
> +++
> b/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java
> @@ -350,6 +350,7 @@ public class AudioBrowserFragment extends
> BaseAudioBrowser implements DevicesDis
>
>           boolean useAllItems = id == R.id.audio_list_browser_play_all;
>           boolean append = id == R.id.audio_list_browser_append;
> +        boolean insert_next = id ==
> R.id.audio_list_browser_insert_next;
>
>           // Play/Append
>           if (useAllItems) {
> @@ -368,6 +369,8 @@ public class AudioBrowserFragment extends
> BaseAudioBrowser implements DevicesDis
>           if (mService != null) {
>               if (append)
>                   mService.append(medias);
> +            else if (insert_next)
> +                mService.insertNext(medias);
>               else
>                   mService.load(medias, startPosition);
>               return true;
> --
> 2.7.4
>
> _______________________________________________
> Android mailing list
> Android at videolan.org
> https://mailman.videolan.org/listinfo/android
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/android/attachments/20170330/3a5de172/attachment-0001.html>


More information about the Android mailing list