Android Chromecast Companion Library - set TextTrackStyle error 2103

你。 提交于 2020-01-07 03:51:08

问题


I'm using CastCompanionLibrary-Android and I'm trying to set custom TextTrackStyle for the captions.

I'm setting this TexTextStyle to the MediaInfo while I'm creating it:

                // set CC style
                TextTrackStyle textTrackStyle = new TextTrackStyle();
                textTrackStyle.setBackgroundColor(Color.parseColor("#FFFFFF"));
                textTrackStyle.setForegroundColor(ContextCompat.getColor(mContext, R.color.blue));

                MediaInfo mediaInfo = new MediaInfo.Builder(url)
                        .setStreamDuration(movieVideoItem.getDuration())
                        .setStreamType(MediaInfo.STREAM_TYPE_NONE)
                        .setContentType(type)
                        .setMetadata(mediaMetadata)
                        .setMediaTracks(tracks)
                        .setCustomData(customData)
                        .setTextTrackStyle(textTrackStyle)
                        .build();

But there is no visible result on the Chromecast side. I also tried to change VideoCastManager method setTextTrackStyle:

 public void setTextTrackStyle(TextTrackStyle style) {
    // CUSTOM TEXT TRACK STYLE HERE
    TextTrackStyle textTrackStyle = new TextTrackStyle();
    textTrackStyle.setBackgroundColor(Color.parseColor("#FF0000"));
    textTrackStyle.setForegroundColor(Color.parseColor("#0000FF"));

    mRemoteMediaPlayer.setTextTrackStyle(mApiClient, textTrackStyle)
            .setResultCallback(new ResultCallback<MediaChannelResult>() {
                @Override
                public void onResult(MediaChannelResult result) {
                    if (!result.getStatus().isSuccess()) {
                        onFailed(R.string.ccl_failed_to_set_track_style,
                                result.getStatus().getStatusCode());
                    }
                }
            });
    for (VideoCastConsumer consumer : mVideoConsumers) {
        try {
            consumer.onTextTrackStyleChanged(textTrackStyle);
        } catch (Exception e) {
            LOGE(TAG, "onTextTrackStyleChanged(): Failed to inform " + consumer, e);
        }
    }
}

But in this ResultCallback I'm getting error code 2103 which I found here: developers google

public static final int REPLACED
Status code indicating that the request's progress is no longer being tracked because another request of the same type has been made before the first request completed.

Constant Value: 2103

I don't know what this error code means, or what I'm doing wrong. The Chromecast implementation should be able to handle custom TextTrackStyle (at least for embedded VTT type)

MediaManager.onMetadataLoaded = function (event) {
    .......
    console.log("### RESOLVED TEXT TRACK TYPE " + textTrackType);
    if (textTrackType ==
        sampleplayer.TextTrackType.SIDE_LOADED_TTML &&
        event.message && event.message.activeTrackIds && event.message.media &&
        event.message.media.tracks) {
        _processTtmlCues(
            event.message.activeTrackIds, event.message.media.tracks);
    } else if (!textTrackType || textTrackType == sampleplayer.TextTrackType.SIDE_LOADED_UNSUPPORTED) {
        // If we do not have a textTrackType, check if the tracks are embedded
        _maybeLoadEmbeddedTracksMetadata(event);
    }
    MediaManager['onMetadataLoadedOrig'](event);
}


 function _maybeLoadEmbeddedTracksMetadata(info) {
    if (!info.message || !info.message.media) {
        return;
    }
    var tracksInfo = _readInBandTracksInfo();
    if (tracksInfo) {
        textTrackType = sampleplayer.TextTrackType.EMBEDDED;
        tracksInfo.textTrackStyle = info.message.media.textTrackStyle;
        MediaManager.loadTracksInfo(tracksInfo);
    }
}

The result on the Chromecast is just white text with black background.

// EDIT Chromecast receiver log added:

There is Chromecast receiver log where I found some TextTrackStyle but this is not my style that I'm trying to set:

 Received message: {"data":"{\"requestId\":4,\"type\":\"EDIT_TRACKS_INFO\",\"textTrackStyle\":{\"fontScale\":1,\"foregroundColor\":\"#4285F4FF\",\"backgroundColor\":\"#FFFFFFFF\"},\"mediaSessionId\":1}"

Those are different colors that I'm actually sending from my Android Sender app. I cannot see any TextTrackStyle inside the onLoad method at all. So I'm not sure if the problem is on Android side or on Chromecast side?

来源:https://stackoverflow.com/questions/35530745/android-chromecast-companion-library-set-texttrackstyle-error-2103

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