当前位置: 首页>>代码示例>>Java>>正文


Java Format.createTextSampleFormat方法代码示例

本文整理汇总了Java中com.google.android.exoplayer2.Format.createTextSampleFormat方法的典型用法代码示例。如果您正苦于以下问题:Java Format.createTextSampleFormat方法的具体用法?Java Format.createTextSampleFormat怎么用?Java Format.createTextSampleFormat使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.android.exoplayer2.Format的用法示例。


在下文中一共展示了Format.createTextSampleFormat方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: parseTextSampleEntry

import com.google.android.exoplayer2.Format; //导入方法依赖的package包/类
private static void parseTextSampleEntry(ParsableByteArray parent, int atomType, int position,
    int atomSize, int trackId, String language, DrmInitData drmInitData, StsdData out)
    throws ParserException {
  parent.setPosition(position + Atom.HEADER_SIZE + StsdData.STSD_HEADER_SIZE);

  // Default values.
  List<byte[]> initializationData = null;
  long subsampleOffsetUs = Format.OFFSET_SAMPLE_RELATIVE;

  String mimeType;
  if (atomType == Atom.TYPE_TTML) {
    mimeType = MimeTypes.APPLICATION_TTML;
  } else if (atomType == Atom.TYPE_tx3g) {
    mimeType = MimeTypes.APPLICATION_TX3G;
    int sampleDescriptionLength = atomSize - Atom.HEADER_SIZE - 8;
    byte[] sampleDescriptionData = new byte[sampleDescriptionLength];
    parent.readBytes(sampleDescriptionData, 0, sampleDescriptionLength);
    initializationData = Collections.singletonList(sampleDescriptionData);
  } else if (atomType == Atom.TYPE_wvtt) {
    mimeType = MimeTypes.APPLICATION_MP4VTT;
  } else if (atomType == Atom.TYPE_stpp) {
    mimeType = MimeTypes.APPLICATION_TTML;
    subsampleOffsetUs = 0; // Subsample timing is absolute.
  } else if (atomType == Atom.TYPE_c608) {
    // Defined by the QuickTime File Format specification.
    mimeType = MimeTypes.APPLICATION_MP4CEA608;
    out.requiredSampleTransformation = Track.TRANSFORMATION_CEA608_CDAT;
  } else {
    // Never happens.
    throw new IllegalStateException();
  }

  out.format = Format.createTextSampleFormat(Integer.toString(trackId), mimeType, null,
      Format.NO_VALUE, 0, language, Format.NO_VALUE, drmInitData, subsampleOffsetUs,
      initializationData);
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:37,代码来源:AtomParsers.java

示例2: onCreate

import com.google.android.exoplayer2.Format; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_video);
    Bundle bundle = getIntent().getExtras();
    if(bundle!=null && bundle.containsKey("multimedia")) {

        Multimedia multimedia = bundle.getParcelable("multimedia");
        SimpleExoPlayerView videoView = (SimpleExoPlayerView) findViewById(R.id.video);

        // 1. Crea un slector de pista por defecto
        BandwidthMeter bandwidthMeter = new DefaultBandwidthMeter();
        TrackSelection.Factory videoTrackSelectionFactory = new AdaptiveVideoTrackSelection.Factory(bandwidthMeter);
        TrackSelector trackSelector = new DefaultTrackSelector(videoTrackSelectionFactory);

        // 2. Creo un control para el player
        LoadControl loadControl = new DefaultLoadControl();

        // 3. Creo el player con los componentes anteriores
        player = ExoPlayerFactory.newSimpleInstance(getApplicationContext(), trackSelector, loadControl);

        //Obtengo la URL completa del archivo de video
        Uri uri = Uri.parse(ConsultasBBDD.server + ConsultasBBDD.imagenes +  multimedia.getUrl());

        //A la vista le establezco el reproductor que va a usar
        videoView.setPlayer(player);

        // Procuce que se instancie el DataSource a través de los datos del video que ha sido cargado.
        DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(getApplicationContext(), Util.getUserAgent(getApplicationContext(), "SmartU"));
        // Produce un extractor que parsea el video.
        ExtractorsFactory extractorsFactory = new DefaultExtractorsFactory();
        // Construyo un MediaSource con el formato y los datos del video para asignarselo al reproductor.
        MediaSource videoSource = new ExtractorMediaSource(uri, dataSourceFactory, extractorsFactory, null, null);
        // If has subtitles load video with subtitles
        if (multimedia.getUrlSubtitulos() != null && multimedia.getUrlSubtitulos().compareTo("") != 0) {
            //Obtengo la URL completa para los subtitulos del video
            Uri subtitulosUri = Uri.parse(ConsultasBBDD.server + ConsultasBBDD.imagenes +  multimedia.getUrlSubtitulos());
            //Asigno el formato de los subtitulos
            Format textFormat = Format.createTextSampleFormat(null, MimeTypes.TEXT_VTT,
                    null, Format.NO_VALUE, Format.NO_VALUE, Locale.getDefault().getLanguage(), null);
            //Creo un MediaSource para los subtitulos para añadirselos al video
            MediaSource subtitleSource = new SingleSampleMediaSource(subtitulosUri, dataSourceFactory, textFormat, C.TIME_UNSET);
            // Mezcla el video con los subtitulos
            MergingMediaSource mergedSource = new MergingMediaSource(videoSource, subtitleSource);
            // Preparo el reproductor con los subtitulos y el video
            player.prepare(mergedSource);
        } else // Si no tiene subtitulos preparo solo el video
            player.prepare(videoSource);
    }
}
 
开发者ID:nen155,项目名称:TFG-SmartU-La-red-social,代码行数:51,代码来源:VideoActivity.java

示例3: getFormat

import com.google.android.exoplayer2.Format; //导入方法依赖的package包/类
public Format getFormat(){
    return Format.createTextSampleFormat(null, MimeTypes.APPLICATION_SUBRIP,null, Format.NO_VALUE, Format.NO_VALUE, "indonesia", null);
}
 
开发者ID:herudi,项目名称:react-native-exoplayer-intent-video,代码行数:4,代码来源:PlayerController.java


注:本文中的com.google.android.exoplayer2.Format.createTextSampleFormat方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。