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


Java MediaControlIntent类代码示例

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


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

示例1: onRouteSelected

import android.support.v7.media.MediaControlIntent; //导入依赖的package包/类
@Override
public void onRouteSelected(MediaRouter router, MediaRouter.RouteInfo route) {
    Log.d(TAG, "onRouteSelected: route=" + route);

    if (route.supportsControlCategory(
            MediaControlIntent.CATEGORY_REMOTE_PLAYBACK)){
        // Stop local playback (if necessary)
        // ...

        // Save the new route
        mRoute = route;

        // Attach a new playback client
        mRemotePlaybackClient = new RemotePlaybackClient(getBaseContext(), mRoute);


        // Start remote playback (if necessary)
        // ...
    }
}
 
开发者ID:tgbMedia,项目名称:Android-app,代码行数:21,代码来源:VideoPlayerActivity.java

示例2: onRouteUnselected

import android.support.v7.media.MediaControlIntent; //导入依赖的package包/类
@Override
public void onRouteUnselected(MediaRouter router, MediaRouter.RouteInfo route, int reason) {
    Log.d(TAG, "onRouteUnselected: route=" + route);

    if (route.supportsControlCategory(
            MediaControlIntent.CATEGORY_REMOTE_PLAYBACK)){

        // Changed route: tear down previous client
        if (mRoute != null && mRemotePlaybackClient != null) {
            mRemotePlaybackClient.release();
            mRemotePlaybackClient = null;
        }

        // Save the new route
        mRoute = route;

        if (reason != MediaRouter.UNSELECT_REASON_ROUTE_CHANGED) {
            // Resume local playback  (if necessary)
            // ...
        }
    }
}
 
开发者ID:tgbMedia,项目名称:Android-app,代码行数:23,代码来源:VideoPlayerActivity.java

示例3: startSession

import android.support.v7.media.MediaControlIntent; //导入依赖的package包/类
/**
 * Send a start session intent.
 *
 * @param relaunch Whether we should relaunch the cast application.
 * @param resultBundleHandler BundleHandler to handle reply.
 */
private void startSession(boolean relaunch, String sessionId,
        ResultBundleHandler resultBundleHandler) {
    Intent intent = new Intent(MediaControlIntent.ACTION_START_SESSION);
    intent.addCategory(MediaControlIntent.CATEGORY_REMOTE_PLAYBACK);

    intent.putExtra(CastMediaControlIntent.EXTRA_CAST_STOP_APPLICATION_WHEN_SESSION_ENDS, true);
    intent.putExtra(MediaControlIntent.EXTRA_SESSION_STATUS_UPDATE_RECEIVER,
            mSessionStatusUpdateIntent);
    intent.putExtra(CastMediaControlIntent.EXTRA_CAST_APPLICATION_ID, getCastReceiverId());
    intent.putExtra(CastMediaControlIntent.EXTRA_CAST_RELAUNCH_APPLICATION, relaunch);
    if (sessionId != null) intent.putExtra(MediaControlIntent.EXTRA_SESSION_ID, sessionId);

    addIntentExtraForDebugLogging(intent);
    sendIntentToRoute(intent, resultBundleHandler);
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:22,代码来源:DefaultMediaRouteController.java

示例4: startSession

import android.support.v7.media.MediaControlIntent; //导入依赖的package包/类
/**
 * Send a start session intent.
 *
 * @param relaunch Whether we should relaunch the cast application.
 * @param resultBundleHandler BundleHandler to handle reply.
 */
private void startSession(boolean relaunch, String sessionId,
        ResultBundleHandler resultBundleHandler) {
    Intent intent = new Intent(MediaControlIntent.ACTION_START_SESSION);
    intent.addCategory(MediaControlIntent.CATEGORY_REMOTE_PLAYBACK);

    intent.putExtra(CastMediaControlIntent.EXTRA_CAST_STOP_APPLICATION_WHEN_SESSION_ENDS, true);
    intent.putExtra(MediaControlIntent.EXTRA_SESSION_STATUS_UPDATE_RECEIVER,
            mSessionStatusUpdateIntent);
    intent.putExtra(CastMediaControlIntent.EXTRA_CAST_APPLICATION_ID, getCastReceiverId());
    intent.putExtra(CastMediaControlIntent.EXTRA_CAST_RELAUNCH_APPLICATION, relaunch);
    if (sessionId != null) intent.putExtra(MediaControlIntent.EXTRA_SESSION_ID, sessionId);

    if (mDebug) intent.putExtra(CastMediaControlIntent.EXTRA_DEBUG_LOGGING_ENABLED, true);

    sendIntentToRoute(intent, resultBundleHandler);
}
 
开发者ID:Smalinuxer,项目名称:Vafrinn,代码行数:23,代码来源:DefaultMediaRouteController.java

示例5: onResume

import android.support.v7.media.MediaControlIntent; //导入依赖的package包/类
@Override
public void onResume() {
    super.onResume();

    // The mediaRouter shouldn't exist here, but this is a nice safety check.
    if (mediaRouter != null) {
        return;
    }

    mediaRouter = MediaRouter.getInstance(getActivity());
    final MediaRouteSelector selectorBuilder = new MediaRouteSelector.Builder()
        .addControlCategory(MediaControlIntent.CATEGORY_LIVE_VIDEO)
        .addControlCategory(MediaControlIntent.CATEGORY_REMOTE_PLAYBACK)
        .addControlCategory(CastMediaControlIntent.categoryForCast(ChromeCast.MIRROR_RECEIVER_APP_ID))
        .build();
    mediaRouter.addCallback(selectorBuilder, callback, MediaRouter.CALLBACK_FLAG_REQUEST_DISCOVERY);
}
 
开发者ID:jrconlin,项目名称:mc_backup,代码行数:18,代码来源:MediaPlayerManager.java

示例6: broadcastDescriptor

import android.support.v7.media.MediaControlIntent; //导入依赖的package包/类
private void broadcastDescriptor() {
	// Create intents
	IntentFilter routeIntentFilter = new IntentFilter();
	routeIntentFilter.addCategory(CATEGORY_JUKEBOX_ROUTE);
	routeIntentFilter.addAction(MediaControlIntent.ACTION_START_SESSION);
	routeIntentFilter.addAction(MediaControlIntent.ACTION_GET_SESSION_STATUS);
	routeIntentFilter.addAction(MediaControlIntent.ACTION_END_SESSION);

	// Create route descriptor
	MediaRouteDescriptor.Builder routeBuilder = new MediaRouteDescriptor.Builder("Jukebox Route", "Subsonic Jukebox");
	routeBuilder.addControlFilter(routeIntentFilter)
			.setPlaybackStream(AudioManager.STREAM_MUSIC)
			.setPlaybackType(MediaRouter.RouteInfo.PLAYBACK_TYPE_REMOTE)
			.setDescription("Subsonic Jukebox")
			.setVolume(controller == null ? 5 : (int) (controller.getVolume() * 10))
			.setVolumeMax(MAX_VOLUME)
			.setVolumeHandling(MediaRouter.RouteInfo.PLAYBACK_VOLUME_VARIABLE);

	// Create descriptor
	MediaRouteProviderDescriptor.Builder providerBuilder = new MediaRouteProviderDescriptor.Builder();
	providerBuilder.addRoute(routeBuilder.build());
	setDescriptor(providerBuilder.build());
}
 
开发者ID:popeen,项目名称:Popeens-DSub,代码行数:24,代码来源:JukeboxRouteProvider.java

示例7: startSession

import android.support.v7.media.MediaControlIntent; //导入依赖的package包/类
private void startSession() {
    Intent intent = new Intent(MediaControlIntent.ACTION_START_SESSION);
    intent.addCategory(MediaControlIntent.CATEGORY_REMOTE_PLAYBACK);
    intent.putExtra(MediaControlIntent.EXTRA_SESSION_STATUS_UPDATE_RECEIVER,
            mSessionStatusUpdateIntent);
    intent.putExtra(CastMediaControlIntent.EXTRA_CAST_APPLICATION_ID,
            getReceiverApplicationId());
    intent.putExtra(CastMediaControlIntent.EXTRA_CAST_RELAUNCH_APPLICATION,
            getRelaunchApp());
    intent.putExtra(CastMediaControlIntent.EXTRA_DEBUG_LOGGING_ENABLED, true);
    if (getStopAppWhenEndingSession()) {
        intent.putExtra(CastMediaControlIntent.EXTRA_CAST_STOP_APPLICATION_WHEN_SESSION_ENDS,
                true);
    }
    sendIntentToRoute(intent, new ResultBundleHandler() {
        @Override
        public void handleResult(Bundle bundle) {
            mSessionId = bundle.getString(MediaControlIntent.EXTRA_SESSION_ID);
            Log.d(TAG, "Got a session ID of: " + mSessionId);
        }
    });
}
 
开发者ID:TerribleDev,项目名称:XamarinAdmobTutorial,代码行数:23,代码来源:MrpCastPlayerActivity.java

示例8: endSession

import android.support.v7.media.MediaControlIntent; //导入依赖的package包/类
private void endSession() {
    if (mSessionId == null) {
        return;
    }

    Intent intent = new Intent(MediaControlIntent.ACTION_END_SESSION);
    intent.addCategory(MediaControlIntent.CATEGORY_REMOTE_PLAYBACK);
    intent.putExtra(MediaControlIntent.EXTRA_SESSION_ID, mSessionId);
    sendIntentToRoute(intent, new ResultBundleHandler() {
        @Override
        public void handleResult(final Bundle bundle) {
            MediaSessionStatus status = MediaSessionStatus.fromBundle(
                    bundle.getBundle(MediaControlIntent.EXTRA_SESSION_STATUS));
            int sessionState = status.getSessionState();
            Log.d(TAG, "session state after ending session: " + sessionState);
            clearCurrentMediaItem();
        }
    });
    mSessionId = null;
}
 
开发者ID:TerribleDev,项目名称:XamarinAdmobTutorial,代码行数:21,代码来源:MrpCastPlayerActivity.java

示例9: handleRemove

import android.support.v7.media.MediaControlIntent; //导入依赖的package包/类
private boolean handleRemove(Intent intent, ControlRequestCallback callback) {
    String sid = intent.getStringExtra(MediaControlIntent.EXTRA_SESSION_ID);
    if (sid == null || !sid.equals(mSessionManager.getSessionId())) {
        return false;
    }

    String iid = intent.getStringExtra(MediaControlIntent.EXTRA_ITEM_ID);
    PlaylistItem item = mSessionManager.remove(iid);
    if (callback != null) {
        if (item != null) {
            Bundle result = new Bundle();
            result.putBundle(MediaControlIntent.EXTRA_ITEM_STATUS,
                    item.getStatus().asBundle());
            callback.onResult(result);
        } else {
            callback.onError("Failed to remove" +
                    ", sid=" + sid + ", iid=" + iid, null);
        }
    }
    return (item != null);
}
 
开发者ID:benhysell,项目名称:V.FlyoutTest,代码行数:22,代码来源:SampleMediaRouteProvider.java

示例10: handleSeek

import android.support.v7.media.MediaControlIntent; //导入依赖的package包/类
private boolean handleSeek(Intent intent, ControlRequestCallback callback) {
    String sid = intent.getStringExtra(MediaControlIntent.EXTRA_SESSION_ID);
    if (sid == null || !sid.equals(mSessionManager.getSessionId())) {
        return false;
    }

    String iid = intent.getStringExtra(MediaControlIntent.EXTRA_ITEM_ID);
    long pos = intent.getLongExtra(MediaControlIntent.EXTRA_ITEM_CONTENT_POSITION, 0);
    Log.d(TAG, mRouteId + ": Received seek request, pos=" + pos);
    PlaylistItem item = mSessionManager.seek(iid, pos);
    if (callback != null) {
        if (item != null) {
            Bundle result = new Bundle();
            result.putBundle(MediaControlIntent.EXTRA_ITEM_STATUS,
                    item.getStatus().asBundle());
            callback.onResult(result);
        } else {
            callback.onError("Failed to seek" +
                    ", sid=" + sid + ", iid=" + iid + ", pos=" + pos, null);
        }
    }
    return (item != null);
}
 
开发者ID:benhysell,项目名称:V.FlyoutTest,代码行数:24,代码来源:SampleMediaRouteProvider.java

示例11: handleGetStatus

import android.support.v7.media.MediaControlIntent; //导入依赖的package包/类
private boolean handleGetStatus(Intent intent, ControlRequestCallback callback) {
    String sid = intent.getStringExtra(MediaControlIntent.EXTRA_SESSION_ID);
    String iid = intent.getStringExtra(MediaControlIntent.EXTRA_ITEM_ID);
    Log.d(TAG, mRouteId + ": Received getStatus request, sid=" + sid + ", iid=" + iid);
    PlaylistItem item = mSessionManager.getStatus(iid);
    if (callback != null) {
        if (item != null) {
            Bundle result = new Bundle();
            result.putBundle(MediaControlIntent.EXTRA_ITEM_STATUS,
                    item.getStatus().asBundle());
            callback.onResult(result);
        } else {
            callback.onError("Failed to get status" +
                    ", sid=" + sid + ", iid=" + iid, null);
        }
    }
    return (item != null);
}
 
开发者ID:benhysell,项目名称:V.FlyoutTest,代码行数:19,代码来源:SampleMediaRouteProvider.java

示例12: handleStartSession

import android.support.v7.media.MediaControlIntent; //导入依赖的package包/类
private boolean handleStartSession(Intent intent, ControlRequestCallback callback) {
    String sid = mSessionManager.startSession();
    Log.d(TAG, "StartSession returns sessionId "+sid);
    if (callback != null) {
        if (sid != null) {
            Bundle result = new Bundle();
            result.putString(MediaControlIntent.EXTRA_SESSION_ID, sid);
            result.putBundle(MediaControlIntent.EXTRA_SESSION_STATUS,
                    mSessionManager.getSessionStatus(sid).asBundle());
            callback.onResult(result);
            mSessionReceiver = (PendingIntent)intent.getParcelableExtra(
                    MediaControlIntent.EXTRA_SESSION_STATUS_UPDATE_RECEIVER);
            handleSessionStatusChange(sid);
        } else {
            callback.onError("Failed to start session.", null);
        }
    }
    return (sid != null);
}
 
开发者ID:benhysell,项目名称:V.FlyoutTest,代码行数:20,代码来源:SampleMediaRouteProvider.java

示例13: handleGetSessionStatus

import android.support.v7.media.MediaControlIntent; //导入依赖的package包/类
private boolean handleGetSessionStatus(Intent intent, ControlRequestCallback callback) {
    String sid = intent.getStringExtra(MediaControlIntent.EXTRA_SESSION_ID);

    MediaSessionStatus sessionStatus = mSessionManager.getSessionStatus(sid);
    if (callback != null) {
        if (sessionStatus != null) {
            Bundle result = new Bundle();
            result.putBundle(MediaControlIntent.EXTRA_SESSION_STATUS,
                    mSessionManager.getSessionStatus(sid).asBundle());
            callback.onResult(result);
        } else {
            callback.onError("Failed to get session status, sid=" + sid, null);
        }
    }
    return (sessionStatus != null);
}
 
开发者ID:benhysell,项目名称:V.FlyoutTest,代码行数:17,代码来源:SampleMediaRouteProvider.java

示例14: handleEndSession

import android.support.v7.media.MediaControlIntent; //导入依赖的package包/类
private boolean handleEndSession(Intent intent, ControlRequestCallback callback) {
    String sid = intent.getStringExtra(MediaControlIntent.EXTRA_SESSION_ID);
    boolean success = (sid != null) && sid.equals(mSessionManager.getSessionId())
            && mSessionManager.endSession();
    if (callback != null) {
        if (success) {
            Bundle result = new Bundle();
            MediaSessionStatus sessionStatus = new MediaSessionStatus.Builder(
                    MediaSessionStatus.SESSION_STATE_ENDED).build();
            result.putBundle(MediaControlIntent.EXTRA_SESSION_STATUS, sessionStatus.asBundle());
            callback.onResult(result);
            handleSessionStatusChange(sid);
            mSessionReceiver = null;
        } else {
            callback.onError("Failed to end session, sid=" + sid, null);
        }
    }
    return success;
}
 
开发者ID:benhysell,项目名称:V.FlyoutTest,代码行数:20,代码来源:SampleMediaRouteProvider.java

示例15: handleStatusChange

import android.support.v7.media.MediaControlIntent; //导入依赖的package包/类
private void handleStatusChange(PlaylistItem item) {
    if (item == null) {
        item = mSessionManager.getCurrentItem();
    }
    if (item != null) {
        PendingIntent receiver = item.getUpdateReceiver();
        if (receiver != null) {
            Intent intent = new Intent();
            intent.putExtra(MediaControlIntent.EXTRA_SESSION_ID, item.getSessionId());
            intent.putExtra(MediaControlIntent.EXTRA_ITEM_ID, item.getItemId());
            intent.putExtra(MediaControlIntent.EXTRA_ITEM_STATUS,
                    item.getStatus().asBundle());
            try {
                receiver.send(getContext(), 0, intent);
                Log.d(TAG, mRouteId + ": Sending status update from provider");
            } catch (PendingIntent.CanceledException e) {
                Log.d(TAG, mRouteId + ": Failed to send status update!");
            }
        }
    }
}
 
开发者ID:benhysell,项目名称:V.FlyoutTest,代码行数:22,代码来源:SampleMediaRouteProvider.java


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