Leanback
라이브러리를 사용하여 TV 용 Android 앱을 개발 중입니다. srt
자막을 URI에서 가진 HLS
비디오 스트림이 있습니다. 이 example app에 사용 된 ExoPlayer
버전 2.5.4
을 사용하고 있습니다. 내 MediaSource
사용하여 만든 : 내 PlaybackTransportControlGlue
에서Leanback ExoPlayer에서 자막을 전환하는 방법은 무엇입니까?
private MediaSource onCreateMediaSource(Uri uri, Uri subtitleUri) {
String userAgent = Util.getUserAgent(mContext, "ExoPlayerAdapter");
MediaSource videoSource = new HlsMediaSource(uri,
new DefaultDataSourceFactory(mContext, userAgent),
null,
null);
Format subtitleFormat = Format.createTextSampleFormat(
"1", MimeTypes.APPLICATION_SUBRIP, 0, "en");
MediaSource subtitleSource = new SingleSampleMediaSource(
subtitleUri,
new DefaultDataSourceFactory(mContext, userAgent),
subtitleFormat, C.TIME_UNSET);
MergingMediaSource mergedSource =
new MergingMediaSource(videoSource, subtitleSource);
return mergedSource;
}
을, 나는 PlaybackControlsRow.ClosedCaptioningAction
있습니다. 이 버튼을 클릭하면 액션 디스패처에서 자막을 토글하려면 어떻게해야합니까?
E/gralloc: unregister FBM buffer
비디오 트랙 선택에 대한 답변이 있지만 동일한 논리가 자막 트랙 선택에 적용됩니다. 더 많은 정보가 필요하다면 여기에 더 깊이있는 대답을 쓸 수 있습니다. 그냥 알려줘 :) https://stackoverflow.com/questions/45835562/quality-selector-for-exoplayer-2/45844705#45844705 더 적절한 답변도 있습니다. 네가 뭘 찾고 있는지 알려주지. https://stackoverflow.com/questions/46521570/how-to-add-multiple-subtitles-in-exo-player-2/46547904#46547904 –
@KyleVenn 이미 두 번째 링크에서 제안을했습니다. 첫 번째 링크는 비디오 품질과 오디오를 바꾸는 것에 관한 것 같습니다. 나는 그것을 원하지 않는다. 단추를 클릭 할 때 자막을 표시하거나 숨길 수 있습니다. 이미 버튼에 청취자가 있습니다. 나는 어떤 코드가 CC를 토글 할 것인지 알고 싶다. – khateeb
첫 번째 링크는 동영상 품질 (TRACK_TYPE_VIDEO)에 관한 것이지만 자막에는 동일한 코드가 사용되어야합니다 (트랙 그룹에서도 지원되기 때문에). 'selector.setSelectionOverride (rendererIndex, trackGroups, override);'는 여전히 당신이 원하는대로 작동 할 것입니다. 'C.TRACK_TYPE_VIDEO' 대신'C.TRACK_TYPE_TEXT'가 필요합니다. 명확하지 않은 경우 알려 주시면보다 철저한 답변을 작성하겠습니다. –