我正在使用CastCompanionLibrary-Android而我正在尝试为字幕设置自定义100000020383 ^ 2
。
我正在创建它时将此TextTrackStyle
设置为MediaInfo:
TexTextStyle
但Chromecast方面没有明显的结果。我还尝试更改 // 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();
方法VideoCastManager
:
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);
}
}
}
我收到错误ResultCallback
,我在此处找到:developers google
public static final int REPLACED
状态代码,指示不再跟踪请求的进度,因为在第一个请求完成之前已经进行了相同类型的另一个请求。
常数值:2103
我不知道这个错误代码意味着什么,或者我做错了什么。 Chromecast实施应该能够处理自定义code 2103
(至少对于嵌入式TextTrackStyle
类型)
VTT
Chromecast上的结果只是带有黑色背景的白色文字。
//编辑Chromecast接收器日志:
有Chromecast接收器日志,我找到了一些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);
}
}
,但这不是我想要设置的样式:
TextTrackStyle
这些是我实际从我的Android Sender应用程序发送的不同颜色。我根本无法在 Received message: {"data":"{\"requestId\":4,\"type\":\"EDIT_TRACKS_INFO\",\"textTrackStyle\":{\"fontScale\":1,\"foregroundColor\":\"#4285F4FF\",\"backgroundColor\":\"#FFFFFFFF\"},\"mediaSessionId\":1}"
方法中看到任何TextTrackStyle
。所以我不确定问题出在Android端还是Chromecast端?