• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java MediaItem类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中android.media.browse.MediaBrowser.MediaItem的典型用法代码示例。如果您正苦于以下问题:Java MediaItem类的具体用法?Java MediaItem怎么用?Java MediaItem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



MediaItem类属于android.media.browse.MediaBrowser包,在下文中一共展示了MediaItem类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:21,代码来源:ParceledListSliceAdapterApi21.java


示例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;
    }
}
 
开发者ID:salema,项目名称:Podcatcher-Deluxe-Android-Studio,代码行数:20,代码来源:PodcastBrowserService.java


示例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);
}
 
开发者ID:salema,项目名称:Podcatcher-Deluxe-Android-Studio,代码行数:22,代码来源:PodcastBrowserService.java


示例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);
}
 
开发者ID:salema,项目名称:Podcatcher-Deluxe-Android-Studio,代码行数:22,代码来源:PodcastBrowserService.java


示例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;
    }
}
 
开发者ID:salema,项目名称:Podcatcher-Deluxe-Android-Studio,代码行数:17,代码来源:PodcastBrowserService.java


示例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);
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:23,代码来源:MediaBrowserServiceCompatApi23.java


示例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);
    }
}
 
开发者ID:mrinalgit-dev,项目名称:MrinalMusicPlayer,代码行数:25,代码来源:MusicService.java


示例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());
}
 
开发者ID:mrinalgit-dev,项目名称:MrinalMusicPlayer,代码行数:10,代码来源:TvBrowseFragment.java


示例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);
}
 
开发者ID:mrinalgit-dev,项目名称:MrinalMusicPlayer,代码行数:16,代码来源:TvVerticalGridFragment.java


示例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());
}
 
开发者ID:mrinalgit-dev,项目名称:MrinalMusicPlayer,代码行数:14,代码来源:TvVerticalGridFragment.java


示例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);
    }
}
 
开发者ID:ErNaveen,项目名称:UniversalMusicPlayer,代码行数:24,代码来源:MusicService.java


示例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);
}
 
开发者ID:salema,项目名称:Podcatcher-Deluxe-Android-Studio,代码行数:13,代码来源:PodcastBrowserService.java


示例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);
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:6,代码来源:MediaBrowserCompatApi23.java


示例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());
}
 
开发者ID:smitzey,项目名称:AndroidAutoTourGuide,代码行数:5,代码来源:MuziKarMusicService.java


示例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>());
}
 
开发者ID:smitzey,项目名称:AndroidAutoTourGuide,代码行数:5,代码来源:MyMusicService.java


示例16: onLoadChildren

import android.media.browse.MediaBrowser.MediaItem; //导入依赖的package包/类
@Override
public void onLoadChildren(final String parentMediaId, final Result<List<MediaItem>> result) {
    Log.d (TAG, "onLoadChildren()" ) ;
    result.sendResult(LocalMusicSource.getMediaItems());
}
 
开发者ID:smitzey,项目名称:AndroidAutoTourGuide,代码行数:6,代码来源:MuziKarMusicService.java


示例17: onLoadChildren

import android.media.browse.MediaBrowser.MediaItem; //导入依赖的package包/类
@Override
public void onLoadChildren(final String parentMediaId, final Result<List<MediaItem>> result) {
    result.sendResult(MusicLibrary.getMediaItems());
}
 
开发者ID:googlecodelabs,项目名称:android-music-player,代码行数:5,代码来源:MusicService.java


示例18: onLoadRoot

