Commit abc5c41f by olly Committed by Oliver Woodman

Provide setPlaybackParams convenience method.

It's not a comprehensive solution for setting the
playback speed because (a) it doesn't apply when
audio is disabled, and (b) we do some timestamp
interpolation in a few places where we assume real
time. However in practice it works pretty well and
most apps probably don't allow disabling of audio,
so I think it makes sense to expose it.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=123406605
parent 5cf7c2ec
......@@ -31,6 +31,7 @@ import android.annotation.TargetApi;
import android.content.Context;
import android.media.AudioManager;
import android.media.MediaCodec;
import android.media.PlaybackParams;
import android.os.Handler;
import android.util.Log;
import android.view.Surface;
......@@ -195,6 +196,22 @@ public final class SimpleExoPlayer implements ExoPlayer {
}
/**
* Sets {@link PlaybackParams} governing audio playback.
*
* @param params The {@link PlaybackParams}.
*/
public void setPlaybackParams(PlaybackParams params) {
ExoPlayerMessage[] messages = new ExoPlayerMessage[audioRendererCount];
int count = 0;
for (TrackRenderer renderer : renderers) {
if (renderer.getTrackType() == C.TRACK_TYPE_AUDIO) {
messages[count++] = new ExoPlayerMessage(renderer, C.MSG_SET_PLAYBACK_PARAMS, params);
}
}
player.sendMessages(messages);
}
/**
* @return The {@link BandwidthMeter} being used by the player.
*/
public BandwidthMeter getBandwidthMeter() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment