无法在Android发送者应用

时间:2016-01-19 22:04:15

标签: android chromecast google-cast http-live-streaming

我在我的应用中使用CastCompanionLibrary-android并跟随CastVideos-android在chromecast上播放实时流。现在,视频流在我的本地播放器上运行良好,但是当它投射该视频时,它不会播放。相反,它只是向我显示我的注册接收器应用程序名称和发送方应用程序VideoCastControllerActivity打开时只有一个不会结束的加载程序。 我在Google Chrome演播控制台上注册了我的接收器应用程序(Styled Media Receiver)和设备。此外,我尝试调试接收器应用程序,它在调试器或控制台中没有显示任何内容。

以下是我的发件人应用的代码段:

private void initMediaRouter() {
    BaseCastManager.checkGooglePlayServices(this);
    mCastManager = VideoCastManager.getInstance();
    MediaMetadata mediaMetadata = new MediaMetadata(MediaMetadata.MEDIA_TYPE_MOVIE); //also tried MediaMetadata.MEDIA_TYPE_GENERIC
    mediaMetadata.putString(MediaMetadata.KEY_TITLE, channel.getChannelName());
    mediaMetadata.putString(MediaMetadata.KEY_SUBTITLE, channel.getCatName());
    info = new MediaInfo.Builder(channel.getHttpStream())
            .setMetadata(mediaMetadata)
            .setContentType("Video/*")
            .setStreamType(MediaInfo.STREAM_TYPE_LIVE)
            .build();
    castConsumer = new CastConsumer();

    mCastManager.addVideoCastConsumer(castConsumer);
}

在玩家活动的OnCreate()函数中调用此函数。

听众(我为wasLaunched param获得了真正的价值)

private class CastConsumer extends VideoCastConsumerImpl {
    @Override
    public void onApplicationConnected(ApplicationMetadata appMetadata, String sessionId, boolean wasLaunched) {
        mCastManager.startVideoCastControllerActivity(PlayerActivity.this, info, 0, true);
    }

}

在Application的onCreate()函数中:

String applicationId = getString(R.string.cast_app_id);
    CastConfiguration options = new CastConfiguration.Builder(applicationId)
            .enableAutoReconnect()
            .enableCaptionManagement()
            .enableDebug()
            .enableLockScreen()
            .enableNotification()
            .enableWifiReconnection()
            .setCastControllerImmersive(true)
            .setLaunchOptions(false, Locale.getDefault())
            .addNotificationAction(CastConfiguration.NOTIFICATION_ACTION_PLAY_PAUSE, true)
            .addNotificationAction(CastConfiguration.NOTIFICATION_ACTION_DISCONNECT, true)
            .build();
    VideoCastManager.initialize(this, options);
你可以告诉我哪里出错了吗?感谢。

1 个答案:

答案 0 :(得分:0)

内容类型可能是个问题。如果情况如此,请尝试将其正确设置为video/mp4