com.google.android.exoplayer2.source.TrackGroupArray Java Examples
The following examples show how to use
com.google.android.exoplayer2.source.TrackGroupArray.
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: DefaultTrackSelector.java From K-Sonic with MIT License | 6 votes |
protected TrackSelection selectVideoTrack(RendererCapabilities rendererCapabilities, TrackGroupArray groups, int[][] formatSupport, int maxVideoWidth, int maxVideoHeight, int maxVideoBitrate, boolean allowNonSeamlessAdaptiveness, boolean allowMixedMimeAdaptiveness, int viewportWidth, int viewportHeight, boolean orientationMayChange, TrackSelection.Factory adaptiveVideoTrackSelectionFactory, boolean exceedConstraintsIfNecessary, boolean exceedRendererCapabilitiesIfNecessary) throws ExoPlaybackException { TrackSelection selection = null; if (adaptiveVideoTrackSelectionFactory != null) { selection = selectAdaptiveVideoTrack(rendererCapabilities, groups, formatSupport, maxVideoWidth, maxVideoHeight, maxVideoBitrate, allowNonSeamlessAdaptiveness, allowMixedMimeAdaptiveness, viewportWidth, viewportHeight, orientationMayChange, adaptiveVideoTrackSelectionFactory); } if (selection == null) { selection = selectFixedVideoTrack(groups, formatSupport, maxVideoWidth, maxVideoHeight, maxVideoBitrate, viewportWidth, viewportHeight, orientationMayChange, exceedConstraintsIfNecessary, exceedRendererCapabilitiesIfNecessary); } return selection; }
Example #2
Source File: PlaybackInfo.java From Telegram with GNU General Public License v2.0 | 6 votes |
/** * Creates empty dummy playback info which can be used for masking as long as no real playback * info is available. * * @param startPositionUs The start position at which playback should start, in microseconds. * @param emptyTrackSelectorResult An empty track selector result with null entries for each * renderer. * @return A dummy playback info. */ public static PlaybackInfo createDummy( long startPositionUs, TrackSelectorResult emptyTrackSelectorResult) { return new PlaybackInfo( Timeline.EMPTY, /* manifest= */ null, DUMMY_MEDIA_PERIOD_ID, startPositionUs, /* contentPositionUs= */ C.TIME_UNSET, Player.STATE_IDLE, /* isLoading= */ false, TrackGroupArray.EMPTY, emptyTrackSelectorResult, DUMMY_MEDIA_PERIOD_ID, startPositionUs, /* totalBufferedDurationUs= */ 0, startPositionUs); }
Example #3
Source File: DefaultTrackSelector.java From Telegram-FOSS with GNU General Public License v2.0 | 6 votes |
private static void writeSelectionOverridesToParcel( Parcel dest, SparseArray<Map<TrackGroupArray, SelectionOverride>> selectionOverrides) { int renderersWithOverridesCount = selectionOverrides.size(); dest.writeInt(renderersWithOverridesCount); for (int i = 0; i < renderersWithOverridesCount; i++) { int rendererIndex = selectionOverrides.keyAt(i); Map<TrackGroupArray, SelectionOverride> overrides = selectionOverrides.valueAt(i); int overrideCount = overrides.size(); dest.writeInt(rendererIndex); dest.writeInt(overrideCount); for (Map.Entry<TrackGroupArray, SelectionOverride> override : overrides.entrySet()) { dest.writeParcelable(override.getKey(), /* parcelableFlags= */ 0); dest.writeParcelable(override.getValue(), /* parcelableFlags= */ 0); } } }
Example #4
Source File: MediaPeriodHolder.java From MediaSDK with Apache License 2.0 | 6 votes |
/** * Creates a new holder with information required to play it as part of a timeline. * * @param rendererCapabilities The renderer capabilities. * @param rendererPositionOffsetUs The renderer time of the start of the period, in microseconds. * @param trackSelector The track selector. * @param allocator The allocator. * @param mediaSource The media source that produced the media period. * @param info Information used to identify this media period in its timeline period. * @param emptyTrackSelectorResult A {@link TrackSelectorResult} with empty selections for each * renderer. */ public MediaPeriodHolder( RendererCapabilities[] rendererCapabilities, long rendererPositionOffsetUs, TrackSelector trackSelector, Allocator allocator, MediaSource mediaSource, MediaPeriodInfo info, TrackSelectorResult emptyTrackSelectorResult) { this.rendererCapabilities = rendererCapabilities; this.rendererPositionOffsetUs = rendererPositionOffsetUs; this.trackSelector = trackSelector; this.mediaSource = mediaSource; this.uid = info.id.periodUid; this.info = info; this.trackGroups = TrackGroupArray.EMPTY; this.trackSelectorResult = emptyTrackSelectorResult; sampleStreams = new SampleStream[rendererCapabilities.length]; mayRetainStreamFlags = new boolean[rendererCapabilities.length]; mediaPeriod = createMediaPeriod( info.id, mediaSource, allocator, info.startPositionUs, info.endPositionUs); }
Example #5
Source File: PlaybackInfo.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
public PlaybackInfo copyWithTrackInfo( TrackGroupArray trackGroups, TrackSelectorResult trackSelectorResult) { return new PlaybackInfo( timeline, manifest, periodId, startPositionUs, contentPositionUs, playbackState, isLoading, trackGroups, trackSelectorResult, loadingMediaPeriodId, bufferedPositionUs, totalBufferedDurationUs, positionUs); }
Example #6
Source File: ExoPlayerSubtitleTrackSelector.java From no-player with Apache License 2.0 | 6 votes |
public List<PlayerSubtitleTrack> getSubtitleTracks(RendererTypeRequester rendererTypeRequester) { TrackGroupArray trackGroups = trackSelector.trackGroups(TEXT, rendererTypeRequester); List<PlayerSubtitleTrack> subtitleTracks = new ArrayList<>(); for (int groupIndex = 0; groupIndex < trackGroups.length; groupIndex++) { TrackGroup trackGroup = trackGroups.get(groupIndex); for (int formatIndex = 0; formatIndex < trackGroup.length; formatIndex++) { Format format = trackGroup.getFormat(formatIndex); PlayerSubtitleTrack playerSubtitleTrack = new PlayerSubtitleTrack( groupIndex, formatIndex, format.id, format.language, format.sampleMimeType, format.channelCount, format.bitrate ); subtitleTracks.add(playerSubtitleTrack); } } return subtitleTracks; }
Example #7
Source File: DefaultTrackSelector.java From MediaSDK with Apache License 2.0 | 6 votes |
private static void writeSelectionOverridesToParcel( Parcel dest, SparseArray<Map<TrackGroupArray, @NullableType SelectionOverride>> selectionOverrides) { int renderersWithOverridesCount = selectionOverrides.size(); dest.writeInt(renderersWithOverridesCount); for (int i = 0; i < renderersWithOverridesCount; i++) { int rendererIndex = selectionOverrides.keyAt(i); Map<TrackGroupArray, @NullableType SelectionOverride> overrides = selectionOverrides.valueAt(i); int overrideCount = overrides.size(); dest.writeInt(rendererIndex); dest.writeInt(overrideCount); for (Map.Entry<TrackGroupArray, @NullableType SelectionOverride> override : overrides.entrySet()) { dest.writeParcelable(override.getKey(), /* parcelableFlags= */ 0); dest.writeParcelable(override.getValue(), /* parcelableFlags= */ 0); } } }
Example #8
Source File: DefaultTrackSelector.java From Telegram with GNU General Public License v2.0 | 6 votes |
private static boolean areSelectionOverridesEqual( SparseArray<Map<TrackGroupArray, SelectionOverride>> first, SparseArray<Map<TrackGroupArray, SelectionOverride>> second) { int firstSize = first.size(); if (second.size() != firstSize) { return false; } for (int indexInFirst = 0; indexInFirst < firstSize; indexInFirst++) { int indexInSecond = second.indexOfKey(first.keyAt(indexInFirst)); if (indexInSecond < 0 || !areSelectionOverridesEqual( first.valueAt(indexInFirst), second.valueAt(indexInSecond))) { return false; } } return true; }
Example #9
Source File: DefaultTrackSelector.java From MediaSDK with Apache License 2.0 | 6 votes |
/** * Called by {@link #selectAllTracks(MappedTrackInfo, int[][][], int[], Parameters)} to create a * {@link TrackSelection} for a video renderer. * * @param groups The {@link TrackGroupArray} mapped to the renderer. * @param formatSupports The {@link Capabilities} for each mapped track, indexed by renderer, * track group and track (in that order). * @param mixedMimeTypeAdaptationSupports The {@link AdaptiveSupport} for mixed MIME type * adaptation for the renderer. * @param params The selector's current constraint parameters. * @param enableAdaptiveTrackSelection Whether adaptive track selection is allowed. * @return The {@link TrackSelection.Definition} for the renderer, or null if no selection was * made. * @throws ExoPlaybackException If an error occurs while selecting the tracks. */ @Nullable protected TrackSelection.Definition selectVideoTrack( TrackGroupArray groups, @Capabilities int[][] formatSupports, @AdaptiveSupport int mixedMimeTypeAdaptationSupports, Parameters params, boolean enableAdaptiveTrackSelection) throws ExoPlaybackException { TrackSelection.Definition definition = null; if (!params.forceHighestSupportedBitrate && !params.forceLowestBitrate && enableAdaptiveTrackSelection) { definition = selectAdaptiveVideoTrack(groups, formatSupports, mixedMimeTypeAdaptationSupports, params); } if (definition == null) { definition = selectFixedVideoTrack(groups, formatSupports, params); } return definition; }
Example #10
Source File: DefaultTrackSelector.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
/** * Returns whether a renderer supports tunneling for a {@link TrackSelection}. * * @param formatSupports The result of {@link RendererCapabilities#supportsFormat} for each track, * indexed by group index and track index (in that order). * @param trackGroups The {@link TrackGroupArray}s for the renderer. * @param selection The track selection. * @return Whether the renderer supports tunneling for the {@link TrackSelection}. */ private static boolean rendererSupportsTunneling( int[][] formatSupports, TrackGroupArray trackGroups, TrackSelection selection) { if (selection == null) { return false; } int trackGroupIndex = trackGroups.indexOf(selection.getTrackGroup()); for (int i = 0; i < selection.length(); i++) { int trackFormatSupport = formatSupports[trackGroupIndex][selection.getIndexInTrackGroup(i)]; if ((trackFormatSupport & RendererCapabilities.TUNNELING_SUPPORT_MASK) != RendererCapabilities.TUNNELING_SUPPORTED) { return false; } } return true; }
Example #11
Source File: PlayerActivity.java From ExoPlayer-Offline with Apache License 2.0 | 5 votes |
@Override public void onTracksChanged(TrackGroupArray trackGroups, TrackSelectionArray trackSelections) { updateButtonVisibilities(); MappedTrackInfo mappedTrackInfo = trackSelector.getCurrentMappedTrackInfo(); if (mappedTrackInfo != null) { if (mappedTrackInfo.getTrackTypeRendererSupport(C.TRACK_TYPE_VIDEO) == MappedTrackInfo.RENDERER_SUPPORT_UNSUPPORTED_TRACKS) { showToast(R.string.error_unsupported_video); } if (mappedTrackInfo.getTrackTypeRendererSupport(C.TRACK_TYPE_AUDIO) == MappedTrackInfo.RENDERER_SUPPORT_UNSUPPORTED_TRACKS) { showToast(R.string.error_unsupported_audio); } } }
Example #12
Source File: ExoMediaPlayer.java From ExoMedia with Apache License 2.0 | 5 votes |
/** * Retrieves a list of available tracks * * @return A list of available tracks associated with each type */ @Nullable public Map<RendererType, TrackGroupArray> getAvailableTracks() { if (getPlaybackState() == Player.STATE_IDLE) { return null; } // Retrieves the available tracks Map<RendererType, TrackGroupArray> trackMap = new ArrayMap<>(); MappingTrackSelector.MappedTrackInfo mappedTrackInfo = trackSelector.getCurrentMappedTrackInfo(); if (mappedTrackInfo == null) { return trackMap; } // Maps the available tracks RendererType[] types = new RendererType[]{RendererType.AUDIO, RendererType.VIDEO, RendererType.CLOSED_CAPTION, RendererType.METADATA}; for (RendererType type : types) { List<TrackGroup> trackGroups = new ArrayList<>(); // collect track groups from all the track renderers of the same type for (Integer exoPlayerTrackIndex : getExoPlayerTracksInfo(type, 0, mappedTrackInfo).rendererTrackIndexes) { TrackGroupArray trackGroupArray = mappedTrackInfo.getTrackGroups(exoPlayerTrackIndex); for (int i = 0; i < trackGroupArray.length; i++) { trackGroups.add(trackGroupArray.get(i)); } } if (!trackGroups.isEmpty()) { // construct fake track group array for track groups from all the renderers of the same type trackMap.put(type, new TrackGroupArray(trackGroups.toArray(new TrackGroup[trackGroups.size()]))); } } return trackMap; }
Example #13
Source File: PlaybackInfo.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
/** * Create playback info. * * @param timeline See {@link #timeline}. * @param manifest See {@link #manifest}. * @param periodId See {@link #periodId}. * @param startPositionUs See {@link #startPositionUs}. * @param contentPositionUs See {@link #contentPositionUs}. * @param playbackState See {@link #playbackState}. * @param isLoading See {@link #isLoading}. * @param trackGroups See {@link #trackGroups}. * @param trackSelectorResult See {@link #trackSelectorResult}. * @param loadingMediaPeriodId See {@link #loadingMediaPeriodId}. * @param bufferedPositionUs See {@link #bufferedPositionUs}. * @param totalBufferedDurationUs See {@link #totalBufferedDurationUs}. * @param positionUs See {@link #positionUs}. */ public PlaybackInfo( Timeline timeline, @Nullable Object manifest, MediaPeriodId periodId, long startPositionUs, long contentPositionUs, int playbackState, boolean isLoading, TrackGroupArray trackGroups, TrackSelectorResult trackSelectorResult, MediaPeriodId loadingMediaPeriodId, long bufferedPositionUs, long totalBufferedDurationUs, long positionUs) { this.timeline = timeline; this.manifest = manifest; this.periodId = periodId; this.startPositionUs = startPositionUs; this.contentPositionUs = contentPositionUs; this.playbackState = playbackState; this.isLoading = isLoading; this.trackGroups = trackGroups; this.trackSelectorResult = trackSelectorResult; this.loadingMediaPeriodId = loadingMediaPeriodId; this.bufferedPositionUs = bufferedPositionUs; this.totalBufferedDurationUs = totalBufferedDurationUs; this.positionUs = positionUs; }
Example #14
Source File: AnalyticsListenerForwarder.java From no-player with Apache License 2.0 | 5 votes |
@Override public void onTracksChanged(EventTime eventTime, TrackGroupArray trackGroups, TrackSelectionArray trackSelections) { HashMap<String, String> callingMethodParameters = new HashMap<>(); callingMethodParameters.put(Parameters.EVENT_TIME, eventTime.toString()); callingMethodParameters.put(Parameters.TRACK_GROUPS, trackGroups.toString()); callingMethodParameters.put(Parameters.TRACK_SELECTIONS, trackSelections.toString()); infoListeners.onNewInfo(Methods.ON_TRACKS_CHANGED, callingMethodParameters); }
Example #15
Source File: DefaultTrackSelector.java From MediaSDK with Apache License 2.0 | 5 votes |
private static SparseArray<Map<TrackGroupArray, @NullableType SelectionOverride>> cloneSelectionOverrides( SparseArray<Map<TrackGroupArray, @NullableType SelectionOverride>> selectionOverrides) { SparseArray<Map<TrackGroupArray, @NullableType SelectionOverride>> clone = new SparseArray<>(); for (int i = 0; i < selectionOverrides.size(); i++) { clone.put(selectionOverrides.keyAt(i), new HashMap<>(selectionOverrides.valueAt(i))); } return clone; }
Example #16
Source File: MappingTrackSelector.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
/** * @param rendererTrackTypes The track type handled by each renderer. * @param rendererTrackGroups The {@link TrackGroup}s mapped to each renderer. * @param rendererMixedMimeTypeAdaptiveSupports The result of {@link * RendererCapabilities#supportsMixedMimeTypeAdaptation()} for each renderer. * @param rendererFormatSupports The result of {@link RendererCapabilities#supportsFormat} for * each mapped track, indexed by renderer, track group and track (in that order). * @param unmappedTrackGroups {@link TrackGroup}s not mapped to any renderer. */ /* package */ MappedTrackInfo( int[] rendererTrackTypes, TrackGroupArray[] rendererTrackGroups, int[] rendererMixedMimeTypeAdaptiveSupports, int[][][] rendererFormatSupports, TrackGroupArray unmappedTrackGroups) { this.rendererTrackTypes = rendererTrackTypes; this.rendererTrackGroups = rendererTrackGroups; this.rendererFormatSupports = rendererFormatSupports; this.rendererMixedMimeTypeAdaptiveSupports = rendererMixedMimeTypeAdaptiveSupports; this.unmappedTrackGroups = unmappedTrackGroups; this.rendererCount = rendererTrackTypes.length; this.length = rendererCount; }
Example #17
Source File: DefaultTrackSelector.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
private static @Nullable TrackSelection selectAdaptiveVideoTrack( TrackGroupArray groups, int[][] formatSupport, int mixedMimeTypeAdaptationSupports, Parameters params, TrackSelection.Factory adaptiveTrackSelectionFactory, BandwidthMeter bandwidthMeter) throws ExoPlaybackException { int requiredAdaptiveSupport = params.allowNonSeamlessAdaptiveness ? (RendererCapabilities.ADAPTIVE_NOT_SEAMLESS | RendererCapabilities.ADAPTIVE_SEAMLESS) : RendererCapabilities.ADAPTIVE_SEAMLESS; boolean allowMixedMimeTypes = params.allowMixedMimeAdaptiveness && (mixedMimeTypeAdaptationSupports & requiredAdaptiveSupport) != 0; for (int i = 0; i < groups.length; i++) { TrackGroup group = groups.get(i); int[] adaptiveTracks = getAdaptiveVideoTracksForGroup(group, formatSupport[i], allowMixedMimeTypes, requiredAdaptiveSupport, params.maxVideoWidth, params.maxVideoHeight, params.maxVideoBitrate, params.viewportWidth, params.viewportHeight, params.viewportOrientationMayChange); if (adaptiveTracks.length > 0) { return Assertions.checkNotNull(adaptiveTrackSelectionFactory) .createTrackSelection(group, bandwidthMeter, adaptiveTracks); } } return null; }
Example #18
Source File: PlayerActivity.java From leafpicrevived with GNU General Public License v3.0 | 5 votes |
@Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(com.alienpants.leafpicrevived.R.menu.menu_video_player, menu); MappedTrackInfo mappedTrackInfo = trackSelector.getCurrentMappedTrackInfo(); if (player != null && mappedTrackInfo != null) { for (int i = 0; i < mappedTrackInfo.length; i++) { TrackGroupArray trackGroups = mappedTrackInfo.getTrackGroups(i); if (trackGroups.length != 0) { switch (player.getRendererType(i)) { case C.TRACK_TYPE_AUDIO: menu.findItem(R.id.audio_stuff).setVisible(true); audio = i; break; case C.TRACK_TYPE_VIDEO: menu.findItem(R.id.video_stuff).setVisible(true); video = i; break; case C.TRACK_TYPE_TEXT: menu.findItem(R.id.text_stuff).setVisible(true); text = i; break; } } } } MenuItem loop = menu.findItem(R.id.loop_video); loop.setChecked(Prefs.getLoopVideo()); return true; }
Example #19
Source File: DefaultTrackSelector.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
private static boolean areSelectionOverridesEqual( SparseArray<Map<TrackGroupArray, SelectionOverride>> first, SparseArray<Map<TrackGroupArray, SelectionOverride>> second) { int firstSize = first.size(); if (second.size() != firstSize) { return false; } for (int indexInFirst = 0; indexInFirst < firstSize; indexInFirst++) { int indexInSecond = second.indexOfKey(first.keyAt(indexInFirst)); if (indexInSecond < 0 || !areSelectionOverridesEqual( first.valueAt(indexInFirst), second.valueAt(indexInSecond))) { return false; } } return true; }
Example #20
Source File: ExoMediaPlayer.java From ExoMedia with Apache License 2.0 | 5 votes |
protected ExoPlayerRendererTracksInfo getExoPlayerTracksInfo(@NonNull RendererType type, int groupIndex, MappingTrackSelector.MappedTrackInfo mappedTrackInfo) { // holder for the all exo player renderer track indexes of the specified renderer type List<Integer> exoPlayerRendererTrackIndexes = new ArrayList<>(); // the exoplayer renderer track index related to the specified group index int exoPlayerRendererTrackIndex = C.INDEX_UNSET; // the corrected exoplayer group index int exoPlayerRendererTrackGroupIndex = C.INDEX_UNSET; int skippedRenderersGroupsCount = 0; if (mappedTrackInfo != null) { for (int rendererIndex = 0; rendererIndex < mappedTrackInfo.getRendererCount(); rendererIndex++) { int exoPlayerRendererType = mappedTrackInfo.getRendererType(rendererIndex); if (type == getExoMediaRendererType(exoPlayerRendererType)) { exoPlayerRendererTrackIndexes.add(rendererIndex); TrackGroupArray trackGroups = mappedTrackInfo.getTrackGroups(rendererIndex); if (skippedRenderersGroupsCount + trackGroups.length > groupIndex) { if (exoPlayerRendererTrackIndex == C.INDEX_UNSET) { // if the groupIndex belongs to the current exo player renderer exoPlayerRendererTrackIndex = rendererIndex; exoPlayerRendererTrackGroupIndex = groupIndex - skippedRenderersGroupsCount; } } else { skippedRenderersGroupsCount += trackGroups.length; } } } } return new ExoPlayerRendererTracksInfo(exoPlayerRendererTrackIndexes, exoPlayerRendererTrackIndex, exoPlayerRendererTrackGroupIndex); }
Example #21
Source File: DefaultTrackSelector.java From Telegram with GNU General Public License v2.0 | 5 votes |
@Nullable private static TrackSelection.Definition selectAdaptiveVideoTrack( TrackGroupArray groups, int[][] formatSupport, int mixedMimeTypeAdaptationSupports, Parameters params) { int requiredAdaptiveSupport = params.allowVideoNonSeamlessAdaptiveness ? (RendererCapabilities.ADAPTIVE_NOT_SEAMLESS | RendererCapabilities.ADAPTIVE_SEAMLESS) : RendererCapabilities.ADAPTIVE_SEAMLESS; boolean allowMixedMimeTypes = params.allowVideoMixedMimeTypeAdaptiveness && (mixedMimeTypeAdaptationSupports & requiredAdaptiveSupport) != 0; for (int i = 0; i < groups.length; i++) { TrackGroup group = groups.get(i); int[] adaptiveTracks = getAdaptiveVideoTracksForGroup( group, formatSupport[i], allowMixedMimeTypes, requiredAdaptiveSupport, params.maxVideoWidth, params.maxVideoHeight, params.maxVideoFrameRate, params.maxVideoBitrate, params.viewportWidth, params.viewportHeight, params.viewportOrientationMayChange); if (adaptiveTracks.length > 0) { return new TrackSelection.Definition(group, adaptiveTracks); } } return null; }
Example #22
Source File: ExoPlayerAudioTrackSelector.java From no-player with Apache License 2.0 | 5 votes |
public AudioTracks getAudioTracks(RendererTypeRequester rendererTypeRequester) { TrackGroupArray trackGroups = trackSelector.trackGroups(AUDIO, rendererTypeRequester); List<PlayerAudioTrack> audioTracks = new ArrayList<>(); for (int groupIndex = 0; groupIndex < trackGroups.length; groupIndex++) { if (trackSelector.supportsTrackSwitching(AUDIO, rendererTypeRequester, trackGroups, groupIndex)) { TrackGroup trackGroup = trackGroups.get(groupIndex); for (int formatIndex = 0; formatIndex < trackGroup.length; formatIndex++) { Format format = trackGroup.getFormat(formatIndex); PlayerAudioTrack playerAudioTrack = new PlayerAudioTrack( groupIndex, formatIndex, format.id, format.language, format.sampleMimeType, format.channelCount, format.bitrate, AudioTrackType.from(format.selectionFlags) ); audioTracks.add(playerAudioTrack); } } } return AudioTracks.from(audioTracks); }
Example #23
Source File: DefaultTrackSelector.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
/** * Clears all track selection overrides for the specified renderer. * * @param rendererIndex The renderer index. */ public final ParametersBuilder clearSelectionOverrides(int rendererIndex) { Map<TrackGroupArray, SelectionOverride> overrides = selectionOverrides.get(rendererIndex); if (overrides == null || overrides.isEmpty()) { // Nothing to clear. return this; } selectionOverrides.remove(rendererIndex); return this; }
Example #24
Source File: LiveVideoPlayerActivity.java From LiveVideoBroadcaster with Apache License 2.0 | 5 votes |
@Override public void onTracksChanged(TrackGroupArray trackGroups, TrackSelectionArray trackSelections) { MappedTrackInfo mappedTrackInfo = trackSelector.getCurrentMappedTrackInfo(); if (mappedTrackInfo != null) { if (mappedTrackInfo.getTrackTypeRendererSupport(C.TRACK_TYPE_VIDEO) == MappedTrackInfo.RENDERER_SUPPORT_UNSUPPORTED_TRACKS) { showToast(R.string.error_unsupported_video); } if (mappedTrackInfo.getTrackTypeRendererSupport(C.TRACK_TYPE_AUDIO) == MappedTrackInfo.RENDERER_SUPPORT_UNSUPPORTED_TRACKS) { showToast(R.string.error_unsupported_audio); } } }
Example #25
Source File: DefaultLoadControl.java From K-Sonic with MIT License | 5 votes |
@Override public void onTracksSelected(Renderer[] renderers, TrackGroupArray trackGroups, TrackSelectionArray trackSelections) { targetBufferSize = 0; for (int i = 0; i < renderers.length; i++) { if (trackSelections.get(i) != null) { targetBufferSize += Util.getDefaultBufferSize(renderers[i].getTrackType()); } } allocator.setTargetBufferSize(targetBufferSize); }
Example #26
Source File: ExoPlayerImpl.java From Telegram with GNU General Public License v2.0 | 5 votes |
private PlaybackInfo getResetPlaybackInfo( boolean resetPosition, boolean resetState, int playbackState) { if (resetPosition) { maskingWindowIndex = 0; maskingPeriodIndex = 0; maskingWindowPositionMs = 0; } else { maskingWindowIndex = getCurrentWindowIndex(); maskingPeriodIndex = getCurrentPeriodIndex(); maskingWindowPositionMs = getCurrentPosition(); } // Also reset period-based PlaybackInfo positions if resetting the state. resetPosition = resetPosition || resetState; MediaPeriodId mediaPeriodId = resetPosition ? playbackInfo.getDummyFirstMediaPeriodId(shuffleModeEnabled, window) : playbackInfo.periodId; long startPositionUs = resetPosition ? 0 : playbackInfo.positionUs; long contentPositionUs = resetPosition ? C.TIME_UNSET : playbackInfo.contentPositionUs; return new PlaybackInfo( resetState ? Timeline.EMPTY : playbackInfo.timeline, resetState ? null : playbackInfo.manifest, mediaPeriodId, startPositionUs, contentPositionUs, playbackState, /* isLoading= */ false, resetState ? TrackGroupArray.EMPTY : playbackInfo.trackGroups, resetState ? emptyTrackSelectorResult : playbackInfo.trackSelectorResult, mediaPeriodId, startPositionUs, /* totalBufferedDurationUs= */ 0, startPositionUs); }
Example #27
Source File: DefaultTrackSelector.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
/** * Called by {@link #selectAllTracks(MappedTrackInfo, int[][][], int[], Parameters)} to create a * {@link TrackSelection} for a renderer whose type is neither video, audio or text. * * @param trackType The type of the renderer. * @param groups The {@link TrackGroupArray} mapped to the renderer. * @param formatSupport The result of {@link RendererCapabilities#supportsFormat} for each mapped * track, indexed by track group index and track index (in that order). * @param params The selector's current constraint parameters. * @return The {@link TrackSelection} for the renderer, or null if no selection was made. * @throws ExoPlaybackException If an error occurs while selecting the tracks. */ protected @Nullable TrackSelection selectOtherTrack( int trackType, TrackGroupArray groups, int[][] formatSupport, Parameters params) throws ExoPlaybackException { TrackGroup selectedGroup = null; int selectedTrackIndex = 0; int selectedTrackScore = 0; for (int groupIndex = 0; groupIndex < groups.length; groupIndex++) { TrackGroup trackGroup = groups.get(groupIndex); int[] trackFormatSupport = formatSupport[groupIndex]; for (int trackIndex = 0; trackIndex < trackGroup.length; trackIndex++) { if (isSupported(trackFormatSupport[trackIndex], params.exceedRendererCapabilitiesIfNecessary)) { Format format = trackGroup.getFormat(trackIndex); boolean isDefault = (format.selectionFlags & C.SELECTION_FLAG_DEFAULT) != 0; int trackScore = isDefault ? 2 : 1; if (isSupported(trackFormatSupport[trackIndex], false)) { trackScore += WITHIN_RENDERER_CAPABILITIES_BONUS; } if (trackScore > selectedTrackScore) { selectedGroup = trackGroup; selectedTrackIndex = trackIndex; selectedTrackScore = trackScore; } } } } return selectedGroup == null ? null : new FixedTrackSelection(selectedGroup, selectedTrackIndex); }
Example #28
Source File: PostRecyclerViewAdapter.java From Infinity-For-Reddit with GNU Affero General Public License v3.0 | 5 votes |
@Override public void initialize(@NonNull Container container, @NonNull PlaybackInfo playbackInfo) { if (helper == null) { helper = new ExoPlayerViewHelper(this, mediaUri, null, mExoCreator); helper.addEventListener(new Playable.EventListener() { @Override public void onTracksChanged(TrackGroupArray trackGroups, TrackSelectionArray trackSelections) { if (!trackGroups.isEmpty()) { for (int i = 0; i < trackGroups.length; i++) { String mimeType = trackGroups.get(i).getFormat(0).sampleMimeType; if (mimeType != null && mimeType.contains("audio")) { helper.setVolume(volume); muteButton.setVisibility(View.VISIBLE); if (volume != 0f) { muteButton.setImageDrawable(mActivity.getDrawable(R.drawable.ic_unmute_white_rounded_18dp)); } else { muteButton.setImageDrawable(mActivity.getDrawable(R.drawable.ic_mute_white_rounded_18dp)); } break; } } } else { muteButton.setVisibility(View.GONE); } } @Override public void onMetadata(Metadata metadata) { } @Override public void onCues(List<Cue> cues) { } }); } helper.initialize(container, playbackInfo); }
Example #29
Source File: DefaultLoadControl.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
@Override public void onTracksSelected(Renderer[] renderers, TrackGroupArray trackGroups, TrackSelectionArray trackSelections) { hasVideo = hasVideo(renderers, trackSelections); targetBufferSize = targetBufferBytesOverwrite == C.LENGTH_UNSET ? calculateTargetBufferSize(renderers, trackSelections) : targetBufferBytesOverwrite; allocator.setTargetBufferSize(targetBufferSize); }
Example #30
Source File: MappingTrackSelector.java From K-Sonic with MIT License | 5 votes |
/** * Clears all track selection override for the specified renderer. * * @param rendererIndex The renderer index. */ public final void clearSelectionOverrides(int rendererIndex) { Map<TrackGroupArray, ?> overrides = selectionOverrides.get(rendererIndex); if (overrides == null || overrides.isEmpty()) { // Nothing to clear. return; } selectionOverrides.remove(rendererIndex); invalidate(); }