當前位置: 首頁>>代碼示例>>Java>>正文


Java TrackSelection類代碼示例

本文整理匯總了Java中com.google.android.exoplayer2.trackselection.TrackSelection的典型用法代碼示例。如果您正苦於以下問題:Java TrackSelection類的具體用法?Java TrackSelection怎麽用?Java TrackSelection使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


TrackSelection類屬於com.google.android.exoplayer2.trackselection包,在下文中一共展示了TrackSelection類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createFullPlayer

import com.google.android.exoplayer2.trackselection.TrackSelection; //導入依賴的package包/類
/***
 * 創建實例播放實例,並不開始緩衝
 **/
private SimpleExoPlayer createFullPlayer() {
    TrackSelection.Factory videoTrackSelectionFactory = new AdaptiveTrackSelection.Factory(new DefaultBandwidthMeter());
    TrackSelector trackSelector = new DefaultTrackSelector(videoTrackSelectionFactory);
    BufferingLoadControl loadControl = new BufferingLoadControl();
    if (null == modelType) {
        setDefaultLoadModel();
    } else {
        loadControl.setListener(new LoadListener() {
            @Override
            public void onProgress(long pro) {
                getPlayerViewListener().showNetSpeed(String.valueOf(pro) + "%");
            }
        });
    }
    DefaultRenderersFactory rf = new DefaultRenderersFactory(activity, drmSessionManager, DefaultRenderersFactory.EXTENSION_RENDERER_MODE_ON);
    SimpleExoPlayer player = ExoPlayerFactory.newSimpleInstance(rf, trackSelector, loadControl);
    player.setPlaybackParameters(playbackParameters);
    getPlayerViewListener().setPlayer(player);
    return player;
}
 
開發者ID:yangchaojiang,項目名稱:yjPlay,代碼行數:24,代碼來源:ExoUserPlayer.java

示例2: onBind

import com.google.android.exoplayer2.trackselection.TrackSelection; //導入依賴的package包/類
@Override
public IBinder onBind(final Intent intent) {

    bandwidthMeter = new DefaultBandwidthMeter();
    TrackSelection.Factory videoTrackSelectionFactory =
            new AdaptiveTrackSelection.Factory(bandwidthMeter);

    dataSourceFactory = new DefaultDataSourceFactory(this,
            Util.getUserAgent(this, "SyncPlayer"), bandwidthMeter);

    extractorsFactory = new DefaultExtractorsFactory();

    TrackSelector trackSelector =
            new DefaultTrackSelector(videoTrackSelectionFactory);

    LoadControl loadControl = new DefaultLoadControl();

    SimpleExoPlayer player =
            ExoPlayerFactory.newSimpleInstance(getApplicationContext(), trackSelector, loadControl);
    mMediaPlayer = player;

    setCompletionListener();
    nbuilder.setSmallIcon(R.mipmap.ic_launcher);
    return mBinder;
}
 
開發者ID:mo3rfan,項目名稱:syncplayer,代碼行數:26,代碼來源:MediaService.java

示例3: initPlayer

import com.google.android.exoplayer2.trackselection.TrackSelection; //導入依賴的package包/類
protected void initPlayer() {
    // 1. Create a default TrackSelector
    mMainHandler = new Handler();
    TrackSelection.Factory videoTrackSelectionFactory =
            new AdaptiveTrackSelection.Factory(BANDWIDTH_METER);
    mTrackSelector =
            new DefaultTrackSelector(videoTrackSelectionFactory);
    mTrackSelectionHelper = new TrackSelectionHelper(this, mTrackSelector,videoTrackSelectionFactory);


    // 3. Create the mTubiExoPlayer
    mTubiExoPlayer = ExoPlayerFactory.newSimpleInstance(this, mTrackSelector);

    mEventLogger = new EventLogger(mTrackSelector);
    mTubiExoPlayer.addListener(mEventLogger);
    mTubiExoPlayer.setAudioDebugListener(mEventLogger);
    mTubiExoPlayer.setVideoDebugListener(mEventLogger);
    mTubiExoPlayer.setMetadataOutput(mEventLogger);

    mTubiPlayerView.setPlayer(mTubiExoPlayer, this);
    mTubiPlayerView.setMediaModel(mediaModel,true);
    mTubiPlayerView.setTrackSelectionHelper(mTrackSelectionHelper);
}
 
