[Android] Play all song sfrom songs view
Geoffrey Métais
git at videolan.org
Fri Aug 7 15:30:31 CEST 2015
vlc-ports/android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Fri Aug 7 15:30:05 2015 +0200| [afb843cf452223f4fb257f66c156cc008ea10648] | committer: Geoffrey Métais
Play all song sfrom songs view
> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=afb843cf452223f4fb257f66c156cc008ea10648
---
.../gui/tv/audioplayer/AudioPlayerActivity.java | 4 +++-
.../videolan/vlc/gui/tv/browser/MusicFragment.java | 23 +++++++++++++++-----
2 files changed, 21 insertions(+), 6 deletions(-)
diff --git a/vlc-android/tv/src/org/videolan/vlc/gui/tv/audioplayer/AudioPlayerActivity.java b/vlc-android/tv/src/org/videolan/vlc/gui/tv/audioplayer/AudioPlayerActivity.java
index 5b20895..8b8d5ab 100644
--- a/vlc-android/tv/src/org/videolan/vlc/gui/tv/audioplayer/AudioPlayerActivity.java
+++ b/vlc-android/tv/src/org/videolan/vlc/gui/tv/audioplayer/AudioPlayerActivity.java
@@ -57,6 +57,7 @@ public class AudioPlayerActivity extends BaseTvActivity implements PlaybackServi
public static final String TAG = "VLC/AudioPlayerActivity";
public static final String MEDIA_LIST = "media_list";
+ public static final String MEDIA_POSITION = "media_position";
private RecyclerView mRecyclerView;
private PlaylistAdapter mAdapter;
@@ -78,6 +79,7 @@ public class AudioPlayerActivity extends BaseTvActivity implements PlaybackServi
setContentView(R.layout.tv_audio_player);
mMediaList = getIntent().getParcelableArrayListExtra(MEDIA_LIST);
+ mCurrentlyPlaying = getIntent().getIntExtra(MEDIA_POSITION, 0);
mRecyclerView = (RecyclerView) findViewById(R.id.playlist);
mLayoutManager = new LinearLayoutManager(this);
mRecyclerView.setLayoutManager(mLayoutManager);
@@ -126,7 +128,7 @@ public class AudioPlayerActivity extends BaseTvActivity implements PlaybackServi
mService.addCallback(this);
ArrayList<MediaWrapper> medias = (ArrayList<MediaWrapper>) mService.getMedias();
if (!mMediaList.isEmpty() && !mMediaList.equals(medias)) {
- mService.load(mMediaList, 0);
+ mService.load(mMediaList, mCurrentlyPlaying);
} else {
mMediaList = medias;
update();
diff --git a/vlc-android/tv/src/org/videolan/vlc/gui/tv/browser/MusicFragment.java b/vlc-android/tv/src/org/videolan/vlc/gui/tv/browser/MusicFragment.java
index c66934b..7746c37 100644
--- a/vlc-android/tv/src/org/videolan/vlc/gui/tv/browser/MusicFragment.java
+++ b/vlc-android/tv/src/org/videolan/vlc/gui/tv/browser/MusicFragment.java
@@ -31,6 +31,7 @@ import android.support.v17.leanback.widget.OnItemViewClickedListener;
import android.support.v17.leanback.widget.Presenter;
import android.support.v17.leanback.widget.Row;
import android.support.v17.leanback.widget.RowPresenter;
+import android.text.TextUtils;
import org.videolan.vlc.MediaLibrary;
import org.videolan.vlc.MediaWrapper;
@@ -43,7 +44,6 @@ import org.videolan.vlc.util.WeakHandler;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
-import java.util.List;
import java.util.Map;
public class MusicFragment extends MediaLibBrowserFragment {
@@ -106,6 +106,7 @@ public class MusicFragment extends MediaLibBrowserFragment {
public class AsyncAudioUpdate extends AsyncTask<Void, ListItem, String> {
+ ArrayList<MediaWrapper> audioList;
public AsyncAudioUpdate() {}
@Override
@@ -122,7 +123,7 @@ public class MusicFragment extends MediaLibBrowserFragment {
String title;
ListItem item;
- List<MediaWrapper> audioList = MediaLibrary.getInstance().getAudioItems();
+ audioList = MediaLibrary.getInstance().getAudioItems();
if (CATEGORY_ARTISTS == mCategory){
Collections.sort(audioList, MediaComparators.byArtist);
title = getString(R.string.artists);
@@ -200,10 +201,22 @@ public class MusicFragment extends MediaLibBrowserFragment {
intent.putExtra(MEDIA_SECTION, FILTER_GENRE);
intent.putExtra(AUDIO_FILTER, listItem.mediaList.get(0).getGenre());
} else {
- if (CATEGORY_ALBUMS == mCategory)
- Collections.sort(listItem.mediaList, MediaComparators.byTrackNumber);
intent = new Intent(mContext, AudioPlayerActivity.class);
- intent.putExtra(AudioPlayerActivity.MEDIA_LIST, listItem.mediaList);
+ if (CATEGORY_ALBUMS == mCategory) {
+ Collections.sort(listItem.mediaList, MediaComparators.byTrackNumber);
+ intent.putExtra(AudioPlayerActivity.MEDIA_LIST, listItem.mediaList);
+ } else {
+ int position = 0;
+ String location = listItem.mediaList.get(0).getLocation();
+ for (int i = 0 ; i< audioList.size() ; ++i) {
+ if (TextUtils.equals(location, audioList.get(i).getLocation())) {
+ position = i;
+ break;
+ }
+ }
+ intent.putExtra(AudioPlayerActivity.MEDIA_LIST, audioList);
+ intent.putExtra(AudioPlayerActivity.MEDIA_POSITION, position);
+ }
}
startActivity(intent);
}
More information about the Android
mailing list