本文整理汇总了Java中android.media.browse.MediaBrowser.MediaItem类的典型用法代码示例。如果您正苦于以下问题:Java MediaItem类的具体用法?Java MediaItem怎么用?Java MediaItem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MediaItem类属于android.media.browse.MediaBrowser包,在下文中一共展示了MediaItem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: newInstance
import android.media.browse.MediaBrowser.MediaItem; //导入依赖的package包/类
static Object newInstance(List<MediaItem> itemList) {
ReflectiveOperationException e;
Object result = null;
try {
result = sConstructor.newInstance(new Object[]{itemList});
} catch (InstantiationException e2) {
e = e2;
e.printStackTrace();
return result;
} catch (IllegalAccessException e3) {
e = e3;
e.printStackTrace();
return result;
} catch (InvocationTargetException e4) {
e = e4;
e.printStackTrace();
return result;
}
return result;
}
示例2: onLoadChildren
import android.media.browse.MediaBrowser.MediaItem; //导入依赖的package包/类
@Override
public void onLoadChildren(@NonNull final String parentMediaId, @NonNull final Result<List<MediaItem>> result) {
result.detach();
switch (parentMediaId) {
case BROWSER_ROOT:
onLoadRoot(result);
break;
case DOWNLOADS_ROOT:
onLoadDownloads(result);
break;
case PLAYLIST_ROOT:
onLoadPlaylist(result);
break;
default:
onLoadPodcast(result, parentMediaId);
break;
}
}
示例3: onLoadDownloads
import android.media.browse.MediaBrowser.MediaItem; //导入依赖的package包/类
private void onLoadDownloads(final Result<List<MediaItem>> result) {
this.currentTask = new PodcastBrowserAsyncTask() {
@Override
protected Void doInBackground(Void... params) {
// Build list of downloaded episodes
final List<Episode> downloads = episodeManager.getDownloads();
for (Episode download : downloads)
items.add(episodeToMediaItem(download));
return null;
}
@Override
protected void onPostExecute(Void aVoid) {
result.sendResult(items);
}
};
currentTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
示例4: onLoadPlaylist
import android.media.browse.MediaBrowser.MediaItem; //导入依赖的package包/类
private void onLoadPlaylist(final Result<List<MediaItem>> result) {
this.currentTask = new PodcastBrowserAsyncTask() {
@Override
protected Void doInBackground(Void... params) {
// Build list of episodes in playlist
final List<Episode> playlist = episodeManager.getPlaylist();
for (Episode episode : playlist)
items.add(episodeToMediaItem(episode));
return null;
}
@Override
protected void onPostExecute(Void aVoid) {
result.sendResult(items);
}
};
currentTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
示例5: onLoadChildren
import android.media.browse.MediaBrowser.MediaItem; //导入依赖的package包/类
@Override
public void onLoadChildren(@NonNull final String parentMediaId, @NonNull final Result<List<MediaItem>> result) {
result.detach();
switch (parentMediaId) {
case BROWSER_ROOT:
onLoadRoot(result);
break;
case DOWNLOADS_ROOT:
onLoadDownloads(result);
break;
default:
onLoadPodcast(result, parentMediaId);
break;
}
}
示例6: getMediaItem
import android.media.browse.MediaBrowser.MediaItem; //导入依赖的package包/类
public void getMediaItem(String mediaId, final ResultReceiver receiver) {
ReflectiveOperationException e;
try {
final String KEY_MEDIA_ITEM = (String) MediaBrowserService.class.getDeclaredField("KEY_MEDIA_ITEM").get(null);
this.mServiceImpl.getMediaItem(mediaId, new ItemCallback() {
public void onItemLoaded(int resultCode, Bundle resultData, Parcel itemParcel) {
if (itemParcel != null) {
itemParcel.setDataPosition(0);
resultData.putParcelable(KEY_MEDIA_ITEM, (MediaItem) MediaItem.CREATOR.createFromParcel(itemParcel));
itemParcel.recycle();
}
receiver.send(resultCode, resultData);
}
});
} catch (IllegalAccessException e2) {
e = e2;
Log.i(MediaBrowserServiceCompatApi23.TAG, "Failed to get KEY_MEDIA_ITEM via reflection", e);
} catch (NoSuchFieldException e3) {
e = e3;
Log.i(MediaBrowserServiceCompatApi23.TAG, "Failed to get KEY_MEDIA_ITEM via reflection", e);
}
}
示例7: onLoadChildren
import android.media.browse.MediaBrowser.MediaItem; //导入依赖的package包/类
@Override
public void onLoadChildren(@NonNull final String parentMediaId,
@NonNull final Result<List<MediaItem>> result) {
if (!mMusicProvider.isInitialized()) {
// Use result.detach to allow calling result.sendResult from another thread:
result.detach();
mMusicProvider.retrieveMediaAsync(new MusicProvider.Callback() {
@Override
public void onMusicCatalogReady(boolean success) {
if (success) {
loadChildrenImpl(parentMediaId, result);
} else {
updatePlaybackState(getString(R.string.error_no_metadata));
result.sendResult(Collections.<MediaItem>emptyList());
}
}
});
} else {
// If our music catalog is already loaded/cached, load them into result immediately
loadChildrenImpl(parentMediaId, result);
}
}
示例8: onChildrenLoaded
import android.media.browse.MediaBrowser.MediaItem; //导入依赖的package包/类
@Override
public void onChildrenLoaded(@NonNull String parentId,
@NonNull List<MediaBrowser.MediaItem> children) {
mListRowAdapter.clear();
for (MediaBrowser.MediaItem item : children) {
mListRowAdapter.add(item);
}
mListRowAdapter.notifyArrayItemRangeChanged(0, children.size());
}
示例9: onItemClicked
import android.media.browse.MediaBrowser.MediaItem; //导入依赖的package包/类
@Override
public void onItemClicked(Presenter.ViewHolder itemViewHolder, Object item,
RowPresenter.ViewHolder rowViewHolder, Row row) {
getActivity().getMediaController().getTransportControls()
.playFromMediaId(((MediaItem) item).getMediaId(), null);
Intent intent = new Intent(getActivity(), TvPlaybackActivity.class);
Bundle bundle = ActivityOptionsCompat.makeSceneTransitionAnimation(
getActivity(),
((ImageCardView) itemViewHolder.view).getMainImageView(),
TvVerticalGridActivity.SHARED_ELEMENT_NAME).toBundle();
getActivity().startActivity(intent, bundle);
}
示例10: onChildrenLoaded
import android.media.browse.MediaBrowser.MediaItem; //导入依赖的package包/类
@Override
public void onChildrenLoaded(@NonNull String parentId, @NonNull List<MediaItem> children) {
mAdapter.clear();
for (int i = 0; i < children.size(); i++) {
MediaItem item = children.get(i);
if (!item.isPlayable()) {
LogHelper.e(TAG, "Cannot show non-playable items. Ignoring ", item.getMediaId());
} else {
mAdapter.add(item);
}
}
mAdapter.notifyArrayItemRangeChanged(0, children.size());
}
示例11: onLoadChildren
import android.media.browse.MediaBrowser.MediaItem; //导入依赖的package包/类
@Override
public void onLoadChildren(final String parentMediaId, final Result<List<MediaItem>> result) {
if (!mMusicProvider.isInitialized()) {
// Use result.detach to allow calling result.sendResult from another thread:
result.detach();
mMusicProvider.retrieveMediaAsync(new MusicProvider.Callback() {
@Override
public void onMusicCatalogReady(boolean success) {
if (success) {
loadChildrenImpl(parentMediaId, result);
} else {
updatePlaybackState(getString(R.string.error_no_metadata));
result.sendResult(Collections.<MediaItem>emptyList());
}
}
});
} else {
// If our music catalog is already loaded/cached, load them into result immediately
loadChildrenImpl(parentMediaId, result);
}
}
示例12: episodeToMediaItem
import android.media.browse.MediaBrowser.MediaItem; //导入依赖的package包/类
private MediaItem episodeToMediaItem(Episode episode) {
final Podcast podcast = episode.getPodcast();
final MediaDescription.Builder mediaDescription = new MediaDescription.Builder()
.setMediaId(episode.getMediaUrl())
.setTitle(episode.getName())
.setSubtitle(podcast.getName());
if (podcast.hasLogoUrl())
mediaDescription.setIconUri(Uri.parse(podcast.getLogoUrl()));
return new MediaItem(mediaDescription.build(), MediaItem.FLAG_PLAYABLE);
}
示例13: onItemLoaded
import android.media.browse.MediaBrowser.MediaItem; //导入依赖的package包/类
public void onItemLoaded(MediaItem item) {
Parcel parcel = Parcel.obtain();
item.writeToParcel(parcel, 0);
this.mItemCallback.onItemLoaded(parcel);
}
示例14: onLoadChildren
import android.media.browse.MediaBrowser.MediaItem; //导入依赖的package包/类
@Override
public void onLoadChildren(final String parentMediaId, final Result<List<MediaItem>> result) {
result.sendResult(LocalMusicSource.getMediaItems());
}
示例15: onLoadChildren
import android.media.browse.MediaBrowser.MediaItem; //导入依赖的package包/类
@Override
public void onLoadChildren(final String parentMediaId, final Result<List<MediaItem>> result) {
result.sendResult(new ArrayList<MediaItem>());
}