import android.media.browse.MediaBrowser.MediaItem; //导入依赖的package包/类
private void onLoadRoot(final Result<List<MediaItem>> result) {
    this.currentTask = new PodcastBrowserAsyncTask() {

        @Override
        protected Void doInBackground(Void... params) {
            try {
                episodeManager.blockUntilEpisodeMetadataIsLoaded();
            } catch (InterruptedException e) {
                cancel(true);
            }

            // Add Downloads entry
            if (episodeManager.getDownloadsSize() > 0)
                items.add(new MediaItem(new MediaDescription.Builder()
                        .setMediaId(DOWNLOADS_ROOT)
                        .setTitle(getString(R.string.downloads))
                        .setSubtitle(getResources().getQuantityString(R.plurals.episodes,
                                episodeManager.getDownloadsSize(), episodeManager.getDownloadsSize()))
                        .build(), MediaItem.FLAG_BROWSABLE));

            // Add Playlist entry
            if (episodeManager.getPlaylistSize() > 0)
                items.add(new MediaItem(new MediaDescription.Builder()
                        .setMediaId(PLAYLIST_ROOT)
                        .setTitle(getString(R.string.playlist))
                        .setSubtitle(getResources().getQuantityString(R.plurals.episodes,
                                episodeManager.getPlaylistSize(), episodeManager.getPlaylistSize()))
                        .build(), MediaItem.FLAG_BROWSABLE));

            // Build list of podcasts
            final List<Podcast> podcasts = podcastManager.getPodcastList();
            for (Podcast podcast : podcasts) {
                final int episodeCount = podcast.getEpisodeCount();
                final MediaDescription.Builder mediaDescription = new MediaDescription.Builder()
                        .setMediaId(podcast.getUrl())
                        .setTitle(podcast.getName())
                        .setSubtitle(episodeCount > 0 ? getResources()
                                .getQuantityString(R.plurals.episodes, episodeCount, episodeCount) : null);

                if (podcast.hasLogoUrl())
                    mediaDescription.setIconUri(Uri.parse(podcast.getLogoUrl()));

                items.add(new MediaItem(mediaDescription.build(), MediaItem.FLAG_BROWSABLE));
            }

            return null;
        }

        @Override
        protected void onPostExecute(Void aVoid) {
            result.sendResult(items);
        }
    };

    currentTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
 
开发者ID:salema,项目名称:Podcatcher-Deluxe-Android-Studio,代码行数:57,代码来源:PodcastBrowserService.java


示例19: onLoadPodcast

import android.media.browse.MediaBrowser.MediaItem; //导入依赖的package包/类
private void onLoadPodcast(final Result<List<MediaItem>> result, final String podcastUrl) {
    this.currentTask = new PodcastBrowserAsyncTask() {

        /**
         * Thread sync latch used to wait for podcast loading
         */
        private CountDownLatch latch = new CountDownLatch(1);
        /**
         * The feed URL we are currently waiting for. Needs to
         * be a member because we have to update it onPodcastMoved()
         */
        private String loadingPodcastUrl = podcastUrl;

        private OnLoadPodcastListener listener = new OnLoadPodcastListener() {

            @Override
            public void onPodcastLoadProgress(Podcast podcast, Progress progress) {
                // pass
            }

            @Override
            public void onPodcastMoved(Podcast podcast, String newUrl) {
                if (podcast.equalByUrl(loadingPodcastUrl))
                    loadingPodcastUrl = newUrl;
            }

            @Override
            public void onPodcastLoaded(Podcast podcast) {
                // Make sure we got the right podcast
                if (podcast.equalByUrl(loadingPodcastUrl)) {
                    if (podcast.getEpisodeCount() > 0) {
                        // Limit episode list to a low item number
                        final List<Episode> episodes = podcast.getEpisodes().subList(0,
                                podcast.getEpisodeCount() < EPISODE_LIST_LIMIT ?
                                        podcast.getEpisodeCount() : EPISODE_LIST_LIMIT);

                        for (Episode episode : episodes)
                            items.add(episodeToMediaItem(episode));
                    }

                    // Items ready, let task send results
                    latch.countDown();
                }
            }

            @Override
            public void onPodcastLoadFailed(Podcast podcast, LoadPodcastTask.PodcastLoadError code) {
                if (podcast.equalByUrl(loadingPodcastUrl))
                    latch.countDown();
            }
        };

        @Override
        protected void onPreExecute() {
            // Needs to run on UI thread
            podcastManager.addLoadPodcastListener(listener);
            podcastManager.load(podcastManager.findPodcastForUrl(loadingPodcastUrl));
        }

        @Override
        protected Void doInBackground(Void... params) {
            try {
                latch.await();
            } catch (InterruptedException e) {
                cancel(true);
            }

            return null;
        }

        @Override
        protected void onPostExecute(Void aVoid) {
            podcastManager.removeLoadPodcastListener(listener);
            result.sendResult(items);
        }
    };

    currentTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
 
开发者ID:salema,项目名称:Podcatcher-Deluxe-Android-Studio,代码行数:80,代码来源:PodcastBrowserService.java


示例20: onLoadRoot

import android.media.browse.MediaBrowser.MediaItem; //导入依赖的package包/类
private void onLoadRoot(final Result<List<MediaItem>> result) {
    this.currentTask = new PodcastBrowserAsyncTask() {

        @Override
        protected Void doInBackground(Void... params) {
            try {
                episodeManager.blockUntilEpisodeMetadataIsLoaded();
            } catch (InterruptedException e) {
                cancel(true);
            }

            // Add Downloads entry
            if (episodeManager.getDownloadsSize() > 0)
                items.add(new MediaItem(new MediaDescription.Builder()
                        .setMediaId(DOWNLOADS_ROOT)
                        .setTitle(getString(R.string.downloads))
                        .setSubtitle(getResources().getQuantityString(R.plurals.episodes,
                                episodeManager.getDownloadsSize(), episodeManager.getDownloadsSize()))
                        .build(), MediaItem.FLAG_BROWSABLE));

            // Build list of podcasts
            final List<Podcast> podcasts = podcastManager.getPodcastList();
            for (Podcast podcast : podcasts) {
                final int episodeCount = podcast.getEpisodeCount();
                final MediaDescription.Builder mediaDescription = new MediaDescription.Builder()
                        .setMediaId(podcast.getUrl())
                        .setTitle(podcast.getName())
                        .setSubtitle(episodeCount > 0 ? getResources()
                                .getQuantityString(R.plurals.episodes, episodeCount, episodeCount) : null);

                if (podcast.hasLogoUrl())
                    mediaDescription.setIconUri(Uri.parse(podcast.getLogoUrl()));

                items.add(new MediaItem(mediaDescription.build(), MediaItem.FLAG_BROWSABLE));
            }

            return null;
        }

        @Override
        protected void onPostExecute(Void aVoid) {
            result.sendResult(items);
        }
    };

    currentTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
 
开发者ID:salema,项目名称:Podcatcher-Deluxe-Android-Studio,代码行数:48,代码来源:PodcastBrowserService.java



注:本文中的android.media.browse.MediaBrowser.MediaItem类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ICompletionProposalExtension5类代码示例发布时间:2022-05-22
下一篇:
Java EntityMinecartEmpty类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap