Commit c96dca15 authored by Geoffrey Métais's avatar Geoffrey Métais

Do not ask for ML reference in Medialibrary module

parent 0a174381
......@@ -76,6 +76,7 @@ public class Medialibrary {
public boolean init(Context context) {
if (context == null)
return false;
mContext = context;
File extFilesDir = context.getExternalFilesDir(null);
File dbDirectory = context.getDir("db", Context.MODE_PRIVATE);
if (extFilesDir == null || !extFilesDir.exists())
......@@ -134,11 +135,9 @@ public class Medialibrary {
super.finalize();
}
public static synchronized Medialibrary getInstance(Context context) {
if (sInstance == null) {
public static synchronized Medialibrary getInstance() {
if (sInstance == null)
sInstance = new Medialibrary();
sInstance.mContext = context;
}
return sInstance;
}
......@@ -383,6 +382,7 @@ public class Medialibrary {
}
}
@SuppressWarnings("unused")
public void onBackgroundTasksIdleChanged(boolean isIdle) {
LocalBroadcastManager.getInstance(mContext).sendBroadcast(new Intent(ACTION_IDLE).putExtra(STATE_IDLE, isIdle));
mIsWorking = !isIdle;
......
......@@ -54,7 +54,8 @@ public class Album extends MediaLibraryItem {
return duration;
}
public MediaWrapper[] getTracks(Medialibrary ml) {
public MediaWrapper[] getTracks() {
Medialibrary ml = Medialibrary.getInstance();
return ml != null && ml.isInitiated() ? nativeGetTracksFromAlbum(ml, mId) : Medialibrary.EMPTY_COLLECTION;
}
......
......@@ -39,11 +39,13 @@ public class Artist extends MediaLibraryItem {
this.artworkMrl = artworkMrl;
}
public Album[] getAlbums(Medialibrary ml) {
public Album[] getAlbums() {
Medialibrary ml = Medialibrary.getInstance();
return ml != null && ml.isInitiated() ? nativeGetAlbumsFromArtist(ml, mId) : new Album[0];
}
public MediaWrapper[] getTracks(Medialibrary ml) {
public MediaWrapper[] getTracks() {
Medialibrary ml = Medialibrary.getInstance();
return ml != null && ml.isInitiated() ? nativeGetMediaFromArtist(ml, mId) : Medialibrary.EMPTY_COLLECTION;
}
......
......@@ -13,7 +13,7 @@ public class DummyItem extends MediaLibraryItem {
}
@Override
public MediaWrapper[] getTracks(Medialibrary ml) {
public MediaWrapper[] getTracks() {
return Medialibrary.EMPTY_COLLECTION;
}
......
......@@ -11,15 +11,18 @@ public class Genre extends MediaLibraryItem {
super(id, title);
}
public Album[] getAlbums(Medialibrary ml) {
public Album[] getAlbums() {
Medialibrary ml = Medialibrary.getInstance();
return ml != null && ml.isInitiated() ? nativeGetAlbumsFromGenre(ml, mId) : new Album[0];
}
public Artist[] getArtists(Medialibrary ml) {
public Artist[] getArtists() {
Medialibrary ml = Medialibrary.getInstance();
return ml != null && ml.isInitiated() ? nativeGetArtistsFromGenre(ml, mId) : new Artist[0];
}
public MediaWrapper[] getTracks(Medialibrary ml) {
public MediaWrapper[] getTracks() {
Medialibrary ml = Medialibrary.getInstance();
return ml != null && ml.isInitiated() ? nativeGetTracksFromGenre(ml, mId) : Medialibrary.EMPTY_COLLECTION;
}
......
......@@ -4,9 +4,6 @@ package org.videolan.medialibrary.media;
import android.net.Uri;
import android.os.Parcel;
import android.os.Parcelable;
import android.support.annotation.Nullable;
import org.videolan.medialibrary.Medialibrary;
import java.util.Date;
......@@ -29,7 +26,7 @@ public class HistoryItem extends MediaLibraryItem {
return mw;
}
@Override
public MediaWrapper[] getTracks(@Nullable Medialibrary ml) {
public MediaWrapper[] getTracks() {
return new MediaWrapper[]{getMedia()};
}
......
......@@ -21,7 +21,7 @@ public abstract class MediaLibraryItem implements Parcelable {
public static final int FLAG_SELECTED = 1;
public abstract MediaWrapper[] getTracks(Medialibrary ml);
public abstract MediaWrapper[] getTracks();
public abstract int getItemType();
long mId;
......
......@@ -304,7 +304,7 @@ public class MediaWrapper extends MediaLibraryItem implements Parcelable {
}
@Override
public MediaWrapper[] getTracks(Medialibrary ml) {
public MediaWrapper[] getTracks() {
return new MediaWrapper[] {this};
}
......@@ -588,20 +588,24 @@ public class MediaWrapper extends MediaLibraryItem implements Parcelable {
mFlags &= ~flags;
}
public long getMetaLong(Medialibrary ml, int metaDataType) {
public long getMetaLong(int metaDataType) {
Medialibrary ml = Medialibrary.getInstance();
return mId == 0 || !ml.isInitiated() ? 0L : nativeGetMediaLongMetadata(ml, mId, metaDataType);
}
public String getMetaString(Medialibrary ml, int metaDataType) {
public String getMetaString(int metaDataType) {
Medialibrary ml = Medialibrary.getInstance();
return mId == 0 || !ml.isInitiated() ? null : nativeGetMediaStringMetadata(ml, mId, metaDataType);
}
public boolean setLongMeta(Medialibrary ml, int metaDataType, long metadataValue) {
public boolean setLongMeta(int metaDataType, long metadataValue) {
Medialibrary ml = Medialibrary.getInstance();
if (mId != 0 && ml.isInitiated())
nativeSetMediaLongMetadata(ml, mId, metaDataType, metadataValue);
return mId != 0;
}
public boolean setStringMeta(Medialibrary ml, int metaDataType, String metadataValue) {
public boolean setStringMeta(int metaDataType, String metadataValue) {
Medialibrary ml = Medialibrary.getInstance();
if (mId != 0 && ml.isInitiated())
nativeSetMediaStringMetadata(ml, mId, metaDataType, metadataValue);
return mId != 0;
......
......@@ -16,7 +16,8 @@ public class Playlist extends MediaLibraryItem {
mTracksCount = trackCount;
}
public MediaWrapper[] getTracks(Medialibrary ml) {
public MediaWrapper[] getTracks() {
Medialibrary ml = Medialibrary.getInstance();
return ml != null && ml.isInitiated() ? nativeGetTracksFromPlaylist(ml, mId) : Medialibrary.EMPTY_COLLECTION;
}
......@@ -29,15 +30,18 @@ public class Playlist extends MediaLibraryItem {
return TYPE_PLAYLIST;
}
public boolean append(Medialibrary ml, long mediaId) {
public boolean append(long mediaId) {
Medialibrary ml = Medialibrary.getInstance();
return ml != null && ml.isInitiated() && nativePlaylistAppend(ml, mId, mediaId);
}
public boolean append(Medialibrary ml, long[] mediaIds) {
public boolean append(long[] mediaIds) {
Medialibrary ml = Medialibrary.getInstance();
return ml != null && ml.isInitiated() && nativePlaylistAppendGroup(ml, mId, mediaIds);
}
public boolean append(Medialibrary ml, List<Long> mediaIds) {
public boolean append(List<Long> mediaIds) {
Medialibrary ml = Medialibrary.getInstance();
if (ml == null || !ml.isInitiated())
return false;
long[] ids = new long[mediaIds.size()];
......@@ -46,19 +50,23 @@ public class Playlist extends MediaLibraryItem {
return nativePlaylistAppendGroup(ml, mId, ids);
}
public boolean add(Medialibrary ml, long mediaId, int position) {
public boolean add(long mediaId, int position) {
Medialibrary ml = Medialibrary.getInstance();
return ml != null && ml.isInitiated() && nativePlaylistAdd(ml, mId, mediaId, position);
}
public boolean move(Medialibrary ml, long mediaId, int position) {
public boolean move(long mediaId, int position) {
Medialibrary ml = Medialibrary.getInstance();
return ml != null && ml.isInitiated() && nativePlaylistMove(ml, mId, mediaId, position);
}
public boolean remove(Medialibrary ml, long mediaId) {
public boolean remove(long mediaId) {
Medialibrary ml = Medialibrary.getInstance();
return ml != null && ml.isInitiated() && nativePlaylistRemove(ml, mId, mediaId);
}
public boolean delete(Medialibrary ml) {
public boolean delete() {
Medialibrary ml = Medialibrary.getInstance();
return ml != null && ml.isInitiated() && nativePlaylistDelete(ml, mId);
}
......
......@@ -5,15 +5,13 @@ import android.net.Uri;
import android.os.Parcel;
import android.os.Parcelable;
import org.videolan.medialibrary.Medialibrary;
public class Storage extends MediaLibraryItem {
Uri uri;
String description;
@Override
public MediaWrapper[] getTracks(Medialibrary ml) {
public MediaWrapper[] getTracks() {
return new MediaWrapper[0];
}
......
......@@ -675,19 +675,19 @@ public class PlaybackService extends MediaBrowserServiceCompat implements IVLCVo
//increase seen counter if more than 90% of the media have been seen
//and reset progress to 0
long incSeen = media.getSeen() + 1L;
media.setLongMeta(mMedialibrary, MediaWrapper.META_SEEN, incSeen);
media.setLongMeta(MediaWrapper.META_SEEN, incSeen);
media.setSeen(incSeen);
progress = 0f;
}
media.setTime(progress == 0f ? 0L : time);
media.setLongMeta(mMedialibrary, MediaWrapper.META_PROGRESS, (long) (progress*100));
media.setLongMeta(MediaWrapper.META_PROGRESS, (long) (progress*100));
}
if (canSwitchToVideo) {
//Save audio delay
if (mSettings.getBoolean("save_individual_audio_delay", false))
media.setLongMeta(mMedialibrary, MediaWrapper.META_AUDIODELAY, mMediaPlayer.getAudioDelay());
media.setLongMeta(mMedialibrary, MediaWrapper.META_SUBTITLE_DELAY, mMediaPlayer.getSpuDelay());
media.setLongMeta(mMedialibrary, MediaWrapper.META_SUBTITLE_TRACK, mMediaPlayer.getSpuTrack());
media.setLongMeta(MediaWrapper.META_AUDIODELAY, mMediaPlayer.getAudioDelay());
media.setLongMeta(MediaWrapper.META_SUBTITLE_DELAY, mMediaPlayer.getSpuDelay());
media.setLongMeta(MediaWrapper.META_SUBTITLE_TRACK, mMediaPlayer.getSpuTrack());
}
}
......@@ -697,9 +697,9 @@ public class PlaybackService extends MediaBrowserServiceCompat implements IVLCVo
return;
if (canSwitchToVideo()) {
if (mSettings.getBoolean("save_individual_audio_delay", false))
mMediaPlayer.setAudioDelay(media.getMetaLong(mMedialibrary, MediaWrapper.META_AUDIODELAY));
mMediaPlayer.setSpuTrack((int) media.getMetaLong(mMedialibrary, MediaWrapper.META_SUBTITLE_TRACK));
mMediaPlayer.setSpuDelay(media.getMetaLong(mMedialibrary, MediaWrapper.META_SUBTITLE_DELAY));
mMediaPlayer.setAudioDelay(media.getMetaLong(MediaWrapper.META_AUDIODELAY));
mMediaPlayer.setSpuTrack((int) media.getMetaLong(MediaWrapper.META_SUBTITLE_TRACK));
mMediaPlayer.setSpuDelay(media.getMetaLong(MediaWrapper.META_SUBTITLE_DELAY));
}
}
......@@ -1213,9 +1213,9 @@ public class PlaybackService extends MediaBrowserServiceCompat implements IVLCVo
@Override
public void onPlayFromMediaId(String mediaId, Bundle extras) {
if (mediaId.startsWith(BrowserProvider.ALBUM_PREFIX)) {
load(mMedialibrary.getAlbum(Long.parseLong(mediaId.split("_")[1])).getTracks(mMedialibrary), 0);
load(mMedialibrary.getAlbum(Long.parseLong(mediaId.split("_")[1])).getTracks(), 0);
} else if (mediaId.startsWith(BrowserProvider.PLAYLIST_PREFIX)) {
load(mMedialibrary.getPlaylist(Long.parseLong(mediaId.split("_")[1])).getTracks(mMedialibrary), 0);
load(mMedialibrary.getPlaylist(Long.parseLong(mediaId.split("_")[1])).getTracks(), 0);
} else
try {
load(mMedialibrary.getMedia(Long.parseLong(mediaId)));
......@@ -1263,14 +1263,14 @@ public class PlaybackService extends MediaBrowserServiceCompat implements IVLCVo
if (Tools.isArrayEmpty(tracks)){
SearchAggregate result = mMedialibrary.search(query);
if (!Tools.isArrayEmpty(result.getAlbums()))
tracks = result.getAlbums()[0].getTracks(mMedialibrary);
tracks = result.getAlbums()[0].getTracks();
else if (!Tools.isArrayEmpty(result.getArtists()))
tracks = result.getArtists()[0].getTracks(mMedialibrary);
tracks = result.getArtists()[0].getTracks();
else if (!Tools.isArrayEmpty(result.getGenres()))
tracks = result.getGenres()[0].getTracks(mMedialibrary);
tracks = result.getGenres()[0].getTracks();
}
if (tracks == null && !Tools.isArrayEmpty(items))
tracks = items[0].getTracks(mMedialibrary);
tracks = items[0].getTracks();
if (!Tools.isArrayEmpty(tracks))
load(tracks, 0);
}
......
......@@ -231,7 +231,7 @@ public class VLCApplication extends Application {
public static Medialibrary getMLInstance() {
if (sMedialibraryInstance == null) {
sMedialibraryInstance = Medialibrary.getInstance(instance);
sMedialibraryInstance = Medialibrary.getInstance();
}
return sMedialibraryInstance;
}
......
......@@ -121,7 +121,7 @@ public class InfoActivity extends AudioPlayerContainerActivity implements View.O
private void updateMeta() {
long length = 0L;
MediaWrapper[] tracks = mItem.getTracks(VLCApplication.getMLInstance());
MediaWrapper[] tracks = mItem.getTracks();
int nbTracks = tracks != null ? tracks.length : 0;
if (nbTracks > 0)
for (MediaWrapper media : tracks)
......@@ -136,7 +136,7 @@ public class InfoActivity extends AudioPlayerContainerActivity implements View.O
mBinding.setSizeTitleText(getString(R.string.file_size));
} else if (mItem.getItemType() == MediaLibraryItem.TYPE_ARTIST) {
Medialibrary ml = VLCApplication.getMLInstance();
Album[] albums = ((Artist)mItem).getAlbums(ml);
Album[] albums = ((Artist)mItem).getAlbums();
int nbAlbums = albums == null ? 0 : albums.length;
mBinding.setSizeTitleText(getString(R.string.albums));
mBinding.setSizeValueText(String.valueOf(nbAlbums));
......@@ -184,7 +184,7 @@ public class InfoActivity extends AudioPlayerContainerActivity implements View.O
@Override
public void onClick(View v) {
mService.load(mItem.getTracks(VLCApplication.getMLInstance()), 0);
mService.load(mItem.getTracks(), 0);
finish();
}
......
......@@ -164,7 +164,7 @@ public class PlaylistActivity extends AudioPlayerContainerActivity implements IE
private void updateList() {
if (mPlaylist != null) {
ArrayList<? extends MediaLibraryItem> tracks = Util.arrayToArrayList(mPlaylist.getTracks(mMediaLibrary));
ArrayList<? extends MediaLibraryItem> tracks = Util.arrayToArrayList(mPlaylist.getTracks());
mAdapter.addAll(tracks);
}
}
......@@ -177,7 +177,7 @@ public class PlaylistActivity extends AudioPlayerContainerActivity implements IE
mAdapter.notifyItemChanged(position, item);
invalidateActionMode();
} else if (mService != null)
mService.load(mPlaylist.getTracks(mMediaLibrary), position);
mService.load(mPlaylist.getTracks(), position);
}
@Override
......@@ -251,7 +251,7 @@ public class PlaylistActivity extends AudioPlayerContainerActivity implements IE
List<MediaLibraryItem> list = mAdapter.getSelection();
ArrayList<MediaWrapper> tracks = new ArrayList<>();
for (MediaLibraryItem mediaItem : list)
tracks.addAll(Arrays.asList(mediaItem.getTracks(mMediaLibrary)));
tracks.addAll(Arrays.asList(mediaItem.getTracks()));
stopActionMode();
switch (item.getItemId()) {
case R.id.action_mode_audio_play:
......@@ -340,7 +340,7 @@ public class PlaylistActivity extends AudioPlayerContainerActivity implements IE
FragmentManager fm = getSupportFragmentManager();
SavePlaylistDialog savePlaylistDialog = new SavePlaylistDialog();
Bundle args = new Bundle();
args.putParcelableArray(SavePlaylistDialog.KEY_NEW_TRACKS, media.getTracks(mMediaLibrary));
args.putParcelableArray(SavePlaylistDialog.KEY_NEW_TRACKS, media.getTracks());
savePlaylistDialog.setArguments(args);
savePlaylistDialog.show(fm, "fragment_add_to_playlist");
return true;
......@@ -371,7 +371,7 @@ public class PlaylistActivity extends AudioPlayerContainerActivity implements IE
public void run() {
final LinkedList<String> foldersToReload = new LinkedList<>();
final LinkedList<String> mediaPaths = new LinkedList<>();
for (MediaWrapper media : mw.getTracks(mMediaLibrary)) {
for (MediaWrapper media : mw.getTracks()) {
String path = media.getUri().getPath();
mediaPaths.add(media.getLocation());
String parentPath = FileUtils.getParent(path);
......@@ -396,6 +396,6 @@ public class PlaylistActivity extends AudioPlayerContainerActivity implements IE
@Override
public void onClick(View v) {
if (mService != null)
mService.load(mPlaylist.getTracks(mMediaLibrary), 0);
mService.load(mPlaylist.getTracks(), 0);
}
}
......@@ -141,7 +141,7 @@ public class SearchActivity extends AppCompatActivity implements TextWatcher, Te
finish();
}
public void onItemClick(MediaLibraryItem item) {
MediaUtils.openArray(SearchActivity.this, item.getTracks(mMedialibrary), 0);
MediaUtils.openArray(SearchActivity.this, item.getTracks(), 0);
finish();
}
}
......
......@@ -235,7 +235,7 @@ public class AudioAlbumsSongsFragment extends BaseAudioBrowser implements SwipeR
FragmentManager fm = getActivity().getSupportFragmentManager();
SavePlaylistDialog savePlaylistDialog = new SavePlaylistDialog();
Bundle args = new Bundle();
args.putParcelableArray(SavePlaylistDialog.KEY_NEW_TRACKS, mediaItem.getTracks(mMediaLibrary));
args.putParcelableArray(SavePlaylistDialog.KEY_NEW_TRACKS, mediaItem.getTracks());
savePlaylistDialog.setArguments(args);
savePlaylistDialog.show(fm, "fragment_add_to_playlist");
return true;
......@@ -248,7 +248,7 @@ public class AudioAlbumsSongsFragment extends BaseAudioBrowser implements SwipeR
} else {
startPosition = 0;
if (mediaItem instanceof Album)
medias = mediaItem.getTracks(mMediaLibrary);
medias = mediaItem.getTracks();
else
medias = new MediaWrapper[] {(MediaWrapper) mediaItem};
}
......@@ -274,10 +274,10 @@ public class AudioAlbumsSongsFragment extends BaseAudioBrowser implements SwipeR
public void run() {
final ArrayList<? extends MediaLibraryItem> albums;
if (mItem.getItemType() == MediaLibraryItem.TYPE_ARTIST) {
albums = Util.arrayToArrayList(((Artist) mItem).getAlbums(mMediaLibrary));
albums = Util.arrayToArrayList(((Artist) mItem).getAlbums());
}
else if (mItem.getItemType() == MediaLibraryItem.TYPE_GENRE)
albums = Util.arrayToArrayList(((Genre) mItem).getAlbums(mMediaLibrary));
albums = Util.arrayToArrayList(((Genre) mItem).getAlbums());
else
return;
final LinkedList<MediaLibraryItem> songs = new LinkedList<>();
......@@ -286,7 +286,7 @@ public class AudioAlbumsSongsFragment extends BaseAudioBrowser implements SwipeR
if (TextUtils.isEmpty(title))
title = getString(R.string.unknown_album);
songs.add(new DummyItem(title));
songs.addAll(Arrays.asList(album.getTracks(mMediaLibrary)));
songs.addAll(Arrays.asList(album.getTracks()));
}
mHandler.post(new Runnable() {
@Override
......
......@@ -334,7 +334,7 @@ public class AudioBrowserFragment extends BaseAudioBrowser implements ISortable,
}
if (id == R.id.audio_view_add_playlist) {
UiTools.addToPlaylist(getActivity(), mediaItem.getTracks(mMediaLibrary));
UiTools.addToPlaylist(getActivity(), mediaItem.getTracks());
return true;
}
......@@ -356,7 +356,7 @@ public class AudioBrowserFragment extends BaseAudioBrowser implements ISortable,
startPosition = 0;
if (position >= adapter.getItemCount())
return false;
medias = mediaItem.getTracks(mMediaLibrary);
medias = mediaItem.getTracks();
}
if (mService != null) {
......@@ -508,7 +508,7 @@ public class AudioBrowserFragment extends BaseAudioBrowser implements ISortable,
VLCApplication.runBackground(new Runnable() {
@Override
public void run() {
playlist.delete(mMediaLibrary);
playlist.delete();
mHandler.obtainMessage(UPDATE_LIST).sendToTarget();
}
});
......
......@@ -81,7 +81,7 @@ public abstract class BaseAudioBrowser extends MediaBrowserFragment implements I
if (!list.isEmpty()) {
ArrayList<MediaWrapper> tracks = new ArrayList<>();
for (MediaLibraryItem mediaItem : list)
tracks.addAll(Arrays.asList(mediaItem.getTracks(mMediaLibrary)));
tracks.addAll(Arrays.asList(mediaItem.getTracks()));
switch (item.getItemId()) {
case R.id.action_mode_audio_play:
mService.load(tracks, 0);
......
......@@ -562,7 +562,7 @@ public abstract class BaseBrowserFragment extends MediaBrowserFragment implement
FragmentManager fm = getActivity().getSupportFragmentManager();
SavePlaylistDialog savePlaylistDialog = new SavePlaylistDialog();
Bundle infoArgs = new Bundle();
infoArgs.putParcelableArray(SavePlaylistDialog.KEY_NEW_TRACKS, mw.getTracks(null));
infoArgs.putParcelableArray(SavePlaylistDialog.KEY_NEW_TRACKS, mw.getTracks());
savePlaylistDialog.setArguments(infoArgs);
savePlaylistDialog.show(fm, "fragment_add_to_playlist");
return true;
......
......@@ -175,7 +175,7 @@ public abstract class MediaBrowserFragment extends PlaybackServiceFragment imple
public void run() {
final LinkedList<String> foldersToReload = new LinkedList<>();
final LinkedList<String> mediaPaths = new LinkedList<>();
for (MediaWrapper media : mw.getTracks(mMediaLibrary)) {
for (MediaWrapper media : mw.getTracks()) {
String path = media.getUri().getPath();
mediaPaths.add(media.getLocation());
String parentPath = FileUtils.getParent(path);
......
......@@ -155,8 +155,8 @@ public class SavePlaylistDialog extends DialogFragment implements View.OnClickLi
if (addTracks) {
tracks = mNewTrack;
} else {//Save a playlist
for (MediaWrapper mw : playlist.getTracks(mMedialibrary))
playlist.remove(mMedialibrary, mw.getId());
for (MediaWrapper mw : playlist.getTracks())
playlist.remove(mw.getId());
tracks = mTracks;
}
LinkedList<Long> ids = new LinkedList<>();
......@@ -174,7 +174,7 @@ public class SavePlaylistDialog extends DialogFragment implements View.OnClickLi
} else
ids.add(id);
}
playlist.append(mMedialibrary, ids);
playlist.append(ids);
if (mCallBack != null)
mCallBack.run();
}
......
......@@ -130,7 +130,7 @@ public class TvUtil {
public static void openAudioCategory(Activity context, MediaLibraryItem mediaLibraryItem) {
if (mediaLibraryItem.getItemType() == MediaLibraryItem.TYPE_ALBUM) {
TvUtil.playAudioList(context, mediaLibraryItem.getTracks(VLCApplication.getMLInstance()), 0);
TvUtil.playAudioList(context, mediaLibraryItem.getTracks(), 0);
} else {
Intent intent = new Intent(context, VerticalGridActivity.class);
intent.putExtra(AUDIO_ITEM, mediaLibraryItem);
......
......@@ -149,9 +149,9 @@ public class MusicFragment extends MediaLibBrowserFragment implements OnItemView
if (mCurrentItem == null)
mDataList = mMediaLibrary.getAlbums();
else if (mCurrentItem.getItemType() == MediaLibraryItem.TYPE_ARTIST)
mDataList = ((Artist)mCurrentItem).getAlbums(mMediaLibrary);
mDataList = ((Artist)mCurrentItem).getAlbums();
else if (mCurrentItem.getItemType() == MediaLibraryItem.TYPE_GENRE)
mDataList = ((Genre)mCurrentItem).getAlbums(mMediaLibrary);
mDataList = ((Genre)mCurrentItem).getAlbums();
else
return null;
} else if (CATEGORY_GENRES == mCategory){
......
......@@ -1654,12 +1654,12 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
return;
if (event.getEsChangedType() == Media.Track.Type.Audio) {
setESTrackLists();
int audioTrack = (int) media.getMetaLong(mMedialibrary, MediaWrapper.META_AUDIOTRACK);
int audioTrack = (int) media.getMetaLong(MediaWrapper.META_AUDIOTRACK);
if (audioTrack != 0 || mCurrentAudioTrack != -2)
mService.setAudioTrack(media.getId() == 0L ? mCurrentAudioTrack : audioTrack);
} else if (event.getEsChangedType() == Media.Track.Type.Text) {
setESTrackLists();
int spuTrack = (int) media.getMetaLong(mMedialibrary, MediaWrapper.META_SUBTITLE_TRACK);
int spuTrack = (int) media.getMetaLong(MediaWrapper.META_SUBTITLE_TRACK);
if (spuTrack != 0 || mCurrentSpuTrack != -2)
mService.setSpuTrack(media.getId() == 0L ? mCurrentAudioTrack : spuTrack);
}
......@@ -2588,7 +2588,7 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
mService.setAudioTrack(trackID);
MediaWrapper mw = mMedialibrary.findMedia(mService.getCurrentMediaWrapper());
if (mw != null && mw.getId() != 0L)
mw.setLongMeta(mMedialibrary, MediaWrapper.META_AUDIOTRACK, trackID);
mw.setLongMeta(MediaWrapper.META_AUDIOTRACK, trackID);
return true;
}
});
......@@ -2605,7 +2605,7 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
mService.setSpuTrack(trackID);
MediaWrapper mw = mMedialibrary.findMedia(mService.getCurrentMediaWrapper());
if (mw != null && mw.getId() != 0L)
mw.setLongMeta(mMedialibrary, MediaWrapper.META_SUBTITLE_TRACK, trackID);
mw.setLongMeta(MediaWrapper.META_SUBTITLE_TRACK, trackID);
return true;
}
});
......@@ -3144,7 +3144,7 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
media = ml.getMedia(mUri);
}
if (media != null && media.getId() != 0L && media.getTime() == 0L)
media.setTime((long) (media.getMetaLong(mMedialibrary, MediaWrapper.META_PROGRESS) * (double) media.getLength())/100L);
media.setTime((long) (media.getMetaLong(MediaWrapper.META_PROGRESS) * (double) media.getLength())/100L);
} else
media = openedMedia;
if (media != null) {
......
......@@ -140,10 +140,10 @@ public class BrowserProvider {
long id = Long.parseLong(idSections[1]);
switch (idSections[0]) {
case ARTIST_PREFIX:
list = ml.getArtist(id).getAlbums(ml);
list = ml.getArtist(id).getAlbums();
break;
case GENRE_PREFIX:
list = ml.getGenre(id).getAlbums(ml);
list = ml.getGenre(id).getAlbums();
break;
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment