使用MediaRouterButton连接chromecast时出错 - CastCompanionLib

时间:2015-06-08 04:05:53

标签: android chromecast

D/ccl_CastMediaRouterCal﹕ [v2.1] onRouteSelected: mSelectedDevice=Android Cast
D/ccl_BaseCastManager﹕ [v2.1] onConnected() reached with prior suspension: false
D/ccl_BaseCastManager﹕ [v2.1] launchApp() is called
D/ccl_BaseCastManager﹕ [v2.1] Launching app
D/ccl_VideoCastManager﹕ [v2.1] onVolumeChanged() reached
D/ccl_VideoCastManager﹕ [v2.1] onApplicationStatusChanged() reached:
D/ccl_VideoCastManager﹕ [v2.1] onApplicationStatusChanged() reached: null

E/ccl_VideoCastManager﹕ [v2.1] Failed to update the progress tracker due to network issues
com.google.android.libraries.cast.companionlibrary.cast.exceptions.NoConnectionException
        at com.google.android.libraries.cast.companionlibrary.cast.VideoCastManager.checkRemoteMediaPlayerAvailable(VideoCastManager.java:544)
        at com.google.android.libraries.cast.companionlibrary.cast.VideoCastManager.getMediaDuration(VideoCastManager.java:758)
        at com.google.android.libraries.cast.companionlibrary.cast.VideoCastManager$UpdateProgressTask.run(VideoCastManager.java:2841)
        at java.util.Timer$TimerImpl.run(Timer.java:284)

D/ccl_BaseCastManager﹕ [v2.1] launchApplication() -> success result

D/ccl_VideoCastNotificat﹕ [v2.1] onStartCommand

D/ccl_VideoCastNotificat﹕ [v2.1] onStartCommand(): Action: ACTION_VISIBILITY false

D/ccl_VideoCastManager﹕ [v2.1] RemoteMediaPlayer::onStatusUpdated() is reached

D/ccl_VideoCastManager﹕ [v2.1] onRemoteMediaPlayerStatusUpdated() reached

D/ccl_VideoCastManager﹕ [v2.1] mApiClient or mRemoteMediaPlayer is null, so will not proceed

D/ccl_VideoCastManager﹕ [v2.1] RemoteMediaPlayer::onMetadataUpdated() is reached

D/ccl_VideoCastManager﹕ [v2.1] onRemoteMediaPlayerMetadataUpdated() reached

D/ccl_VideoCastManager﹕ [v2.1] RemoteMediaPlayer::onQueueStatusUpdated() is reached
D/ccl_VideoCastManager﹕ [v2.1] onQueueUpdated() reached

D/ccl_VideoCastManager﹕ [v2.1] Queue Items size: 0, Item: null, Repeat Mode: 0, Shuffle: false

D/ccl_VideoCastManager﹕ [v2.1] onRemoteMediaPlayerQueueStatusUpdated() reached

D/ccl_VideoCastManager﹕ [v2.1] Queue Items size: 0, Item: null, Repeat Mode: 0, Shuffle: false

D/ccl_VideoCastManager﹕[v2.1] [preload] RemoteMediaPlayer:: onPreloadStatusUpdated() is reached

D/ccl_VideoCastManager﹕ [v2.1] onRemoteMediaPreloadStatusUpdated() null

我使用 CastCompanionLibrary 投放媒体。连接到Chromecast时出错。我仍然投射媒体,但是当点击对话框上的项目连接到chromecast或minicontrol时,我无法恢复投射屏幕。谢谢帮助!

这是我的代码:

的应用。

@Override
public void onCreate() {
    super.onCreate();
    mContext = getApplicationContext();
    ...
    initCast();
    ....
}

private void initCast() {
    VideoCastManager.
            initialize(this, APPLICATION_ID, null, "urn:x-cast:demo.cast").
            setVolumeStep(VOLUME_INCREMENT).
            enableFeatures(VideoCastManager.FEATURE_NOTIFICATION |
                    VideoCastManager.FEATURE_LOCKSCREEN |
                    VideoCastManager.FEATURE_WIFI_RECONNECT |
                    VideoCastManager.FEATURE_CAPTIONS_PREFERENCE |
                    VideoCastManager.FEATURE_DEBUGGING);
}

MainActivity

@Override
public void onCreate() {
    super.onCreate();
    ....
    initCast();
    ....
}

