android.media.PlaybackParams Java Examples
The following examples show how to use
android.media.PlaybackParams.
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: SimpleDecoderAudioRenderer.java From K-Sonic with MIT License | 6 votes |
@Override public void handleMessage(int messageType, Object message) throws ExoPlaybackException { switch (messageType) { case C.MSG_SET_VOLUME: audioTrack.setVolume((Float) message); break; case C.MSG_SET_PLAYBACK_PARAMS: audioTrack.setPlaybackParams((PlaybackParams) message); break; case C.MSG_SET_STREAM_TYPE: @C.StreamType int streamType = (Integer) message; audioTrack.setStreamType(streamType); break; default: super.handleMessage(messageType, message); break; } }
Example #2
Source File: TvInputManagerService.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
@Override public void timeShiftSetPlaybackParams(IBinder sessionToken, PlaybackParams params, int userId) { final int callingUid = Binder.getCallingUid(); final int resolvedUserId = resolveCallingUserId(Binder.getCallingPid(), callingUid, userId, "timeShiftSetPlaybackParams"); final long identity = Binder.clearCallingIdentity(); try { synchronized (mLock) { try { getSessionLocked(sessionToken, callingUid, resolvedUserId) .timeShiftSetPlaybackParams(params); } catch (RemoteException | SessionNotFoundException e) { Slog.e(TAG, "error in timeShiftSetPlaybackParams", e); } } } finally { Binder.restoreCallingIdentity(identity); } }
Example #3
Source File: MediaCodecAudioRenderer.java From K-Sonic with MIT License | 6 votes |
@Override public void handleMessage(int messageType, Object message) throws ExoPlaybackException { switch (messageType) { case C.MSG_SET_VOLUME: audioTrack.setVolume((Float) message); break; case C.MSG_SET_PLAYBACK_PARAMS: audioTrack.setPlaybackParams((PlaybackParams) message); break; case C.MSG_SET_STREAM_TYPE: @C.StreamType int streamType = (Integer) message; audioTrack.setStreamType(streamType); break; default: super.handleMessage(messageType, message); break; } }
Example #4
Source File: SimpleExoPlayer.java From K-Sonic with MIT License | 6 votes |
/** * Sets the {@link PlaybackParams} governing audio playback. * * @param params The {@link PlaybackParams}, or null to clear any previously set parameters. */ @TargetApi(23) public void setPlaybackParams(PlaybackParams params) { if (params != null) { // The audio renderers will call this on the playback thread to ensure they can query // parameters without failure. We do the same up front, which is redundant except that it // ensures an immediate call to getPlaybackParams will retrieve the instance with defaults // allowed, rather than this change becoming visible sometime later once the audio renderers // receive the parameters. params.allowDefaults(); playbackParamsHolder = new PlaybackParamsHolder(params); } else { playbackParamsHolder = null; } ExoPlayerMessage[] messages = new ExoPlayerMessage[audioRendererCount]; int count = 0; for (Renderer renderer : renderers) { if (renderer.getTrackType() == C.TRACK_TYPE_AUDIO) { messages[count++] = new ExoPlayerMessage(renderer, C.MSG_SET_PLAYBACK_PARAMS, params); } } player.sendMessages(messages); }
Example #5
Source File: SystemPlayerManager.java From GSYVideoPlayer with Apache License 2.0 | 6 votes |
private void setSpeed(float speed) { if (release) { return; } if (mediaPlayer != null && mediaPlayer.getInternalMediaPlayer() != null && mediaPlayer.isPlayable()) { try { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { PlaybackParams playbackParams = new PlaybackParams(); playbackParams.setSpeed(speed); mediaPlayer.getInternalMediaPlayer().setPlaybackParams(playbackParams); } else { Debuger.printfError(" not support setSpeed"); } } catch (Exception e) { e.printStackTrace(); } } }
Example #6
Source File: CumulusTvPlayer.java From CumulusTV with MIT License | 5 votes |
@RequiresApi(api = Build.VERSION_CODES.M) @Override public void setPlaybackParams(PlaybackParams params) { mSimpleExoPlayer.setPlaybackParams(params); mPlaybackSpeed = params.getSpeed(); if (DEBUG) { Log.d(TAG, "Set params " + params.toString()); } }
Example #7
Source File: AudioTrack.java From K-Sonic with MIT License | 5 votes |
@Override public void setPlaybackParams(PlaybackParams playbackParams) { playbackParams = (playbackParams != null ? playbackParams : new PlaybackParams()) .allowDefaults(); this.playbackParams = playbackParams; playbackSpeed = playbackParams.getSpeed(); maybeApplyPlaybackParams(); }
Example #8
Source File: SimpleSessionImpl.java From ChannelSurfer with MIT License | 5 votes |
@Override public void onTimeShiftSetPlaybackParams(PlaybackParams params) { if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { if (tvInputProvider instanceof TimeShiftable) { ((TimeShiftable) tvInputProvider).onMediaSetPlaybackParams(params); } } }
Example #9
Source File: NativeAudioPlayer.java From ExoMedia with Apache License 2.0 | 5 votes |
@Override public boolean setPlaybackSpeed(float speed) { // Marshmallow+ support setting the playback speed natively if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { PlaybackParams params = new PlaybackParams(); params.setSpeed(speed); mediaPlayer.setPlaybackParams(params); return true; } return false; }
Example #10
Source File: NativeVideoDelegate.java From ExoMedia with Apache License 2.0 | 5 votes |
public boolean setPlaybackSpeed(float speed) { // Marshmallow+ support setting the playback speed natively if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { PlaybackParams params = new PlaybackParams(); params.setSpeed(speed); mediaPlayer.setPlaybackParams(params); return true; } return false; }
Example #11
Source File: MediaPlayerImpl.java From MediaSDK with Apache License 2.0 | 5 votes |
@Override public void setSpeed(float speed) { if (Build.VERSION.SDK_INT > 23) { PlaybackParams params = new PlaybackParams(); params.setSpeed(speed); mPlayer.setPlaybackParams(params); } else { LogUtils.w("setSpeed is invalid."); } }
Example #12
Source File: DownloadService.java From Popeens-DSub with GNU General Public License v3.0 | 5 votes |
private synchronized void applyPlaybackParams(MediaPlayer mediaPlayer) { if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { float playbackSpeed = getPlaybackSpeed(); try { if (Math.abs(playbackSpeed - 1.0) > 0.01 || mediaPlayer.getPlaybackParams() != null) { PlaybackParams playbackParams = new PlaybackParams(); playbackParams.setSpeed(playbackSpeed); mediaPlayer.setPlaybackParams(playbackParams); } } catch(Exception e) { Log.e(TAG, "Error while applying media player params", e); } } }
Example #13
Source File: AndroidAudioPlayer.java From AntennaPod-AudioPlayer with Apache License 2.0 | 5 votes |
@Override public void setPitchStepsAdjustment(float pitchSteps) { if (Build.VERSION.SDK_INT < 23) { return; } PlaybackParams params = mp.getPlaybackParams(); params.setPitch(params.getPitch() + pitchSteps); mp.setPlaybackParams(params); }
Example #14
Source File: AndroidAudioPlayer.java From AntennaPod-AudioPlayer with Apache License 2.0 | 5 votes |
@Override public void setPlaybackPitch(float f) { Log.d(AMP_TAG, "setPlaybackPitch(" + f + ")"); if (Build.VERSION.SDK_INT < 23) { return; } PlaybackParams params = mp.getPlaybackParams(); params.setPitch(f); mp.setPlaybackParams(params); }
Example #15
Source File: AndroidAudioPlayer.java From AntennaPod-AudioPlayer with Apache License 2.0 | 5 votes |
@Override public void setPlaybackSpeed(float f) { Log.d(AMP_TAG, "setPlaybackSpeed(" + f + ")"); if (Build.VERSION.SDK_INT < 23) { return; } PlaybackParams params = mp.getPlaybackParams(); params.setSpeed(f); boolean isPaused = this.owningMediaPlayer.state == org.antennapod.audio.MediaPlayer.State.PAUSED; mp.setPlaybackParams(params); if (isPaused) { mp.pause(); } }
Example #16
Source File: BaseTvInputService.java From androidtv-sample-inputs with Apache License 2.0 | 5 votes |
@RequiresApi(api = Build.VERSION_CODES.M) @Override public void onTimeShiftSetPlaybackParams(PlaybackParams params) { if (params.getSpeed() != 1.0f) { mHandler.removeMessages(MSG_PLAY_AD); mDbHandler.removeCallbacks(mGetCurrentProgramRunnable); } if (DEBUG) { Log.d(TAG, "Set playback speed to " + params.getSpeed()); } if (getTvPlayer() != null) { getTvPlayer().setPlaybackParams(params); } }
Example #17
Source File: SimpleExoPlayer.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
/** * Sets the {@link PlaybackParams} governing audio playback. * * @deprecated Use {@link #setPlaybackParameters(PlaybackParameters)}. * @param params The {@link PlaybackParams}, or null to clear any previously set parameters. */ @Deprecated @TargetApi(23) public void setPlaybackParams(@Nullable PlaybackParams params) { PlaybackParameters playbackParameters; if (params != null) { params.allowDefaults(); playbackParameters = new PlaybackParameters(params.getSpeed(), params.getPitch()); } else { playbackParameters = null; } setPlaybackParameters(playbackParameters); }
Example #18
Source File: SimpleExoPlayer.java From Telegram with GNU General Public License v2.0 | 5 votes |
/** * Sets the {@link PlaybackParams} governing audio playback. * * @deprecated Use {@link #setPlaybackParameters(PlaybackParameters)}. * @param params The {@link PlaybackParams}, or null to clear any previously set parameters. */ @Deprecated @TargetApi(23) public void setPlaybackParams(@Nullable PlaybackParams params) { PlaybackParameters playbackParameters; if (params != null) { params.allowDefaults(); playbackParameters = new PlaybackParameters(params.getSpeed(), params.getPitch()); } else { playbackParameters = null; } setPlaybackParameters(playbackParameters); }
Example #19
Source File: SimpleExoPlayer.java From K-Sonic with MIT License | 5 votes |
public void setPlaybackSpeed(float speed) { this.speed = speed; if (Build.VERSION.SDK_INT >= 23) { PlaybackParams params = new PlaybackParams(); params.setSpeed(speed); setPlaybackParams(params); } else if (sonicMediaCodecAudioRenderer != null) { sonicMediaCodecAudioRenderer.setSonicSpeed(speed); } }
Example #20
Source File: SimpleExoPlayer.java From MediaSDK with Apache License 2.0 | 5 votes |
/** * Sets the {@link PlaybackParams} governing audio playback. * * @deprecated Use {@link #setPlaybackParameters(PlaybackParameters)}. * @param params The {@link PlaybackParams}, or null to clear any previously set parameters. */ @Deprecated @TargetApi(23) public void setPlaybackParams(@Nullable PlaybackParams params) { PlaybackParameters playbackParameters; if (params != null) { params.allowDefaults(); playbackParameters = new PlaybackParameters(params.getSpeed(), params.getPitch()); } else { playbackParameters = null; } setPlaybackParameters(playbackParameters); }
Example #21
Source File: SimpleExoPlayer.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
/** * Sets the {@link PlaybackParams} governing audio playback. * * @deprecated Use {@link #setPlaybackParameters(PlaybackParameters)}. * @param params The {@link PlaybackParams}, or null to clear any previously set parameters. */ @Deprecated @TargetApi(23) public void setPlaybackParams(@Nullable PlaybackParams params) { PlaybackParameters playbackParameters; if (params != null) { params.allowDefaults(); playbackParameters = new PlaybackParameters(params.getSpeed(), params.getPitch()); } else { playbackParameters = null; } setPlaybackParameters(playbackParameters); }
Example #22
Source File: JZMediaSystem.java From imsdk-android with MIT License | 5 votes |
@RequiresApi(api = Build.VERSION_CODES.M) @Override public void setSpeed(float speed) { PlaybackParams pp = mediaPlayer.getPlaybackParams(); pp.setSpeed(speed); mediaPlayer.setPlaybackParams(pp); }
Example #23
Source File: JZMediaSystemAssertFolder.java From imsdk-android with MIT License | 5 votes |
@RequiresApi(api = Build.VERSION_CODES.M) @Override public void setSpeed(float speed) { PlaybackParams pp = mediaPlayer.getPlaybackParams(); pp.setSpeed(speed); mediaPlayer.setPlaybackParams(pp); }
Example #24
Source File: SimpleExoPlayer.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
/** * Sets the {@link PlaybackParams} governing audio playback. * * @deprecated Use {@link #setPlaybackParameters(PlaybackParameters)}. * @param params The {@link PlaybackParams}, or null to clear any previously set parameters. */ @Deprecated @TargetApi(23) public void setPlaybackParams(@Nullable PlaybackParams params) { PlaybackParameters playbackParameters; if (params != null) { params.allowDefaults(); playbackParameters = new PlaybackParameters(params.getSpeed(), params.getPitch()); } else { playbackParameters = null; } setPlaybackParameters(playbackParameters); }
Example #25
Source File: BaseTvInputService.java From xipl with Apache License 2.0 | 5 votes |
@RequiresApi(api = Build.VERSION_CODES.M) @Override public void onTimeShiftSetPlaybackParams(PlaybackParams params) { if (params.getSpeed() != 1.0f) { mHandler.removeMessages(MSG_PLAY_AD); mDbHandler.removeCallbacks(mGetCurrentProgramRunnable); } if (DEBUG) { Log.d(TAG, "Set playback speed to " + params.getSpeed()); } if (getTvPlayer() != null) { getTvPlayer().setPlaybackParams(params); } }
Example #26
Source File: SimpleExoPlayer.java From K-Sonic with MIT License | 5 votes |
public void setPlaybackPitch(float pitch) { this.pitch = pitch; if (Build.VERSION.SDK_INT >= 23) { PlaybackParams params = new PlaybackParams(); params.setPitch(pitch); setPlaybackParams(params); } else if (sonicMediaCodecAudioRenderer != null) { sonicMediaCodecAudioRenderer.setSonicPitch(pitch); } }
Example #27
Source File: MockTvPlayer.java From xipl with Apache License 2.0 | 4 votes |
@RequiresApi(api = Build.VERSION_CODES.M) @Override public void setPlaybackParams(PlaybackParams params) { mMediaPlayer.setPlaybackParams(params); }
Example #28
Source File: MediaPlayerInputProvider.java From ChannelSurfer with MIT License | 4 votes |
@Override public void onMediaSetPlaybackParams(PlaybackParams playbackParams) { if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { mediaPlayer.setPlaybackParams(playbackParams); } }
Example #29
Source File: BaseTvInputService.java From xipl with Apache License 2.0 | 4 votes |
@Override public void onTimeShiftResume() { if (DEBUG) Log.d(TAG, "Resume playback of program"); mTimeShiftIsPaused = false; if (mCurrentProgram == null) { return; } if (!mPlayingRecordedProgram) { // If currently playing program content, past ad durations must be recalculated // based on getTvPlayer.getCurrentPosition(). mElapsedAdsTime = 0; mElapsedProgramTime = getTvPlayer().getCurrentPosition(); long elapsedProgramTimeAdjusted = mElapsedProgramTime + mCurrentProgram.getStartTimeUtcMillis(); if (mCurrentProgram.getInternalProviderData() != null) { List<Advertisement> ads = mCurrentProgram.getInternalProviderData().getAds(); // First, sort the ads in time order. TreeMap<Long, Long> scheduledAds = new TreeMap<>(); for (Advertisement ad : ads) { scheduledAds.put(ad.getStartTimeUtcMillis(), ad.getStopTimeUtcMillis()); } // Second, add up all ad times which should have played before the elapsed // program time. long programDurationPlayed = 0; long totalDurationPlayed = 0; for (Long adStartTime : scheduledAds.keySet()) { programDurationPlayed += adStartTime - totalDurationPlayed; if (programDurationPlayed < elapsedProgramTimeAdjusted) { long adDuration = scheduledAds.get(adStartTime) - adStartTime; mElapsedAdsTime += adDuration; totalDurationPlayed = programDurationPlayed + adDuration; } else { break; } } } else { Log.w( TAG, "Failed to get program provider data for " + mCurrentProgram.getTitle() + ". Try to do an EPG sync."); } mTimeShiftedPlaybackPosition = elapsedProgramTimeAdjusted + mElapsedAdsTime; scheduleNextAd(); scheduleNextProgram(); } if (getTvPlayer() != null) { getTvPlayer().play(); } // Resume and make sure media is playing at regular speed. if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { PlaybackParams normalParams = new PlaybackParams(); normalParams.setSpeed(1); onTimeShiftSetPlaybackParams(normalParams); } }
Example #30
Source File: MockTvPlayer.java From androidtv-sample-inputs with Apache License 2.0 | 4 votes |
@RequiresApi(api = Build.VERSION_CODES.M) @Override public void setPlaybackParams(PlaybackParams params) { mMediaPlayer.setPlaybackParams(params); }