com.google.android.exoplayer2.source.SingleSampleMediaSource Java Examples

The following examples show how to use com.google.android.exoplayer2.source.SingleSampleMediaSource. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ExoPlayerHelper.java    From ExoPlayer-Wrapper with Apache License 2.0 5 votes vote down vote up
private MediaSource addSubTitlesToMediaSource(MediaSource mediaSource, String subTitlesUrl) {
    Format textFormat = Format.createTextSampleFormat(null, MimeTypes.APPLICATION_SUBRIP,
            null, Format.NO_VALUE, Format.NO_VALUE, "en", Format.NO_VALUE, null);
    Uri uri = Uri.parse(subTitlesUrl);
    MediaSource subtitleSource = new SingleSampleMediaSource.Factory(mDataSourceFactory)
            .createMediaSource(uri, textFormat, C.TIME_UNSET);
    return new MergingMediaSource(mediaSource, subtitleSource);
}
 
Example #2
Source File: GSYExoSubTitlePlayer.java    From GSYVideoPlayer with Apache License 2.0 5 votes vote down vote up
public MediaSource getTextSource(Uri subTitle) {
    //todo C.SELECTION_FLAG_AUTOSELECT language MimeTypes
    Format textFormat = Format.createTextSampleFormat(null, MimeTypes.APPLICATION_SUBRIP, C.SELECTION_FLAG_FORCED, "en");

    DefaultHttpDataSourceFactory factory = new DefaultHttpDataSourceFactory(Util.getUserAgent(mAppContext,
            "GSYExoSubTitlePlayer"), new DefaultBandwidthMeter.Builder(mAppContext).build(),
            50000,
            50000, true);

    MediaSource textMediaSource = new SingleSampleMediaSource.Factory(new DefaultDataSourceFactory(mAppContext, null,
            factory))
            .createMediaSource(subTitle, textFormat, C.TIME_UNSET);
    return textMediaSource;

}
 
Example #3
Source File: ReactExoplayerView.java    From react-native-video with MIT License 4 votes vote down vote up
private MediaSource buildTextSource(String title, Uri uri, String mimeType, String language) {
    Format textFormat = Format.createTextSampleFormat(title, mimeType, Format.NO_VALUE, language);
    return new SingleSampleMediaSource.Factory(mediaDataSourceFactory)
            .createMediaSource(uri, textFormat, C.TIME_UNSET);
}