本文整理了Java中com.google.android.exoplayer2.Format.createTextSampleFormat()
方法的一些代码示例,展示了Format.createTextSampleFormat()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Format.createTextSampleFormat()
方法的具体详情如下:
包路径:com.google.android.exoplayer2.Format
类名称:Format
方法名:createTextSampleFormat
暂无
代码示例来源:origin: google/ExoPlayer
/**
* @param flags A combination of {@code FLAG_*} values that control the behavior of the created
* readers.
*/
public DefaultTsPayloadReaderFactory(@Flags int flags) {
this(
flags,
Collections.singletonList(
Format.createTextSampleFormat(null, MimeTypes.APPLICATION_CEA608, 0, null)));
}
代码示例来源:origin: google/ExoPlayer
public static Format createTextSampleFormat(
@Nullable String id,
String sampleMimeType,
@C.SelectionFlags int selectionFlags,
@Nullable String language,
@Nullable DrmInitData drmInitData) {
return createTextSampleFormat(
id,
sampleMimeType,
/* codecs= */ null,
/* bitrate= */ NO_VALUE,
selectionFlags,
language,
NO_VALUE,
drmInitData,
OFFSET_SAMPLE_RELATIVE,
Collections.emptyList());
}
代码示例来源:origin: google/ExoPlayer
Format.createTextSampleFormat(
Integer.toString(trackId),
mimeType,
代码示例来源:origin: google/ExoPlayer
private TrackOutput buildTrackOutput(long subsampleOffsetUs) {
TrackOutput trackOutput = output.track(0, C.TRACK_TYPE_TEXT);
trackOutput.format(Format.createTextSampleFormat(null, MimeTypes.TEXT_VTT, null,
Format.NO_VALUE, 0, language, null, subsampleOffsetUs));
output.endTracks();
return trackOutput;
}
代码示例来源:origin: google/ExoPlayer
Format.createTextSampleFormat(
代码示例来源:origin: google/ExoPlayer
public void createTracks(ExtractorOutput extractorOutput, TrackIdGenerator idGenerator) {
for (int i = 0; i < outputs.length; i++) {
idGenerator.generateNewId();
TrackOutput output = extractorOutput.track(idGenerator.getTrackId(), C.TRACK_TYPE_TEXT);
Format channelFormat = closedCaptionFormats.get(i);
String channelMimeType = channelFormat.sampleMimeType;
Assertions.checkArgument(MimeTypes.APPLICATION_CEA608.equals(channelMimeType)
|| MimeTypes.APPLICATION_CEA708.equals(channelMimeType),
"Invalid closed caption mime type provided: " + channelMimeType);
String formatId = channelFormat.id != null ? channelFormat.id : idGenerator.getFormatId();
output.format(
Format.createTextSampleFormat(
formatId,
channelMimeType,
/* codecs= */ null,
/* bitrate= */ Format.NO_VALUE,
channelFormat.selectionFlags,
channelFormat.language,
channelFormat.accessibilityChannel,
/* drmInitData= */ null,
Format.OFFSET_SAMPLE_RELATIVE,
channelFormat.initializationData));
outputs[i] = output;
}
}
代码示例来源:origin: google/ExoPlayer
public void createTracks(
ExtractorOutput extractorOutput, TsPayloadReader.TrackIdGenerator idGenerator) {
for (int i = 0; i < outputs.length; i++) {
idGenerator.generateNewId();
TrackOutput output = extractorOutput.track(idGenerator.getTrackId(), C.TRACK_TYPE_TEXT);
Format channelFormat = closedCaptionFormats.get(i);
String channelMimeType = channelFormat.sampleMimeType;
Assertions.checkArgument(
MimeTypes.APPLICATION_CEA608.equals(channelMimeType)
|| MimeTypes.APPLICATION_CEA708.equals(channelMimeType),
"Invalid closed caption mime type provided: " + channelMimeType);
output.format(
Format.createTextSampleFormat(
idGenerator.getFormatId(),
channelMimeType,
/* codecs= */ null,
/* bitrate= */ Format.NO_VALUE,
channelFormat.selectionFlags,
channelFormat.language,
channelFormat.accessibilityChannel,
/* drmInitData= */ null,
Format.OFFSET_SAMPLE_RELATIVE,
channelFormat.initializationData));
outputs[i] = output;
}
}
代码示例来源:origin: google/ExoPlayer
enableCea608Track
? Collections.singletonList(
Format.createTextSampleFormat(null, MimeTypes.APPLICATION_CEA608, 0, null))
: Collections.emptyList();
extractor =
代码示例来源:origin: google/ExoPlayer
Format format = Format.createTextSampleFormat(firstAdaptationSet.id + ":cea608",
MimeTypes.APPLICATION_CEA608, 0, null);
trackGroups[cea608TrackGroupIndex] = new TrackGroup(format);
代码示例来源:origin: google/ExoPlayer
@Test
public void testSampleWithSeiPayloadParsing() throws Exception {
// Enabling the CEA-608 track enables SEI payload parsing.
ExtractorFactory extractorFactory =
getExtractorFactory(
Collections.singletonList(
Format.createTextSampleFormat(null, MimeTypes.APPLICATION_CEA608, 0, null)));
ExtractorAsserts.assertBehavior(extractorFactory, "mp4/sample_fragmented_sei.mp4");
}
代码示例来源:origin: google/ExoPlayer
} else if (MimeTypes.APPLICATION_SUBRIP.equals(mimeType)) {
type = C.TRACK_TYPE_TEXT;
format = Format.createTextSampleFormat(Integer.toString(trackId), mimeType, selectionFlags,
language, drmInitData);
} else if (MimeTypes.TEXT_SSA.equals(mimeType)) {
initializationData.add(SSA_DIALOGUE_FORMAT);
initializationData.add(codecPrivate);
format = Format.createTextSampleFormat(Integer.toString(trackId), mimeType, null,
Format.NO_VALUE, selectionFlags, language, Format.NO_VALUE, drmInitData,
Format.OFFSET_SAMPLE_RELATIVE, initializationData);
代码示例来源:origin: TeamNewPipe/NewPipe
if (mimeType == null) continue;
final Format textFormat = Format.createTextSampleFormat(null, mimeType,
SELECTION_FLAG_AUTOSELECT, PlayerHelper.captionLanguageOf(context, subtitle));
final MediaSource textSource = dataSource.getSampleMediaSourceFactory()
代码示例来源:origin: google/ExoPlayer
@Override
public void createTracks(ExtractorOutput extractorOutput, TrackIdGenerator idGenerator) {
idGenerator.generateNewId();
output = extractorOutput.track(idGenerator.getTrackId(), C.TRACK_TYPE_UNKNOWN);
output.format(
Format.createTextSampleFormat(
idGenerator.getFormatId(), "mime", null, 0, 0, language, null, 0));
}
代码示例来源:origin: google/ExoPlayer
Format.createTextSampleFormat(
代码示例来源:origin: jiajunhui/PlayerBase
Format format = Format.createTextSampleFormat(null, timedTextSource.getMimeType(), timedTextSource.getFlag(), null);
MediaSource timedTextMediaSource = new SingleSampleMediaSource.Factory(new DefaultDataSourceFactory(mAppContext,
Util.getUserAgent(mAppContext, mAppContext.getPackageName())))
代码示例来源:origin: google/ExoPlayer
int accessibilityChannel,
@Nullable DrmInitData drmInitData) {
return createTextSampleFormat(
id,
sampleMimeType,
@Nullable DrmInitData drmInitData,
long subsampleOffsetUs) {
return createTextSampleFormat(
id,
sampleMimeType,
代码示例来源:origin: google/ExoPlayer
@Test
public void testCustomPesReader() throws Exception {
CustomTsPayloadReaderFactory factory = new CustomTsPayloadReaderFactory(true, false);
TsExtractor tsExtractor =
new TsExtractor(TsExtractor.MODE_MULTI_PMT, new TimestampAdjuster(0), factory);
FakeExtractorInput input =
new FakeExtractorInput.Builder()
.setData(TestUtil.getByteArray(RuntimeEnvironment.application, "ts/sample.ts"))
.setSimulateIOErrors(false)
.setSimulateUnknownLength(false)
.setSimulatePartialReads(false)
.build();
FakeExtractorOutput output = new FakeExtractorOutput();
tsExtractor.init(output);
PositionHolder seekPositionHolder = new PositionHolder();
int readResult = Extractor.RESULT_CONTINUE;
while (readResult != Extractor.RESULT_END_OF_INPUT) {
readResult = tsExtractor.read(input, seekPositionHolder);
if (readResult == Extractor.RESULT_SEEK) {
input.setPosition((int) seekPositionHolder.position);
}
}
CustomEsReader reader = factory.esReader;
assertThat(reader.packetsRead).isEqualTo(2);
TrackOutput trackOutput = reader.getTrackOutput();
assertThat(trackOutput == output.trackOutputs.get(257 /* PID of audio track. */)).isTrue();
assertThat(((FakeTrackOutput) trackOutput).format)
.isEqualTo(Format.createTextSampleFormat("1/257", "mime", null, 0, 0, "und", null, 0));
}
代码示例来源:origin: rsiebert/TVHClient
@NonNull
private Format buildFormat(int streamIndex, @NonNull HtspMessage stream) {
return Format.createTextSampleFormat(
Integer.toString(streamIndex),
MimeTypes.APPLICATION_SUBRIP,
C.SELECTION_FLAG_AUTOSELECT,
stream.getString("language", "und"),
null
);
}
代码示例来源:origin: cemrich/zapp
@NonNull
private MediaSource getMediaSource(VideoInfo videoInfo) {
Uri uri = Uri.parse(videoInfo.getUrl());
MediaSource mediaSource = getMediaSourceWithoutSubtitles(uri);
// add subtitles if present
if (videoInfo.hasSubtitles()) {
Format textFormat = Format.createTextSampleFormat(null, MimeTypes.APPLICATION_TTML, C.SELECTION_FLAG_DEFAULT, SUBTITLE_LANGUAGE_ON);
MediaSource textMediaSource = new SingleSampleMediaSource.Factory(dataSourceFactory)
.setTreatLoadErrorsAsEndOfStream(true)
.createMediaSource(Uri.parse(videoInfo.getSubtitleUrl()), textFormat, C.TIME_UNSET);
mediaSource = new MergingMediaSource(mediaSource, textMediaSource);
}
// empty subtitle source to switch to
Format emptyTextFormat = Format.createTextSampleFormat(null, MimeTypes.APPLICATION_TTML, C.SELECTION_FLAG_DEFAULT, SUBTITLE_LANGUAGE_OFF);
MediaSource emptyTextMediaSource = new SingleSampleMediaSource.Factory(dataSourceFactory)
.setTreatLoadErrorsAsEndOfStream(true)
.createMediaSource(Uri.EMPTY, emptyTextFormat, 0);
mediaSource = new MergingMediaSource(mediaSource, emptyTextMediaSource);
return mediaSource;
}
内容来源于网络,如有侵权,请联系作者删除!