[Android] Add external media to playlists
Hugo Beauzée-Luyssen
hugo at beauzee.fr
Wed Jan 4 14:43:10 CET 2017
On 01/03/2017 05:13 PM, Geoffrey Métais wrote:
> vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Tue Jan 3 14:35:46 2017 +0100| [6d69478d6cd4db20c6a77a56732e7294d1074d3e] | committer: Geoffrey Métais
>
> Add external media to playlists
>
>> https://code.videolan.org/videolan/vlc-android/commit/6d69478d6cd4db20c6a77a56732e7294d1074d3e
> ---
>
> .../vlc/gui/dialogs/SavePlaylistDialog.java | 22 +++++++++++++++++++---
> 1 file changed, 19 insertions(+), 3 deletions(-)
>
> diff --git a/vlc-android/src/org/videolan/vlc/gui/dialogs/SavePlaylistDialog.java b/vlc-android/src/org/videolan/vlc/gui/dialogs/SavePlaylistDialog.java
> index 64a2600..6483787 100644
> --- a/vlc-android/src/org/videolan/vlc/gui/dialogs/SavePlaylistDialog.java
> +++ b/vlc-android/src/org/videolan/vlc/gui/dialogs/SavePlaylistDialog.java
> @@ -148,16 +148,32 @@ public class SavePlaylistDialog extends DialogFragment implements View.OnClickLi
> if (addTracks) {
> if (!exists)
> playlist = mMedialibrary.createPlaylist(name);
> - ids = new long[mTracks.size()];
> - for (int i = 0 ; i < mNewTrack.size(); ++i)
> + ids = new long[mNewTrack.size()];
> + for (int i = 0 ; i < mNewTrack.size(); ++i) {
> ids[i] = mNewTrack.get(i).getId();
> + if (ids[i] == 0) {
> + MediaWrapper media = mMedialibrary.getMedia(mNewTrack.get(i).getLocation());
> + if (media != null && media.getId() != 0)
A media returned from the medialibrary will always have an ID > 0
> + ids[i] = media.getId();
> + else
> + ids[i] = mMedialibrary.addMedia(mNewTrack.get(i).getLocation()).getId();
There's a thin possibility for addMedia to return a null media
(unlikely, but theoretically possible)
> + }
> + }
> } else { //Save a playlist
> if (exists)
> playlist.delete(mMedialibrary);
> playlist = mMedialibrary.createPlaylist(name);
> ids = new long[mTracks.size()];
> - for (int i = 0; i < mTracks.size(); ++i)
> + for (int i = 0; i < mTracks.size(); ++i) {
> ids[i] = mTracks.get(i).getId();
> + if (ids[i] == 0) {
> + MediaWrapper media = mMedialibrary.getMedia(mNewTrack.get(i).getLocation());
> + if (media != null && media.getId() != 0)
> + ids[i] = media.getId();
> + else
> + ids[i] = mMedialibrary.addMedia(mNewTrack.get(i).getLocation()).getId();
> + }
> + }
> }
> playlist.append(mMedialibrary, ids);
> if (mCallBack != null)
>
> _______________________________________________
> Android mailing list
> Android at videolan.org
> https://mailman.videolan.org/listinfo/android
>
More information about the Android
mailing list