private void initCast(){
    mMediaRouteButton=(MediaRouteButton)findViewById(R.id.btnMainChomeCast);
    VideoCastManager.getInstance().addMediaRouterButton(mMediaRouteButton);
    videoCastConsumer=new VideoCastConsumerImpl(){
        @Override
        public void onCastAvailabilityChanged(boolean castPresent) {
            super.onCastAvailabilityChanged(castPresent);
        }

        @Override
        public void onCastDeviceDetected(MediaRouter.RouteInfo info) {
            super.onCastDeviceDetected(info);
        }

        @Override
        public void onConnected() {
            super.onConnected();
        }

        @Override
        public void onConnectionSuspended(int cause) {
            super.onConnectionSuspended(cause);
        }
    };

    if(VideoCastManager.getInstance().isAnyRouteAvailable()){
        mMediaRouteButton.setVisibility(View.VISIBLE);
    }
}
 @Override
protected void onResume() {

    mCastManager = VideoCastManager.getInstance();
    mMiniController.setOnMiniControllerChangedListener(mCastManager);
    mCastManager.addVideoCastConsumer(videoCastConsumer);
    mCastManager.incrementUiCounter();
    super.onResume();
}

@Override
protected void onPause() {
    super.onPause();
    mCastManager.removeVideoCastConsumer(mCastConsumer);
    mMiniController.removeOnMiniControllerChangedListener(mCastManager);
    mCastManager.decrementUiCounter();
}

