0

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?

Stepan Sanda
  • 2,322
  • 7
  • 31
  • 55
  • You firs need to determine whether your issue is on the sender side or receiver. The error you mentioned means that you have sent the same message/request while another one was in queue. By looking at the console log on the chrome debugger connected to your receiver, you should be able to see whether sender is sending the info that you want or not. I presume you are seeing the captions but can't style it, right? – Ali Naddaf Feb 21 '16 at 02:37
  • Yes, you are right. I can see the captions but without my custom style. They have white font and black background all the time. And I'm still getting this error 2103. Is it possible that the CompanionLibrary is somehow applying some default TextTrackStyle to the captions? How I should proceed to find where the problem is? – Stepan Sanda Feb 21 '16 at 11:12
  • I checked the Chromecast console and I can see, that I'm actually sending the style to the Chromecast receiver. I edited my answer - added the console log from Chromecast receiver. – Stepan Sanda Feb 21 '16 at 12:26
  • In that case, it seems to be an issue on the receiver side and has nothing to do with CastCompanionLibrary. I know that with side-loaded VTT, you can change the style (CastVideos-android app shows that) so it might be a side effect of using embedded VTT; you might want to open a ticket on our issue tracker and provide the info; make sure you provide a full log on the receiver. – Ali Naddaf Feb 21 '16 at 18:05
  • Thank you for your time and answers! I actually added more logs to the Chromecast receiver and now I can see, that TextTrackStyle is coming empty from Android side. It looks like this: 'custom TextTrackStyle: {} embedded' there should be my style in Json format inside the brackets. Even when I'm trying to use side loaded TTML format, the TextTrackStyle is still the same no mater what I'm sending from Android. – Stepan Sanda Feb 21 '16 at 18:29
  • Please provide the logs for the portion that you are seeing empty track styles and surrounding area (not just one line) and the corresponding sender methods that you are calling for side-loaded version. Meanwhile, try CastVideos0android and verify that styling of captions work (the first three videos there have captions) – Ali Naddaf Feb 21 '16 at 19:28

1 Answers1

0

Just Make Sure to add your setTextTrackStyle function inside mediaclient.load call back if the the statue of the result isSuccess.

Mark S. Khalil
  • 113
  • 1
  • 4