本文整理匯總了Java中com.google.android.exoplayer2.source.MediaSource.prepareSource方法的典型用法代碼示例。如果您正苦於以下問題:Java MediaSource.prepareSource方法的具體用法?Java MediaSource.prepareSource怎麽用?Java MediaSource.prepareSource使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.google.android.exoplayer2.source.MediaSource
的用法示例。
在下文中一共展示了MediaSource.prepareSource方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: prepareInternal
import com.google.android.exoplayer2.source.MediaSource; //導入方法依賴的package包/類
private void prepareInternal(MediaSource mediaSource, boolean resetPosition) {
pendingPrepareCount++;
resetInternal(true);
loadControl.onPrepared();
if (resetPosition) {
playbackInfo = new PlaybackInfo(null, null, 0, C.TIME_UNSET);
} else {
// The new start position is the current playback position.
playbackInfo = new PlaybackInfo(null, null, playbackInfo.periodId, playbackInfo.positionUs,
playbackInfo.contentPositionUs);
}
this.mediaSource = mediaSource;
mediaSource.prepareSource(player, true, this);
setState(Player.STATE_BUFFERING);
handler.sendEmptyMessage(MSG_DO_SOME_WORK);
}
示例2: prepareInternal
import com.google.android.exoplayer2.source.MediaSource; //導入方法依賴的package包/類
private void prepareInternal(MediaSource mediaSource, boolean resetPosition) {
eventHandler.sendEmptyMessage(MSG_PREPARE_ACK);
resetInternal(true);
loadControl.onPrepared();
if (resetPosition) {
playbackInfo = new PlaybackInfo(0, C.TIME_UNSET);
}
this.mediaSource = mediaSource;
mediaSource.prepareSource(player, true, this);
setState(ExoPlayer.STATE_BUFFERING);
handler.sendEmptyMessage(MSG_DO_SOME_WORK);
}
示例3: prepareInternal
import com.google.android.exoplayer2.source.MediaSource; //導入方法依賴的package包/類
private void prepareInternal(MediaSource mediaSource, boolean resetPosition) {
resetInternal(true);
loadControl.onPrepared();
if (resetPosition) {
playbackInfo = new PlaybackInfo(0, C.TIME_UNSET);
}
this.mediaSource = mediaSource;
mediaSource.prepareSource(player, true, this);
setState(ExoPlayer.STATE_BUFFERING);
handler.sendEmptyMessage(MSG_DO_SOME_WORK);
}
示例4: prepareInternal
import com.google.android.exoplayer2.source.MediaSource; //導入方法依賴的package包/類
private void prepareInternal(MediaSource mediaSource, boolean resetPosition)
throws ExoPlaybackException {
resetInternal();
loadControl.onPrepared();
if (resetPosition) {
playbackInfo = new PlaybackInfo(0, C.TIME_UNSET);
}
this.mediaSource = mediaSource;
mediaSource.prepareSource(this);
setState(ExoPlayer.STATE_BUFFERING);
handler.sendEmptyMessage(MSG_DO_SOME_WORK);
}
示例5: createPeriod
import com.google.android.exoplayer2.source.MediaSource; //導入方法依賴的package包/類
@Override
public MediaPeriod createPeriod(MediaPeriodId id, Allocator allocator) {
if (adPlaybackState.adGroupCount > 0 && id.isAd()) {
final int adGroupIndex = id.adGroupIndex;
final int adIndexInAdGroup = id.adIndexInAdGroup;
if (adGroupMediaSources[adGroupIndex].length <= adIndexInAdGroup) {
Uri adUri = adPlaybackState.adUris[id.adGroupIndex][id.adIndexInAdGroup];
final MediaSource adMediaSource =
adMediaSourceFactory.createMediaSource(adUri, eventHandler, eventListener);
int oldAdCount = adGroupMediaSources[id.adGroupIndex].length;
if (adIndexInAdGroup >= oldAdCount) {
int adCount = adIndexInAdGroup + 1;
adGroupMediaSources[adGroupIndex] =
Arrays.copyOf(adGroupMediaSources[adGroupIndex], adCount);
adDurationsUs[adGroupIndex] = Arrays.copyOf(adDurationsUs[adGroupIndex], adCount);
Arrays.fill(adDurationsUs[adGroupIndex], oldAdCount, adCount, C.TIME_UNSET);
}
adGroupMediaSources[adGroupIndex][adIndexInAdGroup] = adMediaSource;
deferredMediaPeriodByAdMediaSource.put(adMediaSource, new ArrayList<DeferredMediaPeriod>());
adMediaSource.prepareSource(player, false, new MediaSource.Listener() {
@Override
public void onSourceInfoRefreshed(MediaSource source, Timeline timeline,
@Nullable Object manifest) {
onAdSourceInfoRefreshed(adMediaSource, adGroupIndex, adIndexInAdGroup, timeline);
}
});
}
MediaSource mediaSource = adGroupMediaSources[adGroupIndex][adIndexInAdGroup];
DeferredMediaPeriod deferredMediaPeriod =
new DeferredMediaPeriod(mediaSource, new MediaPeriodId(0), allocator);
List<DeferredMediaPeriod> mediaPeriods = deferredMediaPeriodByAdMediaSource.get(mediaSource);
if (mediaPeriods == null) {
deferredMediaPeriod.createPeriod();
} else {
// Keep track of the deferred media period so it can be populated with the real media period
// when the source's info becomes available.
mediaPeriods.add(deferredMediaPeriod);
}
return deferredMediaPeriod;
} else {
DeferredMediaPeriod mediaPeriod = new DeferredMediaPeriod(contentMediaSource, id, allocator);
mediaPeriod.createPeriod();
return mediaPeriod;
}
}