com.google.android.exoplayer2.PlaybackParameters Java Examples
The following examples show how to use
com.google.android.exoplayer2.PlaybackParameters.
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: DefaultAudioSink.java From Telegram-FOSS with GNU General Public License v2.0 | 6 votes |
@Override public PlaybackParameters setPlaybackParameters(PlaybackParameters playbackParameters) { if (configuration != null && !configuration.canApplyPlaybackParameters) { this.playbackParameters = PlaybackParameters.DEFAULT; return this.playbackParameters; } PlaybackParameters lastSetPlaybackParameters = afterDrainPlaybackParameters != null ? afterDrainPlaybackParameters : !playbackParametersCheckpoints.isEmpty() ? playbackParametersCheckpoints.getLast().playbackParameters : this.playbackParameters; if (!playbackParameters.equals(lastSetPlaybackParameters)) { if (isInitialized()) { // Drain the audio processors so we can determine the frame position at which the new // parameters apply. afterDrainPlaybackParameters = playbackParameters; } else { // Update the playback parameters now. They will be applied to the audio processors during // initialization. this.playbackParameters = playbackParameters; } } return this.playbackParameters; }
Example #2
Source File: DefaultAudioSink.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
@Override public PlaybackParameters setPlaybackParameters(PlaybackParameters playbackParameters) { if (isInitialized() && !canApplyPlaybackParameters) { this.playbackParameters = PlaybackParameters.DEFAULT; return this.playbackParameters; } PlaybackParameters lastSetPlaybackParameters = afterDrainPlaybackParameters != null ? afterDrainPlaybackParameters : !playbackParametersCheckpoints.isEmpty() ? playbackParametersCheckpoints.getLast().playbackParameters : this.playbackParameters; if (!playbackParameters.equals(lastSetPlaybackParameters)) { if (isInitialized()) { // Drain the audio processors so we can determine the frame position at which the new // parameters apply. afterDrainPlaybackParameters = playbackParameters; } else { // Update the playback parameters now. this.playbackParameters = audioProcessorChain.applyPlaybackParameters(playbackParameters); } } return this.playbackParameters; }
Example #3
Source File: DefaultAudioSink.java From MediaSDK with Apache License 2.0 | 5 votes |
@Override public PlaybackParameters getPlaybackParameters() { // Mask the already set parameters. return afterDrainPlaybackParameters != null ? afterDrainPlaybackParameters : !playbackParametersCheckpoints.isEmpty() ? playbackParametersCheckpoints.getLast().playbackParameters : playbackParameters; }
Example #4
Source File: AnalyticsCollector.java From MediaSDK with Apache License 2.0 | 5 votes |
@Override public final void onPlaybackParametersChanged(PlaybackParameters playbackParameters) { EventTime eventTime = generatePlayingMediaPeriodEventTime(); for (AnalyticsListener listener : listeners) { listener.onPlaybackParametersChanged(eventTime, playbackParameters); } }
Example #5
Source File: EventLogger.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
@Override public void onPlaybackParametersChanged( EventTime eventTime, PlaybackParameters playbackParameters) { logd( eventTime, "playbackParameters", Util.formatInvariant( "speed=%.2f, pitch=%.2f, skipSilence=%s", playbackParameters.speed, playbackParameters.pitch, playbackParameters.skipSilence)); }
Example #6
Source File: StandaloneMediaClock.java From Telegram with GNU General Public License v2.0 | 5 votes |
@Override public PlaybackParameters setPlaybackParameters(PlaybackParameters playbackParameters) { // Store the current position as the new base, in case the playback speed has changed. if (started) { resetPosition(getPositionUs()); } this.playbackParameters = playbackParameters; return playbackParameters; }
Example #7
Source File: DefaultAudioSink.java From Telegram with GNU General Public License v2.0 | 5 votes |
@Override public PlaybackParameters applyPlaybackParameters(PlaybackParameters playbackParameters) { silenceSkippingAudioProcessor.setEnabled(playbackParameters.skipSilence); return new PlaybackParameters( sonicAudioProcessor.setSpeed(playbackParameters.speed), sonicAudioProcessor.setPitch(playbackParameters.pitch), playbackParameters.skipSilence); }
Example #8
Source File: DefaultAudioSink.java From Telegram with GNU General Public License v2.0 | 5 votes |
/** * Creates a new default audio sink, optionally using float output for high resolution PCM and * with the specified {@code audioProcessorChain}. * * @param audioCapabilities The audio capabilities for playback on this device. May be null if the * default capabilities (no encoded audio passthrough support) should be assumed. * @param audioProcessorChain An {@link AudioProcessorChain} which is used to apply playback * parameters adjustments. The instance passed in must not be reused in other sinks. * @param enableConvertHighResIntPcmToFloat Whether to enable conversion of high resolution * integer PCM to 32-bit float for output, if possible. Functionality that uses 16-bit integer * audio processing (for example, speed and pitch adjustment) will not be available when float * output is in use. */ public DefaultAudioSink( @Nullable AudioCapabilities audioCapabilities, AudioProcessorChain audioProcessorChain, boolean enableConvertHighResIntPcmToFloat) { this.audioCapabilities = audioCapabilities; this.audioProcessorChain = Assertions.checkNotNull(audioProcessorChain); this.enableConvertHighResIntPcmToFloat = enableConvertHighResIntPcmToFloat; releasingConditionVariable = new ConditionVariable(true); audioTrackPositionTracker = new AudioTrackPositionTracker(new PositionTrackerListener()); channelMappingAudioProcessor = new ChannelMappingAudioProcessor(); trimmingAudioProcessor = new TrimmingAudioProcessor(); ArrayList<AudioProcessor> toIntPcmAudioProcessors = new ArrayList<>(); Collections.addAll( toIntPcmAudioProcessors, new ResamplingAudioProcessor(), channelMappingAudioProcessor, trimmingAudioProcessor); Collections.addAll(toIntPcmAudioProcessors, audioProcessorChain.getAudioProcessors()); toIntPcmAvailableAudioProcessors = toIntPcmAudioProcessors.toArray(new AudioProcessor[0]); toFloatPcmAvailableAudioProcessors = new AudioProcessor[] {new FloatResamplingAudioProcessor()}; volume = 1.0f; startMediaTimeState = START_NOT_SET; audioAttributes = AudioAttributes.DEFAULT; audioSessionId = C.AUDIO_SESSION_ID_UNSET; auxEffectInfo = new AuxEffectInfo(AuxEffectInfo.NO_AUX_EFFECT_ID, 0f); playbackParameters = PlaybackParameters.DEFAULT; drainingAudioProcessorIndex = C.INDEX_UNSET; activeAudioProcessors = new AudioProcessor[0]; outputBuffers = new ByteBuffer[0]; playbackParametersCheckpoints = new ArrayDeque<>(); }
Example #9
Source File: DefaultAudioSink.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
private void initialize() throws InitializationException { // If we're asynchronously releasing a previous audio track then we block until it has been // released. This guarantees that we cannot end up in a state where we have multiple audio // track instances. Without this guarantee it would be possible, in extreme cases, to exhaust // the shared memory that's available for audio track buffers. This would in turn cause the // initialization of the audio track to fail. releasingConditionVariable.block(); audioTrack = initializeAudioTrack(); int audioSessionId = audioTrack.getAudioSessionId(); if (enablePreV21AudioSessionWorkaround) { if (Util.SDK_INT < 21) { // The workaround creates an audio track with a two byte buffer on the same session, and // does not release it until this object is released, which keeps the session active. if (keepSessionIdAudioTrack != null && audioSessionId != keepSessionIdAudioTrack.getAudioSessionId()) { releaseKeepSessionIdAudioTrack(); } if (keepSessionIdAudioTrack == null) { keepSessionIdAudioTrack = initializeKeepSessionIdAudioTrack(audioSessionId); } } } if (this.audioSessionId != audioSessionId) { this.audioSessionId = audioSessionId; if (listener != null) { listener.onAudioSessionId(audioSessionId); } } playbackParameters = canApplyPlaybackParameters ? audioProcessorChain.applyPlaybackParameters(playbackParameters) : PlaybackParameters.DEFAULT; setupAudioProcessors(); audioTrackPositionTracker.setAudioTrack( audioTrack, outputEncoding, outputPcmFrameSize, bufferSize); setVolumeInternal(); }
Example #10
Source File: StandaloneMediaClock.java From MediaSDK with Apache License 2.0 | 5 votes |
@Override public void setPlaybackParameters(PlaybackParameters playbackParameters) { // Store the current position as the new base, in case the playback speed has changed. if (started) { resetPosition(getPositionUs()); } this.playbackParameters = playbackParameters; }
Example #11
Source File: DefaultAudioSink.java From MediaSDK with Apache License 2.0 | 5 votes |
/** * Creates a new default audio sink, optionally using float output for high resolution PCM and * with the specified {@code audioProcessorChain}. * * @param audioCapabilities The audio capabilities for playback on this device. May be null if the * default capabilities (no encoded audio passthrough support) should be assumed. * @param audioProcessorChain An {@link AudioProcessorChain} which is used to apply playback * parameters adjustments. The instance passed in must not be reused in other sinks. * @param enableConvertHighResIntPcmToFloat Whether to enable conversion of high resolution * integer PCM to 32-bit float for output, if possible. Functionality that uses 16-bit integer * audio processing (for example, speed and pitch adjustment) will not be available when float * output is in use. */ public DefaultAudioSink( @Nullable AudioCapabilities audioCapabilities, AudioProcessorChain audioProcessorChain, boolean enableConvertHighResIntPcmToFloat) { this.audioCapabilities = audioCapabilities; this.audioProcessorChain = Assertions.checkNotNull(audioProcessorChain); this.enableConvertHighResIntPcmToFloat = enableConvertHighResIntPcmToFloat; releasingConditionVariable = new ConditionVariable(true); audioTrackPositionTracker = new AudioTrackPositionTracker(new PositionTrackerListener()); channelMappingAudioProcessor = new ChannelMappingAudioProcessor(); trimmingAudioProcessor = new TrimmingAudioProcessor(); ArrayList<AudioProcessor> toIntPcmAudioProcessors = new ArrayList<>(); Collections.addAll( toIntPcmAudioProcessors, new ResamplingAudioProcessor(), channelMappingAudioProcessor, trimmingAudioProcessor); Collections.addAll(toIntPcmAudioProcessors, audioProcessorChain.getAudioProcessors()); toIntPcmAvailableAudioProcessors = toIntPcmAudioProcessors.toArray(new AudioProcessor[0]); toFloatPcmAvailableAudioProcessors = new AudioProcessor[] {new FloatResamplingAudioProcessor()}; volume = 1.0f; startMediaTimeState = START_NOT_SET; audioAttributes = AudioAttributes.DEFAULT; audioSessionId = C.AUDIO_SESSION_ID_UNSET; auxEffectInfo = new AuxEffectInfo(AuxEffectInfo.NO_AUX_EFFECT_ID, 0f); playbackParameters = PlaybackParameters.DEFAULT; drainingAudioProcessorIndex = C.INDEX_UNSET; activeAudioProcessors = new AudioProcessor[0]; outputBuffers = new ByteBuffer[0]; playbackParametersCheckpoints = new ArrayDeque<>(); }
Example #12
Source File: DefaultAudioSink.java From MediaSDK with Apache License 2.0 | 5 votes |
@Override public PlaybackParameters applyPlaybackParameters(PlaybackParameters playbackParameters) { silenceSkippingAudioProcessor.setEnabled(playbackParameters.skipSilence); return new PlaybackParameters( sonicAudioProcessor.setSpeed(playbackParameters.speed), sonicAudioProcessor.setPitch(playbackParameters.pitch), playbackParameters.skipSilence); }
Example #13
Source File: StandaloneMediaClock.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
@Override public PlaybackParameters setPlaybackParameters(PlaybackParameters playbackParameters) { // Store the current position as the new base, in case the playback speed has changed. if (started) { resetPosition(getPositionUs()); } this.playbackParameters = playbackParameters; return playbackParameters; }
Example #14
Source File: EventLogger.java From Telegram with GNU General Public License v2.0 | 5 votes |
@Override public void onPlaybackParametersChanged( EventTime eventTime, PlaybackParameters playbackParameters) { logd( eventTime, "playbackParameters", Util.formatInvariant( "speed=%.2f, pitch=%.2f, skipSilence=%s", playbackParameters.speed, playbackParameters.pitch, playbackParameters.skipSilence)); }
Example #15
Source File: DefaultAudioSink.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
/** * Creates a new default audio sink, optionally using float output for high resolution PCM and * with the specified {@code audioProcessorChain}. * * @param audioCapabilities The audio capabilities for playback on this device. May be null if the * default capabilities (no encoded audio passthrough support) should be assumed. * @param audioProcessorChain An {@link AudioProcessorChain} which is used to apply playback * parameters adjustments. The instance passed in must not be reused in other sinks. * @param enableConvertHighResIntPcmToFloat Whether to enable conversion of high resolution * integer PCM to 32-bit float for output, if possible. Functionality that uses 16-bit integer * audio processing (for example, speed and pitch adjustment) will not be available when float * output is in use. */ public DefaultAudioSink( @Nullable AudioCapabilities audioCapabilities, AudioProcessorChain audioProcessorChain, boolean enableConvertHighResIntPcmToFloat) { this.audioCapabilities = audioCapabilities; this.audioProcessorChain = Assertions.checkNotNull(audioProcessorChain); this.enableConvertHighResIntPcmToFloat = enableConvertHighResIntPcmToFloat; releasingConditionVariable = new ConditionVariable(true); audioTrackPositionTracker = new AudioTrackPositionTracker(new PositionTrackerListener()); channelMappingAudioProcessor = new ChannelMappingAudioProcessor(); trimmingAudioProcessor = new TrimmingAudioProcessor(); ArrayList<AudioProcessor> toIntPcmAudioProcessors = new ArrayList<>(); Collections.addAll( toIntPcmAudioProcessors, new ResamplingAudioProcessor(), channelMappingAudioProcessor, trimmingAudioProcessor); Collections.addAll(toIntPcmAudioProcessors, audioProcessorChain.getAudioProcessors()); toIntPcmAvailableAudioProcessors = toIntPcmAudioProcessors.toArray(new AudioProcessor[0]); toFloatPcmAvailableAudioProcessors = new AudioProcessor[] {new FloatResamplingAudioProcessor()}; volume = 1.0f; startMediaTimeState = START_NOT_SET; audioAttributes = AudioAttributes.DEFAULT; audioSessionId = C.AUDIO_SESSION_ID_UNSET; auxEffectInfo = new AuxEffectInfo(AuxEffectInfo.NO_AUX_EFFECT_ID, 0f); playbackParameters = PlaybackParameters.DEFAULT; drainingAudioProcessorIndex = C.INDEX_UNSET; activeAudioProcessors = new AudioProcessor[0]; outputBuffers = new ByteBuffer[0]; playbackParametersCheckpoints = new ArrayDeque<>(); }
Example #16
Source File: DefaultAudioSink.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
/** * Creates a new default audio sink, optionally using float output for high resolution PCM and * with the specified {@code audioProcessorChain}. * * @param audioCapabilities The audio capabilities for playback on this device. May be null if the * default capabilities (no encoded audio passthrough support) should be assumed. * @param audioProcessorChain An {@link AudioProcessorChain} which is used to apply playback * parameters adjustments. The instance passed in must not be reused in other sinks. * @param enableConvertHighResIntPcmToFloat Whether to enable conversion of high resolution * integer PCM to 32-bit float for output, if possible. Functionality that uses 16-bit integer * audio processing (for example, speed and pitch adjustment) will not be available when float * output is in use. */ public DefaultAudioSink( @Nullable AudioCapabilities audioCapabilities, AudioProcessorChain audioProcessorChain, boolean enableConvertHighResIntPcmToFloat) { this.audioCapabilities = audioCapabilities; this.audioProcessorChain = Assertions.checkNotNull(audioProcessorChain); this.enableConvertHighResIntPcmToFloat = enableConvertHighResIntPcmToFloat; releasingConditionVariable = new ConditionVariable(true); audioTrackPositionTracker = new AudioTrackPositionTracker(new PositionTrackerListener()); channelMappingAudioProcessor = new ChannelMappingAudioProcessor(); trimmingAudioProcessor = new TrimmingAudioProcessor(); ArrayList<AudioProcessor> toIntPcmAudioProcessors = new ArrayList<>(); Collections.addAll( toIntPcmAudioProcessors, new ResamplingAudioProcessor(), channelMappingAudioProcessor, trimmingAudioProcessor); Collections.addAll(toIntPcmAudioProcessors, audioProcessorChain.getAudioProcessors()); toIntPcmAvailableAudioProcessors = toIntPcmAudioProcessors.toArray(new AudioProcessor[toIntPcmAudioProcessors.size()]); toFloatPcmAvailableAudioProcessors = new AudioProcessor[] {new FloatResamplingAudioProcessor()}; volume = 1.0f; startMediaTimeState = START_NOT_SET; audioAttributes = AudioAttributes.DEFAULT; audioSessionId = C.AUDIO_SESSION_ID_UNSET; playbackParameters = PlaybackParameters.DEFAULT; drainingAudioProcessorIndex = C.INDEX_UNSET; activeAudioProcessors = new AudioProcessor[0]; outputBuffers = new ByteBuffer[0]; playbackParametersCheckpoints = new ArrayDeque<>(); }
Example #17
Source File: BackgroundAudioPlayer.java From flutter_exoplayer with MIT License | 5 votes |
@Override public void setPlaybackSpeed(float speed) { if (!this.released && this.speed != speed) { this.speed = speed; PlaybackParameters param = new PlaybackParameters(speed); player.setPlaybackParameters(param); } }
Example #18
Source File: ForegroundAudioPlayer.java From flutter_exoplayer with MIT License | 5 votes |
@Override public void setPlaybackSpeed(float speed) { if (!this.released && this.speed != speed) { this.speed = speed; PlaybackParameters param = new PlaybackParameters(speed); player.setPlaybackParameters(param); } }
Example #19
Source File: DefaultAudioSink.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
@Override public PlaybackParameters applyPlaybackParameters(PlaybackParameters playbackParameters) { silenceSkippingAudioProcessor.setEnabled(playbackParameters.skipSilence); return new PlaybackParameters( sonicAudioProcessor.setSpeed(playbackParameters.speed), sonicAudioProcessor.setPitch(playbackParameters.pitch), playbackParameters.skipSilence); }
Example #20
Source File: AnalyticsCollector.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
@Override public final void onPlaybackParametersChanged(PlaybackParameters playbackParameters) { EventTime eventTime = generatePlayingMediaPeriodEventTime(); for (AnalyticsListener listener : listeners) { listener.onPlaybackParametersChanged(eventTime, playbackParameters); } }
Example #21
Source File: AnalyticsCollector.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
@Override public final void onPlaybackParametersChanged(PlaybackParameters playbackParameters) { EventTime eventTime = generatePlayingMediaPeriodEventTime(); for (AnalyticsListener listener : listeners) { listener.onPlaybackParametersChanged(eventTime, playbackParameters); } }
Example #22
Source File: EventLogger.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
@Override public void onPlaybackParametersChanged( EventTime eventTime, PlaybackParameters playbackParameters) { logd( eventTime, "playbackParameters", Util.formatInvariant( "speed=%.2f, pitch=%.2f, skipSilence=%s", playbackParameters.speed, playbackParameters.pitch, playbackParameters.skipSilence)); }
Example #23
Source File: BrightcovePlayerView.java From react-native-brightcove-player with MIT License | 4 votes |
private void updatePlaybackRate() { ExoPlayer expPlayer = ((ExoPlayerVideoDisplayComponent) this.playerVideoView.getVideoDisplay()).getExoPlayer(); if (expPlayer != null) { expPlayer.setPlaybackParameters(new PlaybackParameters(playbackRate, 1f)); } }
Example #24
Source File: PlayerService.java From AndroidAudioExample with MIT License | 4 votes |
@Override public void onPlaybackParametersChanged(PlaybackParameters playbackParameters) { }
Example #25
Source File: OnCompletionForwarder.java From no-player with Apache License 2.0 | 4 votes |
@Override public void onPlaybackParametersChanged(PlaybackParameters playbackParameters) { // TODO: should we send? }
Example #26
Source File: EventLogger.java From GSYVideoPlayer with Apache License 2.0 | 4 votes |
@Override public void onPlaybackParametersChanged(PlaybackParameters playbackParameters) { Log.d(TAG, "playbackParameters " + String.format( "[speed=%.2f, pitch=%.2f]", playbackParameters.speed, playbackParameters.pitch)); }
Example #27
Source File: MediaCodecAudioRenderer.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
@Override public PlaybackParameters setPlaybackParameters(PlaybackParameters playbackParameters) { return audioSink.setPlaybackParameters(playbackParameters); }
Example #28
Source File: SimpleDecoderAudioRenderer.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
@Override public PlaybackParameters getPlaybackParameters() { return audioSink.getPlaybackParameters(); }
Example #29
Source File: ExoMediaPlayer.java From PlayerBase with Apache License 2.0 | 4 votes |
@Override public void onPlaybackParametersChanged(PlaybackParameters playbackParameters) { PLog.d(TAG,"onPlaybackParametersChanged : " + playbackParameters.toString()); }
Example #30
Source File: SimpleDecoderAudioRenderer.java From Telegram-FOSS with GNU General Public License v2.0 | 4 votes |
@Override public PlaybackParameters setPlaybackParameters(PlaybackParameters playbackParameters) { return audioSink.setPlaybackParameters(playbackParameters); }