開發者ID:Tubitv,項目名稱:TubiPlayer,代碼行數:24,代碼來源:TubiPlayerActivity.java

示例4: selectTracks

import com.google.android.exoplayer2.trackselection.TrackSelection; //導入依賴的package包/類
@Override
protected TrackSelection[] selectTracks(RendererCapabilities[] rendererCapabilities,
    TrackGroupArray[] rendererTrackGroupArrays, int[][][] rendererFormatSupports)
    throws ExoPlaybackException {
  Assertions.checkState(rendererCapabilities[VIDEO_RENDERER_INDEX].getTrackType()
      == C.TRACK_TYPE_VIDEO);
  Assertions.checkState(rendererCapabilities[AUDIO_RENDERER_INDEX].getTrackType()
      == C.TRACK_TYPE_AUDIO);
  Assertions.checkState(rendererTrackGroupArrays[VIDEO_RENDERER_INDEX].length == 1);
  Assertions.checkState(rendererTrackGroupArrays[AUDIO_RENDERER_INDEX].length == 1);
  TrackSelection[] selections = new TrackSelection[rendererCapabilities.length];
  selections[VIDEO_RENDERER_INDEX] = new RandomTrackSelection(
      rendererTrackGroupArrays[VIDEO_RENDERER_INDEX].get(0),
      getVideoTrackIndices(rendererTrackGroupArrays[VIDEO_RENDERER_INDEX].get(0),
          rendererFormatSupports[VIDEO_RENDERER_INDEX][0], videoFormatIds,
          canIncludeAdditionalVideoFormats),
      0 /* seed */);
  selections[AUDIO_RENDERER_INDEX] = new FixedTrackSelection(
      rendererTrackGroupArrays[AUDIO_RENDERER_INDEX].get(0),
      getTrackIndex(rendererTrackGroupArrays[AUDIO_RENDERER_INDEX].get(0), audioFormatId));
  includedAdditionalVideoFormats =
      selections[VIDEO_RENDERER_INDEX].length() > videoFormatIds.length;
  return selections;
}
 
開發者ID:ashwanijanghu,項目名稱:ExoPlayer-Offline,代碼行數:25,代碼來源:DashTest.java

示例5: initializePlayer

import com.google.android.exoplayer2.trackselection.TrackSelection; //導入依賴的package包/類
private void initializePlayer() {
  if (player == null) {
    // a factory to create an AdaptiveVideoTrackSelection
    TrackSelection.Factory adaptiveTrackSelectionFactory =
        new AdaptiveTrackSelection.Factory(BANDWIDTH_METER);
    // using a DefaultTrackSelector with an adaptive video selection factory
    player = ExoPlayerFactory.newSimpleInstance(new DefaultRenderersFactory(this),
        new DefaultTrackSelector(adaptiveTrackSelectionFactory), new DefaultLoadControl());
    player.addListener(componentListener);
    player.addVideoDebugListener(componentListener);
    player.addAudioDebugListener(componentListener);
    playerView.setPlayer(player);
    player.setPlayWhenReady(playWhenReady);
    player.seekTo(currentWindow, playbackPosition);
  }
  MediaSource mediaSource = buildMediaSource(Uri.parse(getString(R.string.media_url_dash)));
  player.prepare(mediaSource, true, false);
}
 
開發者ID:googlecodelabs,項目名稱:exoplayer-intro,代碼行數:19,代碼來源:PlayerActivity.java

示例6: prepareAsync

