Search in sources :

Example 1 with StreamInfo

use of org.schabi.newpipe.extractor.stream.StreamInfo in project NewPipe by TeamNewPipe.

the class MediaSourceManager method maybeSync.

/*//////////////////////////////////////////////////////////////////////////
    // Metadata Synchronization
    //////////////////////////////////////////////////////////////////////////*/
private void maybeSync() {
    if (DEBUG)
        Log.d(TAG, "onPlaybackSynchronize() called.");
    final PlayQueueItem currentItem = playQueue.getItem();
    if (isBlocked.get() || !isPlaybackReady() || currentItem == null)
        return;
    final Consumer<StreamInfo> onSuccess = info -> syncInternal(currentItem, info);
    final Consumer<Throwable> onError = throwable -> syncInternal(currentItem, null);
    final Disposable sync = currentItem.getStream().observeOn(AndroidSchedulers.mainThread()).subscribe(onSuccess, onError);
    syncReactor.set(sync);
}
Also used : DynamicConcatenatingMediaSource(com.google.android.exoplayer2.source.DynamicConcatenatingMediaSource) ManagedMediaSource(org.schabi.newpipe.player.mediasource.ManagedMediaSource) ServiceHelper(org.schabi.newpipe.util.ServiceHelper) SerialDisposable(io.reactivex.disposables.SerialDisposable) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) NonNull(android.support.annotation.NonNull) Single(io.reactivex.Single) AndroidSchedulers(io.reactivex.android.schedulers.AndroidSchedulers) LoadedMediaSource(org.schabi.newpipe.player.mediasource.LoadedMediaSource) StreamInfo(org.schabi.newpipe.extractor.stream.StreamInfo) HashSet(java.util.HashSet) PlaceholderMediaSource(org.schabi.newpipe.player.mediasource.PlaceholderMediaSource) DEBUG(org.schabi.newpipe.playlist.PlayQueue.DEBUG) ShuffleOrder(com.google.android.exoplayer2.source.ShuffleOrder) MoveEvent(org.schabi.newpipe.playlist.events.MoveEvent) Observable(io.reactivex.Observable) PlayQueueItem(org.schabi.newpipe.playlist.PlayQueueItem) Subscriber(org.reactivestreams.Subscriber) Log(android.util.Log) MediaSource(com.google.android.exoplayer2.source.MediaSource) RemoveEvent(org.schabi.newpipe.playlist.events.RemoveEvent) Set(java.util.Set) FailedMediaSource(org.schabi.newpipe.player.mediasource.FailedMediaSource) Consumer(io.reactivex.functions.Consumer) TimeUnit(java.util.concurrent.TimeUnit) ReorderEvent(org.schabi.newpipe.playlist.events.ReorderEvent) CompositeDisposable(io.reactivex.disposables.CompositeDisposable) Disposable(io.reactivex.disposables.Disposable) PublishSubject(io.reactivex.subjects.PublishSubject) PlayQueueEvent(org.schabi.newpipe.playlist.events.PlayQueueEvent) Subscription(org.reactivestreams.Subscription) PlayQueue(org.schabi.newpipe.playlist.PlayQueue) Nullable(android.support.annotation.Nullable) Collections(java.util.Collections) EmptySubscription(io.reactivex.internal.subscriptions.EmptySubscription) SerialDisposable(io.reactivex.disposables.SerialDisposable) CompositeDisposable(io.reactivex.disposables.CompositeDisposable) Disposable(io.reactivex.disposables.Disposable) PlayQueueItem(org.schabi.newpipe.playlist.PlayQueueItem) StreamInfo(org.schabi.newpipe.extractor.stream.StreamInfo)

Example 2 with StreamInfo

use of org.schabi.newpipe.extractor.stream.StreamInfo in project NewPipe by TeamNewPipe.

the class VideoDetailFragment method onRestoreInstanceState.

@Override
protected void onRestoreInstanceState(@NonNull Bundle savedState) {
    super.onRestoreInstanceState(savedState);
    wasRelatedStreamsExpanded = savedState.getBoolean(WAS_RELATED_EXPANDED_KEY, false);
    Serializable serializable = savedState.getSerializable(INFO_KEY);
    if (serializable instanceof StreamInfo) {
        // noinspection unchecked
        currentInfo = (StreamInfo) serializable;
        InfoCache.getInstance().putInfo(serviceId, url, currentInfo);
    }
    serializable = savedState.getSerializable(STACK_KEY);
    if (serializable instanceof Collection) {
        // noinspection unchecked
        stack.addAll((Collection<? extends StackItem>) serializable);
    }
}
Also used : Serializable(java.io.Serializable) StreamInfo(org.schabi.newpipe.extractor.stream.StreamInfo) Collection(java.util.Collection)

Example 3 with StreamInfo

use of org.schabi.newpipe.extractor.stream.StreamInfo in project NewPipe by TeamNewPipe.

the class DownloadDialog method onCreate.

/*//////////////////////////////////////////////////////////////////////////
    // LifeCycle
    //////////////////////////////////////////////////////////////////////////*/
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (DEBUG)
        Log.d(TAG, "onCreate() called with: savedInstanceState = [" + savedInstanceState + "]");
    if (!PermissionHelper.checkStoragePermissions(getActivity())) {
        getDialog().dismiss();
        return;
    }
    if (savedInstanceState != null) {
        Serializable serial = savedInstanceState.getSerializable(INFO_KEY);
        if (serial instanceof StreamInfo)
            currentInfo = (StreamInfo) serial;
        serial = savedInstanceState.getSerializable(SORTED_VIDEOS_LIST_KEY);
        if (serial instanceof ArrayList) {
            // noinspection unchecked
            sortedStreamVideosList = (ArrayList<VideoStream>) serial;
        }
        selectedVideoIndex = savedInstanceState.getInt(SELECTED_VIDEO_KEY, 0);
        selectedAudioIndex = savedInstanceState.getInt(SELECTED_AUDIO_KEY, 0);
    }
}
Also used : Serializable(java.io.Serializable) StreamInfo(org.schabi.newpipe.extractor.stream.StreamInfo) ArrayList(java.util.ArrayList) VideoStream(org.schabi.newpipe.extractor.stream.VideoStream)

Aggregations

StreamInfo (org.schabi.newpipe.extractor.stream.StreamInfo)3 Serializable (java.io.Serializable)2 NonNull (android.support.annotation.NonNull)1 Nullable (android.support.annotation.Nullable)1 Log (android.util.Log)1 DynamicConcatenatingMediaSource (com.google.android.exoplayer2.source.DynamicConcatenatingMediaSource)1 MediaSource (com.google.android.exoplayer2.source.MediaSource)1 ShuffleOrder (com.google.android.exoplayer2.source.ShuffleOrder)1 Observable (io.reactivex.Observable)1 Single (io.reactivex.Single)1 AndroidSchedulers (io.reactivex.android.schedulers.AndroidSchedulers)1 CompositeDisposable (io.reactivex.disposables.CompositeDisposable)1 Disposable (io.reactivex.disposables.Disposable)1 SerialDisposable (io.reactivex.disposables.SerialDisposable)1 Consumer (io.reactivex.functions.Consumer)1 EmptySubscription (io.reactivex.internal.subscriptions.EmptySubscription)1 PublishSubject (io.reactivex.subjects.PublishSubject)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1