点击minicontroller时,这是完整的日志:

    D/ccl_BaseCastManager﹕ [v2.1] Successfully removed the existing BaseCastConsumer listener .MainActivity$1@28787a01
    D/ccl_BaseCastManager﹕ [v2.1] UI is no longer visible

    D/ccl_VideoCastManager﹕ [v2.1] Successfully added the new MiniController com.google.android.libraries.cast.companionlibrary.widgets.MiniController{10a38a34 V.E..... ......I. 0,0-0,0 #7f0e012b app:id/miniController1}
    D/ccl_VideoCastControlle﹕ [v2.1] setPlaybackStatus(): state = 4
     D/ccl_VideoCastManager﹕ [v2.1] loadMedia
    D/ccl_VideoCastControlle﹕ [v2.1] Stopped TrickPlay Timer
    D/ccl_VideoCastControlle﹕ [v2.1] Restarted TrickPlay Timer
    D/ccl_BaseCastManager﹕ [v2.1] Successfully added the new BaseCastConsumer listener com.google.android.libraries.cast.companionlibrary.cast.player.VideoCastControllerFragment$MyCastConsumer@2a352559
    D/ccl_VideoCastManager﹕ [v2.1] Successfully added the new CastConsumer listener com.google.android.libraries.cast.companionlibrary.cast.player.VideoCastControllerFragment$MyCastConsumer@2a352559
    D/ccl_BaseCastManager﹕ [v2.1] UI is visible
    D/ccl_VideoCastControlle﹕ [v2.1] updatePlayerStatus(), state: 2
    D/ccl_VideoCastControlle﹕ [v2.1] setPlaybackStatus(): state = 2
    D/ccl_VideoCastManager﹕ [v2.1] RemoteMediaPlayer::onStatusUpdated() is reached
    D/ccl_VideoCastManager﹕ [v2.1] onRemoteMediaPlayerStatusUpdated() reached
    D/ccl_VideoCastManager﹕ [v2.1] onQueueUpdated() reached
    D/ccl_VideoCastManager﹕ [v2.1] Queue Items size: 0, Item: null, Repeat Mode: 0, Shuffle: false
    D/ccl_VideoCastManager﹕ [v2.1] onRemoteMediaPlayerStatusUpdated(): Player status = idle
    D/ccl_VideoCastManager﹕ [v2.1] removeRemoteControlClient()
    D/ccl_BaseCastManager﹕ [v2.1] stopReconnectionService()
    D/ccl_VideoCastManager﹕ [v2.1] updateMiniControllersVisibility() reached with visibility: false
    D/ccl_VideoCastNotificat﹕ [v2.1] onRemoteMediaPlayerStatusUpdated() reached with status: 1
    D/ccl_VideoCastControlle﹕ [v2.1] updatePlayerStatus(), state: 1
    D/ccl_VideoCastManager﹕ [v2.1] RemoteMediaPlayer::onQueueStatusUpdated() is reached
    D/ccl_VideoCastManager﹕ [v2.1] onQueueUpdated() reached
    D/ccl_VideoCastManager﹕ [v2.1] Queue Items size: 0, Item: null, Repeat Mode: 0, Shuffle: false
    D/ccl_VideoCastManager﹕ [v2.1] onRemoteMediaPlayerQueueStatusUpdated() reached
    D/ccl_VideoCastManager﹕ [v2.1] Queue Items size: 0, Item: null, Repeat Mode: 0, Shuffle: false
    D/ccl_ReconnectionService﹕ [v2.1] onDestroy()
    D/ccl_BaseCastManager﹕ [v2.1] Successfully removed the existing BaseCastConsumer listener com.google.android.libraries.cast.companionlibrary.notification.VideoCastNotificationService$1@1a8b521c
    D/ccl_BaseCastManager﹕ [v2.1] Successfully removed the existing BaseCastConsumer listener com.google.android.libraries.cast.companionlibrary.cast.player.VideoCastControllerFragment$MyCastConsumer@2a352559
    D/ccl_BaseCastManager﹕ [v2.1] UI is no longer visible
    D/MainActivity﹕ onresume
    D/ccl_BaseCastManager﹕ [v2.1] Successfully added the new BaseCastConsumer listener .MainActivity$1@28787a01
    D/ccl_VideoCastManager﹕ [v2.1] Successfully added the new CastConsumer listener .MainActivity$1@28787a01
    D/ccl_BaseCastManager﹕ [v2.1] UI is visible
    D/ccl_VideoCastControlle﹕ [v2.1] onDestroy()
    D/ccl_VideoCastControlle﹕ [v2.1] Stopped TrickPlay Timer
    D/ccl_BaseCastManager﹕ [v2.1] onUiVisibilityChanged() addCallback called
    D/ccl_VideoCastManager﹕ [v2.1] RemoteMediaPlayer::onStatusUpdated() is reached
    D/ccl_VideoCastManager﹕ [v2.1] onRemoteMediaPlayerStatusUpdated() reached
    D/ccl_VideoCastManager﹕ [v2.1] onQueueUpdated() reached
    D/ccl_VideoCastManager﹕ [v2.1] Queue Items size: 1, Item: com.google.android.gms.cast.MediaQueueItem@4d8b6426, Repeat Mode: 0, Shuffle: false
    D/ccl_VideoCastManager﹕ [v2.1] [queue] Queue Item is: { content id }
    D/ccl_VideoCastManager﹕ [v2.1] onRemoteMediaPlayerStatusUpdated(): Player status = buffering
    D/ccl_VideoCastManager﹕ [v2.1] updateMiniControllersVisibility() reached with visibility: true
    D/ccl_VideoCastManager﹕ [v2.1] RemoteMediaPlayer::onStatusUpdated() is reached
    D/ccl_VideoCastManager﹕ [v2.1] onRemoteMediaPlayerStatusUpdated() reached
    D/ccl_VideoCastManager﹕ [v2.1] onQueueUpdated() reached
    D/ccl_VideoCastManager﹕ [v2.1] Queue Items size: 1, Item: com.google.android.gms.cast.MediaQueueItem@4d8b6426, Repeat Mode: 0, Shuffle: false
    D/ccl_VideoCastManager﹕ [v2.1] [queue] Queue Item is: {  content item}
    D/ccl_VideoCastManager﹕ [v2.1] onRemoteMediaPlayerStatusUpdated(): Player status = buffering
    D/ccl_VideoCastManager﹕ [v2.1] updateMiniControllersVisibility() reached with visibility: true
    D/ccl_VideoCastManager﹕ [v2.1] RemoteMediaPlayer::onMetadataUpdated() is reached
    D/ccl_VideoCastManager﹕ [v2.1] onRemoteMediaPlayerMetadataUpdated() reached
    D/ccl_VideoCastManager﹕ [v2.1] RemoteMediaPlayer::onQueueStatusUpdated() is reached
    D/ccl_VideoCastManager﹕ [v2.1] onQueueUpdated() reached
    D/ccl_VideoCastManager﹕ [v2.1] Queue Items size: 1, Item: com.google.android.gms.cast.MediaQueueItem@4d8b6426, Repeat Mode: 0, Shuffle: false
    D/ccl_VideoCastManager﹕ [v2.1] onRemoteMediaPlayerQueueStatusUpdated() reached
    D/ccl_VideoCastManager﹕ [v2.1] Queue Items size: 1, Item: com.google.android.gms.cast.MediaQueueItem@4d8b6426, Repeat Mode: 0, Shuffle: false
    D/ccl_VideoCastManager﹕ [v2.1] [preload] RemoteMediaPlayer::onPreloadStatusUpdated() is reached
    D/ccl_VideoCastManager﹕ [v2.1] onRemoteMediaPreloadStatusUpdated() null
    D/ccl_VideoCastManager﹕ [v2.1] RemoteMediaPlayer::onStatusUpdated() is reached
    D/ccl_VideoCastManager﹕ [v2.1] onRemoteMediaPlayerStatusUpdated() reached
    D/ccl_VideoCastManager﹕ [v2.1] onQueueUpdated() reached
    D/ccl_VideoCastManager﹕ [v2.1] Queue Items size: 1, Item: com.google.android.gms.cast.MediaQueueItem@4d8b6426, Repeat Mode: 0, Shuffle: false
    D/ccl_VideoCastManager﹕ [v2.1] [queue] Queue Item is: { content item }
    D/ccl_VideoCastManager﹕ [v2.1] onRemoteMediaPlayerStatusUpdated(): Player status = playing
    D/ccl_VideoCastManager﹕ [v2.1] setUpRemoteControl() was called
    D/ccl_BaseCastManager﹕ [v2.1] startReconnectionService() for media length lef = 0
    D/ccl_VideoCastManager﹕ [v2.1] startNotificationService()
    D/ccl_VideoCastManager﹕ [v2.1] updateMiniControllersVisibility() reached with visibility: true
     D/ccl_ReconnectionService﹕ [v2.1] onCreate() is called
    D/ccl_ReconnectionService﹕ [v2.1] onStartCommand() is called
     D/ccl_ReconnectionService﹕ [v2.1] setUpEndTimer(): setting up a timer for the end of current media
    D/ccl_BaseCastManager﹕ [v2.1] Successfully added the new BaseCastConsumer listener com.google.android.libraries.cast.companionlibrary.notification.VideoCastNotificationService$1@1d03f6e2
    D/ccl_VideoCastManager﹕ [v2.1] Successfully added the new CastConsumer listener com.google.android.libraries.cast.companionlibrary.notification.VideoCastNotificationService$1@1d03f6e2
    D/ccl_VideoCastNotificat﹕ [v2.1] onStartCommand
    D/ccl_VideoCastNotificat﹕ [v2.1] onStartCommand(): Action: ACTION_VISIBILITY false
    D/ccl_ReconnectionService﹕ [v2.1] WIFI connectivity changed to enabled
    D/ccl_ReconnectionService﹕ [v2.1] onDestroy()
    D/ccl_VideoCastManager﹕ [v2.1] RemoteMediaPlayer::onStatusUpdated() is reached
    D/ccl_VideoCastManager﹕ [v2.1] onRemoteMediaPlayerStatusUpdated() reached
    D/ccl_VideoCastManager﹕ [v2.1] onQueueUpdated() reached
    D/ccl_VideoCastManager﹕ [v2.1] Queue Items size: 0, Item: null, Repeat Mode: 0, Shuffle: false
    D/ccl_VideoCastManager﹕ [v2.1] onRemoteMediaPlayerStatusUpdated(): Player status = idle
    D/ccl_VideoCastManager﹕ [v2.1] removeRemoteControlClient()
    D/ccl_BaseCastManager﹕ [v2.1] stopReconnectionService()
    D/ccl_VideoCastManager﹕ [v2.1] updateMiniControllersVisibility() reached with visibility: false
D/ccl_VideoCastNotificat﹕ [v2.1] onRemoteMediaPlayerStatusUpdated() reached with status: 1
D/ccl_VideoCastManager﹕ [v2.1] RemoteMediaPlayer::onQueueStatusUpdated() is reached
    D/ccl_VideoCastManager﹕ [v2.1] onQueueUpdated() reached
    D/ccl_VideoCastManager﹕ [v2.1] Queue Items size: 0, Item: null, Repeat Mode: 0, Shuffle: false
    D/ccl_VideoCastManager﹕ [v2.1] onRemoteMediaPlayerQueueStatusUpdated() reached
    D/ccl_VideoCastManager﹕ [v2.1] Queue Items size: 0, Item: null, Repeat Mode: 0, Shuffle: false
    D/ccl_BaseCastManager﹕ [v2.1] Successfully removed the existing BaseCastConsumer listener com.google.android.libraries.cast.companionlibrary.notification.VideoCastNotificationService$1@1d03f6e2

0 个答案:

没有答案