Unable to play live stream on chromecast from android sender app

拈花ヽ惹草 提交于 2019-12-12 21:15:39

问题


I am using CastCompanionLibrary-android in my app and following CastVideos-android to play live streams on chromecast. Now the streaming of video works fine on my local player but when it comes to cast that video, it wont play. Rather it just show me my registered receiver app name and on sender app the VideoCastControllerActivity opens with only a loader which wont end. I have registered both my receiver app (Styled Media Receiver) and the device on Google chrome cast console. Also, I tried to debug the receiver app, it show nothing on the debugger or in console.

Here is the code snippet of my sender app:

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);
}

this function is called on the player activity's OnCreate() function.

The Listener (I'm getting true value for wasLaunched param)

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

}

And in the onCreate() function of Application:

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);

can you please tell me where i am going wrong? Thanks.


回答1:


The content type might be an issue. Try properly setting it to something like video/mp4 if that's the case.



来源:https://stackoverflow.com/questions/34887826/unable-to-play-live-stream-on-chromecast-from-android-sender-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!