本文整理汇总了Java中com.google.android.exoplayer2.PlaybackParameters类的典型用法代码示例。如果您正苦于以下问题:Java PlaybackParameters类的具体用法?Java PlaybackParameters怎么用?Java PlaybackParameters使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PlaybackParameters类属于com.google.android.exoplayer2包,在下文中一共展示了PlaybackParameters类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handlePrepareRequest
import com.google.android.exoplayer2.PlaybackParameters; //导入依赖的package包/类
public void handlePrepareRequest() {
mPendingAutoContinue = false;
if (mMediaMetadata != null) {
final MediaId id = MediaProvider.getInstance().getMediaId(mMediaMetadata.getDescription().getMediaId());
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (id.type == MediaId.TYPE_AUDIO)
mPlayback.setPlaybackParams(new PlaybackParameters(mServiceCallback.getAudioSpeed(), 1));
else
mPlayback.setPlaybackParams(PlaybackParameters.DEFAULT);
}
mServiceCallback.onPlaybackPrepare(id);
mPlayback.prepare(mMediaMetadata);
mHandler.removeMessages(TIMER_COUNTDOWN);
mHandler.removeMessages(TIMER_TIMING);
if (mQueue != null && !mQueue.setMetadata(mMediaMetadata)) {
mQueue = null;
mServiceCallback.onQueue(null);
}
}
}
示例2: setPlaybackParams
import com.google.android.exoplayer2.PlaybackParameters; //导入依赖的package包/类
@Override
public void setPlaybackParams(PlaybackParameters playbackParams) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (mMediaPlayer == null || !mPrepared) {
mPlaybackParams = new PlaybackParams().setSpeed(playbackParams.speed).setPitch(playbackParams.pitch);
} else {
mMediaPlayer.setPlaybackParams(new PlaybackParams().setSpeed(playbackParams.speed).setPitch(playbackParams.pitch));
if (mState != PlaybackStateCompat.STATE_PLAYING && mMediaPlayer.isPlaying()) {
mState = PlaybackStateCompat.STATE_PLAYING;
}
if (mCallback != null) {
mCallback.onPlaybackStatusChanged(mState);
}
}
}
}
示例3: setPlaybackParameters
import com.google.android.exoplayer2.PlaybackParameters; //导入依赖的package包/类
@Override
public PlaybackParameters setPlaybackParameters(PlaybackParameters playbackParameters) {
// Store the current position as the new base, in case the playback speed has changed.
if (started) {
setPositionUs(getPositionUs());
}
this.playbackParameters = playbackParameters;
return playbackParameters;
}
示例4: AudioTrack
import com.google.android.exoplayer2.PlaybackParameters; //导入依赖的package包/类
/**
* @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 audioProcessors An array of {@link AudioProcessor}s that will process PCM audio before
* output. May be empty.
* @param listener Listener for audio track events.
*/
public AudioTrack(AudioCapabilities audioCapabilities, AudioProcessor[] audioProcessors,
Listener listener) {
this.audioCapabilities = audioCapabilities;
this.listener = listener;
releasingConditionVariable = new ConditionVariable(true);
if (Util.SDK_INT >= 18) {
try {
getLatencyMethod =
android.media.AudioTrack.class.getMethod("getLatency", (Class<?>[]) null);
} catch (NoSuchMethodException e) {
// There's no guarantee this method exists. Do nothing.
}
}
if (Util.SDK_INT >= 19) {
audioTrackUtil = new AudioTrackUtilV19();
} else {
audioTrackUtil = new AudioTrackUtil();
}
channelMappingAudioProcessor = new ChannelMappingAudioProcessor();
sonicAudioProcessor = new SonicAudioProcessor();
availableAudioProcessors = new AudioProcessor[3 + audioProcessors.length];
availableAudioProcessors[0] = new ResamplingAudioProcessor();
availableAudioProcessors[1] = channelMappingAudioProcessor;
System.arraycopy(audioProcessors, 0, availableAudioProcessors, 2, audioProcessors.length);
availableAudioProcessors[2 + audioProcessors.length] = sonicAudioProcessor;
playheadOffsets = new long[MAX_PLAYHEAD_OFFSET_COUNT];
volume = 1.0f;
startMediaTimeState = START_NOT_SET;
streamType = C.STREAM_TYPE_DEFAULT;
audioSessionId = C.AUDIO_SESSION_ID_UNSET;
playbackParameters = PlaybackParameters.DEFAULT;
drainingAudioProcessorIndex = C.INDEX_UNSET;
this.audioProcessors = new AudioProcessor[0];
outputBuffers = new ByteBuffer[0];
playbackParametersCheckpoints = new LinkedList<>();
}
示例5: handlePlayRequest
import com.google.android.exoplayer2.PlaybackParameters; //导入依赖的package包/类
public void handlePlayRequest() {
mPendingAutoContinue = false;
if (mMediaMetadata != null) {
final MediaId id = MediaProvider.getInstance().getMediaId(mMediaMetadata.getDescription().getMediaId());
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (id.type == MediaId.TYPE_AUDIO)
mPlayback.setPlaybackParams(new PlaybackParameters(mServiceCallback.getAudioSpeed(), 1));
else
mPlayback.setPlaybackParams(PlaybackParameters.DEFAULT);
}
mServiceCallback.onPlaybackStart(id);
mServiceCallback.onNotificationRequired();
mPlayback.start();
mPlayback.play(mMediaMetadata);
if (mTimer > -1) {
mHandler.removeMessages(TIMER_COUNTDOWN);
mHandler.sendEmptyMessageDelayed(TIMER_COUNTDOWN, ONE_SECOND);
}
if (mPlayback.getTiming() != null) {
mHandler.removeMessages(TIMER_TIMING);
mHandler.sendEmptyMessageDelayed(TIMER_TIMING, ONE_SECOND);
}
if (mQueue != null && !mQueue.setMetadata(mMediaMetadata)) {
mQueue = null;
mServiceCallback.onQueue(null);
}
}
}
示例6: onCustomAction
import com.google.android.exoplayer2.PlaybackParameters; //导入依赖的package包/类
@Override
public void onCustomAction(@NonNull String action, Bundle extras) {
switch (action) {
case MediaService.ACTION_SET_SURFACE:
final long surfaceId = extras.getLong(MediaService.EXTRA_SURFACE_ID);
if (!extras.containsKey(MediaService.EXTRA_SURFACE)) {
mPlayback.setSurface(surfaceId, null);
} else {
final Surface surface = extras.getParcelable(MediaService.EXTRA_SURFACE);
mPlayback.setSurface(surfaceId, surface);
}
break;
case MediaService.ACTION_SET_SPEED:
final float speed = extras.getFloat(MediaService.EXTRA_SPEED);
mServiceCallback.onSpeedSet(speed);
mPlayback.setPlaybackParams(new PlaybackParameters(speed, 1));
break;
case MediaService.ACTION_SET_TIMER:
mTimer = extras.getLong(MediaService.EXTRA_TIMER);
mHandler.removeMessages(TIMER_COUNTDOWN);
if (mTimer != -1)
mHandler.sendEmptyMessageDelayed(TIMER_COUNTDOWN, ONE_SECOND);
mServiceCallback.onTimerCount(mTimer);
break;
case MediaService.ACTION_SET_AUTO_CONTINUE:
final boolean autoContinue = extras.getBoolean(MediaService.EXTRA_AUTO_CONTINUE);
mServiceCallback.onAutoContinueSet(autoContinue);
break;
default:
break;
}
}
示例7: setPlaybackParams
import com.google.android.exoplayer2.PlaybackParameters; //导入依赖的package包/类
@Override
public void setPlaybackParams(PlaybackParameters playbackParams) {
mPlaybackParams = playbackParams;
if (mMediaPlayer != null)
mMediaPlayer.setPlaybackParameters(playbackParams);
if (mCallback != null)
mCallback.onPlaybackStatusChanged(mState);
}
示例8: setSpeed
import com.google.android.exoplayer2.PlaybackParameters; //导入依赖的package包/类
/**
* 倍速播放
*
* @param speed 倍速播放,默认为1
* @param pitch 音量缩放,默认为1,修改会导致声音变调
*/
public void setSpeed(@Size(min = 0) float speed, @Size(min = 0) float pitch) {
PlaybackParameters playbackParameters = new PlaybackParameters(speed, pitch);
mSpeedPlaybackParameters = playbackParameters;
if (mInternalPlayer != null) {
mInternalPlayer.setPlaybackParameters(playbackParameters);
}
}
示例9: onPlaybackParametersChanged
import com.google.android.exoplayer2.PlaybackParameters; //导入依赖的package包/类
@Override
public void onPlaybackParametersChanged(PlaybackParameters playbackParameters) {
HashMap<String, String> callingMethodParameters = new HashMap<>();
callingMethodParameters.put("playbackParameters", String.valueOf(playbackParameters));
infoListener.onNewInfo("onPlaybackParametersChanged", callingMethodParameters);
}
示例10: DefaultAudioSink
import com.google.android.exoplayer2.PlaybackParameters; //导入依赖的package包/类
/**
* @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 audioProcessors An array of {@link AudioProcessor}s that will process PCM audio before
* output. May be empty.
*/
public DefaultAudioSink(@Nullable AudioCapabilities audioCapabilities,
AudioProcessor[] audioProcessors) {
this.audioCapabilities = audioCapabilities;
releasingConditionVariable = new ConditionVariable(true);
if (Util.SDK_INT >= 18) {
try {
getLatencyMethod =
AudioTrack.class.getMethod("getLatency", (Class<?>[]) null);
} catch (NoSuchMethodException e) {
// There's no guarantee this method exists. Do nothing.
}
}
if (Util.SDK_INT >= 19) {
audioTrackUtil = new AudioTrackUtilV19();
} else {
audioTrackUtil = new AudioTrackUtil();
}
channelMappingAudioProcessor = new ChannelMappingAudioProcessor();
trimmingAudioProcessor = new TrimmingAudioProcessor();
sonicAudioProcessor = new SonicAudioProcessor();
availableAudioProcessors = new AudioProcessor[4 + audioProcessors.length];
availableAudioProcessors[0] = new ResamplingAudioProcessor();
availableAudioProcessors[1] = channelMappingAudioProcessor;
availableAudioProcessors[2] = trimmingAudioProcessor;
System.arraycopy(audioProcessors, 0, availableAudioProcessors, 3, audioProcessors.length);
availableAudioProcessors[3 + audioProcessors.length] = sonicAudioProcessor;
playheadOffsets = new long[MAX_PLAYHEAD_OFFSET_COUNT];
volume = 1.0f;
startMediaTimeState = START_NOT_SET;
audioAttributes = AudioAttributes.DEFAULT;
audioSessionId = C.AUDIO_SESSION_ID_UNSET;
playbackParameters = PlaybackParameters.DEFAULT;
drainingAudioProcessorIndex = C.INDEX_UNSET;
this.audioProcessors = new AudioProcessor[0];
outputBuffers = new ByteBuffer[0];
playbackParametersCheckpoints = new ArrayDeque<>();
}
示例11: onPlaybackParametersChanged
import com.google.android.exoplayer2.PlaybackParameters; //导入依赖的package包/类
@Override
public void onPlaybackParametersChanged(PlaybackParameters playbackParameters) {
}
示例12: onPlaybackParametersChanged
import com.google.android.exoplayer2.PlaybackParameters; //导入依赖的package包/类
@Override
public void onPlaybackParametersChanged(PlaybackParameters playbackParameters) {
Timber.e("播放: onPlaybackParametersChanged ");
}
示例13: onPlaybackParametersChanged
import com.google.android.exoplayer2.PlaybackParameters; //导入依赖的package包/类
@Override
public void onPlaybackParametersChanged(PlaybackParameters playbackParameters) {
// Do nothing.
}
示例14: Initialize
import com.google.android.exoplayer2.PlaybackParameters; //导入依赖的package包/类
/**
* Initializes the player.
*/
public void Initialize(final BA ba, String EventName) {
eventName = EventName.toLowerCase(BA.cul);
BandwidthMeter bandwidthMeter = new DefaultBandwidthMeter();
TrackSelection.Factory videoTrackSelectionFactory =
new AdaptiveTrackSelection.Factory(bandwidthMeter);
trackSelector =
new DefaultTrackSelector(videoTrackSelectionFactory);
player = ExoPlayerFactory.newSimpleInstance(BA.applicationContext, trackSelector);
player.addListener(new Player.EventListener() {
@Override
public void onLoadingChanged(boolean isLoading) {
}
@Override
public void onPlayerError(ExoPlaybackException error) {
ba.raiseEvent(SimpleExoPlayerWrapper.this, eventName + "_error", String.valueOf(error.getCause()));
}
@Override
public void onPlayerStateChanged(boolean playWhenReady,
int playbackState) {
if (playbackState != currentState) {
currentState = playbackState;
if (currentState == Player.STATE_ENDED)
ba.raiseEvent(SimpleExoPlayerWrapper.this, eventName + "_complete");
else if (currentState == Player.STATE_READY)
ba.raiseEvent(SimpleExoPlayerWrapper.this, eventName + "_ready");
}
}
@Override
public void onPositionDiscontinuity() {
}
@Override
public void onTimelineChanged(Timeline timeline, Object manifest) {
}
@Override
public void onPlaybackParametersChanged(
PlaybackParameters playbackParameters) {
// TODO Auto-generated method stub
}
@Override
public void onRepeatModeChanged(int repeatMode) {
}
@Override
public void onTracksChanged(TrackGroupArray trackGroups,
TrackSelectionArray trackSelections) {
ba.raiseEventFromUI(SimpleExoPlayerWrapper.this, eventName + "_trackchanged");
}
});
}
示例15: StandaloneMediaClock
import com.google.android.exoplayer2.PlaybackParameters; //导入依赖的package包/类
/**
* Creates a new standalone media clock.
*/
public StandaloneMediaClock() {
playbackParameters = PlaybackParameters.DEFAULT;
}