import com.google.android.exoplayer2.trackselection.TrackSelection; //導入依賴的package包/類
@Override
public void prepareAsync() throws IllegalStateException {
    TrackSelection.Factory videoTrackSelectionFactory =
            new AdaptiveTrackSelection.Factory(BANDWIDTH_METER);
    DefaultTrackSelector trackSelector = new DefaultTrackSelector(videoTrackSelectionFactory);

    mInternalMediaPlayer = InternalExoPlayer.newInstance(mAppContext, trackSelector);

    mEventListener = new ExoEventListener();
    mInternalMediaPlayer.addListener(mEventListener);
    mVideoListener = new ExoVideoListener();
    mInternalMediaPlayer.addVideoListener(mVideoListener);

    MediaSource mediaSource = buildMediaSource(mUri, mHeaders);
    mInternalMediaPlayer.setVideoSurface(mSurface);
    mInternalMediaPlayer.prepare(mediaSource);
    notifyOnPrepared();
}
 
開發者ID:xinpianchang,項目名稱:NSMPlayer-Android,代碼行數:19,代碼來源:WrapExoPlayer.java

示例7: setExoViewSource

import com.google.android.exoplayer2.trackselection.TrackSelection; //導入依賴的package包/類
private void setExoViewSource(@NonNull MasterSecret masterSecret, @NonNull VideoSlide videoSource)
    throws IOException
{
  BandwidthMeter         bandwidthMeter             = new DefaultBandwidthMeter();
  TrackSelection.Factory videoTrackSelectionFactory = new AdaptiveTrackSelection.Factory(bandwidthMeter);
  TrackSelector          trackSelector              = new DefaultTrackSelector(videoTrackSelectionFactory);
  LoadControl            loadControl                = new DefaultLoadControl();

  exoPlayer = ExoPlayerFactory.newSimpleInstance(getContext(), trackSelector, loadControl);
  exoView.setPlayer(exoPlayer);

  DefaultDataSourceFactory    defaultDataSourceFactory    = new DefaultDataSourceFactory(getContext(), "GenericUserAgent", null);
  AttachmentDataSourceFactory attachmentDataSourceFactory = new AttachmentDataSourceFactory(getContext(), masterSecret, defaultDataSourceFactory, null);
  ExtractorsFactory           extractorsFactory           = new DefaultExtractorsFactory();

  MediaSource mediaSource = new ExtractorMediaSource(videoSource.getUri(), attachmentDataSourceFactory, extractorsFactory, null, null);

  exoPlayer.prepare(mediaSource);
  exoPlayer.setPlayWhenReady(true);
}
 
開發者ID:CableIM,項目名稱:Cable-Android,代碼行數:21,代碼來源:VideoPlayer.java

示例8: selectTracks

import com.google.android.exoplayer2.trackselection.TrackSelection; //導入依賴的package包/類
@Override
public long selectTracks(TrackSelection[] selections, boolean[] mayRetainStreamFlags,
    SampleStream[] streams, boolean[] streamResetFlags, long positionUs) {
  sampleStreams = new ClippingSampleStream[streams.length];
  SampleStream[] internalStreams = new SampleStream[streams.length];
  for (int i = 0; i < streams.length; i++) {
    sampleStreams[i] = (ClippingSampleStream) streams[i];
    internalStreams[i] = sampleStreams[i] != null ? sampleStreams[i].stream : null;
  }
  long enablePositionUs = mediaPeriod.selectTracks(selections, mayRetainStreamFlags,
      internalStreams, streamResetFlags, positionUs + startUs);
  Assertions.checkState(enablePositionUs == positionUs + startUs
      || (enablePositionUs >= startUs
      && (endUs == C.TIME_END_OF_SOURCE || enablePositionUs <= endUs)));
  for (int i = 0; i < streams.length; i++) {
    if (internalStreams[i] == null) {
      sampleStreams[i] = null;
    } else if (streams[i] == null || sampleStreams[i].stream != internalStreams[i]) {
      sampleStreams[i] = new ClippingSampleStream(this, internalStreams[i], startUs, endUs,
          pendingInitialDiscontinuity);
    }
    streams[i] = sampleStreams[i];
  }
  return enablePositionUs - startUs;
}
 
開發者ID:sanjaysingh1990,項目名稱:Exoplayer2Radio,代碼行數:26,代碼來源:ClippingMediaPeriod.java

示例9: maybeBlacklistTrack

import com.google.android.exoplayer2.trackselection.TrackSelection; //導入依賴的package包/類
/**
 * Blacklists {@code trackSelectionIndex} in {@code trackSelection} for
 * {@code blacklistDurationMs} if calling {@link #shouldBlacklist(Exception)} for {@code e}
 * returns true. Else does nothing. Note that blacklisting will fail if the track is the only
 * non-blacklisted track in the selection.
 *
 * @param trackSelection The track selection.
 * @param trackSelectionIndex The index in the selection to consider blacklisting.
 * @param e The error to inspect.
 * @param blacklistDurationMs The duration to blacklist the track for, if it is blacklisted.
 * @return Whether the track was blacklisted.
 */
public static boolean maybeBlacklistTrack(TrackSelection trackSelection, int trackSelectionIndex,
    Exception e, long blacklistDurationMs) {
  if (shouldBlacklist(e)) {
    boolean blacklisted = trackSelection.blacklist(trackSelectionIndex, blacklistDurationMs);
    int responseCode = ((InvalidResponseCodeException) e).responseCode;
    if (blacklisted) {
      Log.w(TAG, "Blacklisted: duration=" + blacklistDurationMs + ", responseCode="
          + responseCode + ", format=" + trackSelection.getFormat(trackSelectionIndex));
    } else {
      Log.w(TAG, "Blacklisting failed (cannot blacklist last enabled track): responseCode="
          + responseCode + ", format=" + trackSelection.getFormat(trackSelectionIndex));
    }
    return blacklisted;
  }
  return false;
}
 
開發者ID:sanjaysingh1990,項目名稱:Exoplayer2Radio,代碼行數:29,代碼來源:ChunkedTrackBlacklistUtil.java

示例10: selectTracks

import com.google.android.exoplayer2.trackselection.TrackSelection; //導入依賴的package包/類
@Override
public long selectTracks(TrackSelection[] selections, boolean[] mayRetainStreamFlags,
    SampleStream[] streams, boolean[] streamResetFlags, long positionUs) {
  for (int i = 0; i < selections.length; i++) {
    if (streams[i] != null && (selections[i] == null || !mayRetainStreamFlags[i])) {
      sampleStreams.remove(streams[i]);
      streams[i] = null;
    }
    if (streams[i] == null && selections[i] != null) {
      SampleStreamImpl stream = new SampleStreamImpl();
      sampleStreams.add(stream);
      streams[i] = stream;
      streamResetFlags[i] = true;
    }
  }
  return positionUs;
}
 
開發者ID:sanjaysingh1990,項目名稱:Exoplayer2Radio,代碼行數:18,代碼來源:SingleSampleMediaPeriod.java

示例11: setupExoPlayer

import com.google.android.exoplayer2.trackselection.TrackSelection; //導入依賴的package包/類
private void setupExoPlayer() {
    TrackSelection.Factory adaptiveTrackSelectionFactory =
            new AdaptiveTrackSelection.Factory(new DefaultBandwidthMeter());

    exoPlayer = ExoPlayerFactory.newSimpleInstance(
            new DefaultRenderersFactory(this),
            new DefaultTrackSelector(adaptiveTrackSelectionFactory),
            new DefaultLoadControl());
    pvVideoPreview.setPlayer(exoPlayer);
    exoPlayer.setPlayWhenReady(true);

    Uri uri = Uri.parse("asset:///sample_video.mp4");
    MediaSource mediaSource = createMediaSource(this, uri);
    LoopingMediaSource loopingMediaSource = new LoopingMediaSource(mediaSource);
    exoPlayer.prepare(loopingMediaSource, true, false);
}
 
開發者ID:akexorcist,項目名稱:Android-O-Feature,代碼行數:17,代碼來源:PictureInPictureActivity.java

示例12: initExoPlayer

import com.google.android.exoplayer2.trackselection.TrackSelection; //導入依賴的package包/類
private void initExoPlayer(MediaSource sampleSource) {
  if (exoPlayer == null) {
    TrackSelection.Factory videoTrackSelectionFactory =
        new AdaptiveTrackSelection.Factory(new DefaultBandwidthMeter());
    TrackSelector trackSelector = new DefaultTrackSelector(videoTrackSelectionFactory);

    // 2. Create the player
    exoPlayer = ExoPlayerFactory.newSimpleInstance(this, trackSelector);
  }

  exoPlayer.prepare(sampleSource);

  exoPlayer.setVideoSurfaceView(svPlayer);

  exoPlayer.setPlayWhenReady(true);

  initMediaControls();
}
 
開發者ID:Foso,項目名稱:ExoPlayer-with-MediaControls,代碼行數:19,代碼來源:MainActivity.java

示例13: DefaultDashChunkSource

import com.google.android.exoplayer2.trackselection.TrackSelection; //導入依賴的package包/類
/**
 * @param manifestLoaderErrorThrower Throws errors affecting loading of manifests.
 * @param manifest The initial manifest.
 * @param periodIndex The index of the period in the manifest.
 * @param adaptationSetIndex The index of the adaptation set in the period.
 * @param trackSelection The track selection.
 * @param dataSource A {@link DataSource} suitable for loading the media data.
 * @param elapsedRealtimeOffsetMs If known, an estimate of the instantaneous difference between
 *     server-side unix time and {@link SystemClock#elapsedRealtime()} in milliseconds, specified
 *     as the server's unix time minus the local elapsed time. If unknown, set to 0.
 * @param maxSegmentsPerLoad The maximum number of segments to combine into a single request.
 *     Note that segments will only be combined if their {@link Uri}s are the same and if their
 *     data ranges are adjacent.
 * @param enableEventMessageTrack Whether the chunks generated by the source may output an event
 *     message track.
 * @param enableEventMessageTrack Whether the chunks generated by the source may output a CEA-608
 *     track.
 */
public DefaultDashChunkSource(LoaderErrorThrower manifestLoaderErrorThrower,
    DashManifest manifest, int periodIndex, int adaptationSetIndex, TrackSelection trackSelection,
    DataSource dataSource, long elapsedRealtimeOffsetMs, int maxSegmentsPerLoad,
    boolean enableEventMessageTrack, boolean enableCea608Track) {
  this.manifestLoaderErrorThrower = manifestLoaderErrorThrower;
  this.manifest = manifest;
  this.adaptationSetIndex = adaptationSetIndex;
  this.trackSelection = trackSelection;
  this.dataSource = dataSource;
  this.periodIndex = periodIndex;
  this.elapsedRealtimeOffsetMs = elapsedRealtimeOffsetMs;
  this.maxSegmentsPerLoad = maxSegmentsPerLoad;

  long periodDurationUs = manifest.getPeriodDurationUs(periodIndex);
  AdaptationSet adaptationSet = getAdaptationSet();
  List<Representation> representations = adaptationSet.representations;
  representationHolders = new RepresentationHolder[trackSelection.length()];
  for (int i = 0; i < representationHolders.length; i++) {
    Representation representation = representations.get(trackSelection.getIndexInTrackGroup(i));
    representationHolders[i] = new RepresentationHolder(periodDurationUs, representation,
        enableEventMessageTrack, enableCea608Track, adaptationSet.type);
  }
}
 
開發者ID:jcodeing,項目名稱:K-Sonic,代碼行數:42,代碼來源:DefaultDashChunkSource.java

示例14: buildSampleStream

import com.google.android.exoplayer2.trackselection.TrackSelection; //導入依賴的package包/類
private ChunkSampleStream<DashChunkSource> buildSampleStream(int adaptationSetIndex,
    TrackSelection selection, long positionUs) {
  AdaptationSet adaptationSet = adaptationSets.get(adaptationSetIndex);
  int embeddedTrackCount = 0;
  int[] embeddedTrackTypes = new int[2];
  boolean enableEventMessageTrack = hasEventMessageTrack(adaptationSet);
  if (enableEventMessageTrack) {
    embeddedTrackTypes[embeddedTrackCount++] = C.TRACK_TYPE_METADATA;
  }
  boolean enableCea608Track = hasCea608Track(adaptationSet);
  if (enableCea608Track) {
    embeddedTrackTypes[embeddedTrackCount++] = C.TRACK_TYPE_TEXT;
  }
  if (embeddedTrackCount < embeddedTrackTypes.length) {
    embeddedTrackTypes = Arrays.copyOf(embeddedTrackTypes, embeddedTrackCount);
  }
  DashChunkSource chunkSource = chunkSourceFactory.createDashChunkSource(
      manifestLoaderErrorThrower, manifest, periodIndex, adaptationSetIndex, selection,
      elapsedRealtimeOffset, enableEventMessageTrack, enableCea608Track);
  ChunkSampleStream<DashChunkSource> stream = new ChunkSampleStream<>(adaptationSet.type,
      embeddedTrackTypes, chunkSource, this, allocator, positionUs, minLoadableRetryCount,
      eventDispatcher);
  return stream;
}
 
開發者ID:jcodeing,項目名稱:K-Sonic,代碼行數:25,代碼來源:DashMediaPeriod.java

示例15: DefaultSsChunkSource

import com.google.android.exoplayer2.trackselection.TrackSelection; //導入依賴的package包/類
/**
 * @param manifestLoaderErrorThrower Throws errors affecting loading of manifests.
 * @param manifest The initial manifest.
 * @param elementIndex The index of the stream element in the manifest.
 * @param trackSelection The track selection.
 * @param dataSource A {@link DataSource} suitable for loading the media data.
 * @param trackEncryptionBoxes Track encryption boxes for the stream.
 */
public DefaultSsChunkSource(LoaderErrorThrower manifestLoaderErrorThrower, SsManifest manifest,
    int elementIndex, TrackSelection trackSelection, DataSource dataSource,
    TrackEncryptionBox[] trackEncryptionBoxes) {
  this.manifestLoaderErrorThrower = manifestLoaderErrorThrower;
  this.manifest = manifest;
  this.elementIndex = elementIndex;
  this.trackSelection = trackSelection;
  this.dataSource = dataSource;

  StreamElement streamElement = manifest.streamElements[elementIndex];

  extractorWrappers = new ChunkExtractorWrapper[trackSelection.length()];
  for (int i = 0; i < extractorWrappers.length; i++) {
    int manifestTrackIndex = trackSelection.getIndexInTrackGroup(i);
    Format format = streamElement.formats[manifestTrackIndex];
    int nalUnitLengthFieldLength = streamElement.type == C.TRACK_TYPE_VIDEO ? 4 : 0;
    Track track = new Track(manifestTrackIndex, streamElement.type, streamElement.timescale,
        C.TIME_UNSET, manifest.durationUs, format, Track.TRANSFORMATION_NONE,
        trackEncryptionBoxes, nalUnitLengthFieldLength, null, null);
    FragmentedMp4Extractor extractor = new FragmentedMp4Extractor(
        FragmentedMp4Extractor.FLAG_WORKAROUND_EVERY_VIDEO_FRAME_IS_SYNC_FRAME
        | FragmentedMp4Extractor.FLAG_WORKAROUND_IGNORE_TFDT_BOX, null, track);
    extractorWrappers[i] = new ChunkExtractorWrapper(extractor, format);
  }
}
 
開發者ID:jcodeing,項目名稱:K-Sonic,代碼行數:34,代碼來源:DefaultSsChunkSource.java


注:本文中的com.google.android.exoplayer2.trackselection.TrackSelection類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。