当前位置: 首页>>代码示例>>Java>>正文


Java MediaControlIntent.ACTION_PLAY属性代码示例

本文整理汇总了Java中android.support.v7.media.MediaControlIntent.ACTION_PLAY属性的典型用法代码示例。如果您正苦于以下问题:Java MediaControlIntent.ACTION_PLAY属性的具体用法?Java MediaControlIntent.ACTION_PLAY怎么用?Java MediaControlIntent.ACTION_PLAY使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在android.support.v7.media.MediaControlIntent的用法示例。


在下文中一共展示了MediaControlIntent.ACTION_PLAY属性的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: play

/**
 * Sets current track in renderer to specified item in playlist, then
 * starts playback.
 */
public void play(int trackNumber) {
	if (trackNumber < 0 || trackNumber >= mPlaylist.size())
		return;

	mCurrentTrack = trackNumber;
	Item track = mPlaylist.get(trackNumber);
	DIDLParser parser = new DIDLParser();
	DIDLContent didl = new DIDLContent();
	didl.addItem(track);
	String metadata = "";
	try	{
		metadata = parser.generate(didl, true);
	}
	catch (Exception e)	{
		Log.w(TAG, "Metadata generation failed", e);
	}

	Intent intent = new Intent(MediaControlIntent.ACTION_PLAY);
	intent.addCategory(MediaControlIntent.CATEGORY_REMOTE_PLAYBACK);
	intent.setData(Uri.parse(track.getFirstResource().getValue()));
	intent.putExtra(MediaControlIntent.EXTRA_ITEM_METADATA, metadata);

	mMediaRouter.getSelectedRoute().sendControlRequest(intent,
			new ControlRequestCallback() {
		@Override
		public void onResult(Bundle data) {
			mSessionId = data.getString(MediaControlIntent.EXTRA_SESSION_ID);
			mItemId = data.getString(MediaControlIntent.EXTRA_ITEM_ID);
			mPollingStatus = true;

			new CreateNotificationTask().execute(mPlaylist.get(mCurrentTrack)
					.getFirstPropertyValue(DIDLObject.Property.UPNP.ALBUM_ART_URI.class));

			if (mRouterFragment.get() != null) {
				mRouterFragment.get().scrollToCurrent();
			}
		}
	});
}
 
开发者ID:Nutomic,项目名称:controldlna,代码行数:43,代码来源:MediaRouterPlayService.java

示例2: makePlayIntent

private Intent makePlayIntent(MediaItem item) {
    Intent intent = new Intent(MediaControlIntent.ACTION_PLAY);
    intent.addCategory(MediaControlIntent.CATEGORY_REMOTE_PLAYBACK);
    intent.setDataAndType(item.mUri, "video/mp4");
    return intent;
}
 
开发者ID:reknih,项目名称:informant-droid,代码行数:6,代码来源:SampleMediaRouterActivity.java

示例3: onPlayMedia

@Override
protected void onPlayMedia(final MediaInfo media) {
    if (media == null) {
        return;
    }
    MediaMetadata metadata = media.getMetadata();
    Log.d(TAG, "Casting " + metadata.getString(MediaMetadata.KEY_TITLE) + " ("
            + media.getContentType() + ")");

    Intent intent = new Intent(MediaControlIntent.ACTION_PLAY);
    intent.addCategory(MediaControlIntent.CATEGORY_REMOTE_PLAYBACK);
    intent.setDataAndType(Uri.parse(media.getContentId()), media.getContentType());
    intent.putExtra(MediaControlIntent.EXTRA_SESSION_ID, mSessionId);
    intent.putExtra(MediaControlIntent.EXTRA_ITEM_STATUS_UPDATE_RECEIVER,
            mMediaStatusUpdateIntent);

    Bundle metadataBundle = new Bundle();

    String title = metadata.getString(MediaMetadata.KEY_TITLE);
    if (!TextUtils.isEmpty(title)) {
        metadataBundle.putString(MediaItemMetadata.KEY_TITLE, title);
    }

    List<WebImage> images = metadata.getImages();
    String artist = metadata.getString(MediaMetadata.KEY_ARTIST);
    if (artist == null) {
        artist = metadata.getString(MediaMetadata.KEY_STUDIO);
    }
    if (!TextUtils.isEmpty(artist)) {
        metadataBundle.putString(MediaItemMetadata.KEY_ARTIST, artist);
    }

    if ((images != null) && !images.isEmpty()) {
        Uri imageUrl = images.get(0).getUrl();
        if (imageUrl != null) {
            metadataBundle.putString(MediaItemMetadata.KEY_ARTWORK_URI, imageUrl.toString());
        }
    }

    intent.putExtra(MediaControlIntent.EXTRA_ITEM_METADATA, metadataBundle);

    sendIntentToRoute(intent, mMediaResultHandler);
}
 
开发者ID:TerribleDev,项目名称:XamarinAdmobTutorial,代码行数:43,代码来源:MrpCastPlayerActivity.java


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