Search in sources :

Example 16 with MediaWrapper

use of butter.droid.base.providers.media.model.MediaWrapper in project butter-android by butterproject.

the class BaseStreamLoadingFragmentPresenterImpl method loadSubtitles.

/**
 * Downloads the subs file
 */
private void loadSubtitles() {
    MediaWrapper media = streamInfo.getMedia();
    SubsProvider subsProvider = providerManager.getSubsProvider(media.getProviderId());
    SubtitleWrapper subtitle = streamInfo.getSubtitle();
    // TODO dispose
    subtitleManager.downloadSubtitle(subsProvider, media.getMedia(), subtitle).observeOn(AndroidSchedulers.mainThread()).subscribe(new MaybeObserver<SubtitleWrapper>() {

        @Override
        public void onSubscribe(final Disposable d) {
            subtitleDisposable = d;
        }

        @Override
        public void onSuccess(final SubtitleWrapper wrapper) {
            subtitleDisposable = null;
            startPlayer();
        }

        @Override
        public void onError(final Throwable e) {
            subtitleDisposable = null;
            startPlayer();
        }

        @Override
        public void onComplete() {
            subtitleDisposable = null;
            startPlayer();
        }
    });
}
Also used : MediaWrapper(butter.droid.base.providers.media.model.MediaWrapper) Disposable(io.reactivex.disposables.Disposable) SubsProvider(butter.droid.provider.subs.SubsProvider) SubtitleWrapper(butter.droid.base.providers.subs.model.SubtitleWrapper)

Example 17 with MediaWrapper

use of butter.droid.base.providers.media.model.MediaWrapper in project butter-android by butterproject.

the class TVTrailerPlayerActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState, 0);
    final Intent intent = getIntent();
    final MediaWrapper media = intent.getParcelableExtra(EXTRA_MEDIA);
    final String youtubeUrl = intent.getStringExtra(EXTRA_URI);
    if (savedInstanceState == null) {
        TVTrailerPlayerFragment fragment = TVTrailerPlayerFragment.newInstance(media, youtubeUrl);
        getSupportFragmentManager().beginTransaction().add(android.R.id.content, fragment).commit();
    }
}
Also used : MediaWrapper(butter.droid.base.providers.media.model.MediaWrapper) Intent(android.content.Intent)

Example 18 with MediaWrapper

use of butter.droid.base.providers.media.model.MediaWrapper in project butter-android by butterproject.

the class TVMediaGridPresenterImpl method loadItems.

private void loadItems(@Nullable String endCursor) {
    cancelCurrentCall();
    providerManager.getMediaProvider(providerId).items(filter, new Pager(endCursor)).flatMap(i -> Single.zip(Single.just(i).map(ItemsWrapper::getMedia).flatMapObservable(Observable::fromIterable).map(media -> new MediaWrapper(media, providerId)).map(MediaCardItem::new).toList(), Single.just(i).map(ItemsWrapper::getPaging), Pair::create)).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new SingleObserver<Pair<List<MediaCardItem>, Paging>>() {

        @Override
        public void onSubscribe(final Disposable d) {
            currentCall = d;
        }

        @Override
        public void onSuccess(final Pair<List<MediaCardItem>, Paging> value) {
            view.appendItems(value.first, !value.second.hasNextPage(), value.second.getEndCursor());
        }

        @Override
        public void onError(final Throwable e) {
            view.displayError("Error getting show list");
        }
    });
}
Also used : MediaCardItem(butter.droid.tv.presenters.MediaCardPresenter.MediaCardItem) ItemsWrapper(butter.droid.provider.base.paging.ItemsWrapper) Pair(android.util.Pair) Filter(butter.droid.provider.base.filter.Filter) Single(io.reactivex.Single) AndroidSchedulers(io.reactivex.android.schedulers.AndroidSchedulers) Disposable(io.reactivex.disposables.Disposable) List(java.util.List) SingleObserver(io.reactivex.SingleObserver) ProviderManager(butter.droid.base.manager.internal.provider.ProviderManager) Pager(butter.droid.provider.filter.Pager) Observable(io.reactivex.Observable) Schedulers(io.reactivex.schedulers.Schedulers) MediaWrapper(butter.droid.base.providers.media.model.MediaWrapper) Nullable(android.support.annotation.Nullable) Paging(butter.droid.provider.base.paging.Paging) MediaWrapper(butter.droid.base.providers.media.model.MediaWrapper) Disposable(io.reactivex.disposables.Disposable) Paging(butter.droid.provider.base.paging.Paging) Observable(io.reactivex.Observable) Pager(butter.droid.provider.filter.Pager) List(java.util.List) MediaCardItem(butter.droid.tv.presenters.MediaCardPresenter.MediaCardItem) Pair(android.util.Pair)

Example 19 with MediaWrapper

use of butter.droid.base.providers.media.model.MediaWrapper in project butter-android by butterproject.

the class TVShowDetailsFragment method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Bundle arguments = getArguments();
    final MediaWrapper item = arguments.getParcelable(EXTRA_ITEM);
    presenter.onCreate(item);
}
Also used : MediaWrapper(butter.droid.base.providers.media.model.MediaWrapper) Bundle(android.os.Bundle)

Example 20 with MediaWrapper

use of butter.droid.base.providers.media.model.MediaWrapper in project butter-android by butterproject.

the class TVLaunchActivity method navigateForward.

@Override
public void navigateForward() {
    String action = getIntent().getAction();
    Uri data = getIntent().getData();
    if (action != null && action.equals(Intent.ACTION_VIEW) && data != null) {
        String streamUrl = data.toString();
        try {
            streamUrl = URLDecoder.decode(streamUrl, "utf-8");
            final Media media = new Clip("0", streamUrl, -1, new Genre[0], -1, null, "", "", streamUrl);
            TVStreamLoadingActivity.startActivity(this, new StreamInfo(streamUrl, new MediaWrapper(media, -1), null));
            finish();
            return;
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
    }
    TVMainActivity.startActivity(this);
    finish();
}
Also used : Clip(butter.droid.provider.base.model.Clip) MediaWrapper(butter.droid.base.providers.media.model.MediaWrapper) Media(butter.droid.provider.base.model.Media) StreamInfo(butter.droid.base.providers.media.model.StreamInfo) UnsupportedEncodingException(java.io.UnsupportedEncodingException) Uri(android.net.Uri)

Aggregations

MediaWrapper (butter.droid.base.providers.media.model.MediaWrapper)26 Bundle (android.os.Bundle)7 Disposable (io.reactivex.disposables.Disposable)6 ProviderManager (butter.droid.base.manager.internal.provider.ProviderManager)4 StreamInfo (butter.droid.base.providers.media.model.StreamInfo)4 Filter (butter.droid.provider.base.filter.Filter)4 Media (butter.droid.provider.base.model.Media)4 Pager (butter.droid.provider.filter.Pager)4 MediaCardItem (butter.droid.tv.presenters.MediaCardPresenter.MediaCardItem)4 Observable (io.reactivex.Observable)4 Single (io.reactivex.Single)4 AndroidSchedulers (io.reactivex.android.schedulers.AndroidSchedulers)4 Schedulers (io.reactivex.schedulers.Schedulers)4 List (java.util.List)4 Nullable (android.support.annotation.Nullable)3 Pair (android.util.Pair)3 SubtitleWrapper (butter.droid.base.providers.subs.model.SubtitleWrapper)3 Clip (butter.droid.provider.base.model.Clip)3 Paging (butter.droid.provider.base.paging.Paging)3 SingleObserver (io.reactivex.SingleObserver)3