Search in sources :

Example 6 with SubtitleWrapper

use of butter.droid.base.providers.subs.model.SubtitleWrapper in project butter-android by butterproject.

the class StreamableDetailPresenterImpl method subtitleSelected.

@Override
public void subtitleSelected(UiSubItem item) {
    UiSubItem selectedSub = this.selectedSub;
    if (selectedSub != null) {
        selectedSub.setSelected(false);
    }
    this.selectedSub = item;
    item.setSelected(true);
    String language = item.getLanguage();
    parentPresenter.selectSubtitle(new SubtitleWrapper(item.getSubtitle()));
    if (language == null) {
        view.setSubtitleText(R.string.no_subs);
    } else {
        view.setSubtitleText(item.getName());
    }
    view.hideDialog();
}
Also used : UiSubItem(butter.droid.ui.media.detail.model.UiSubItem) SubtitleWrapper(butter.droid.base.providers.subs.model.SubtitleWrapper)

Example 7 with SubtitleWrapper

use of butter.droid.base.providers.subs.model.SubtitleWrapper 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 8 with SubtitleWrapper

use of butter.droid.base.providers.subs.model.SubtitleWrapper in project butter-android by butterproject.

the class TVStreamableDetailsFragment method startMovie.

@Override
public void startMovie(final MediaWrapper item, final Torrent torrent, final String quality) {
    // Default subtitles will be loaded
    StreamInfo info = new StreamInfo(torrent, item, null, new SubtitleWrapper());
    TVStreamLoadingActivity.startActivity(getActivity(), info);
}
Also used : StreamInfo(butter.droid.base.providers.media.model.StreamInfo) SubtitleWrapper(butter.droid.base.providers.subs.model.SubtitleWrapper)

Example 9 with SubtitleWrapper

use of butter.droid.base.providers.subs.model.SubtitleWrapper in project butter-android by butterproject.

the class StreamableDetailPresenterImpl method displaySubtitles.

private void displaySubtitles() {
    if (providerManager.hasSubsProvider(mediaWrapper.getProviderId())) {
        view.setSubtitleText(R.string.loading_subs);
        view.setSubtitleEnabled(false);
        providerManager.getSubsProvider(mediaWrapper.getProviderId()).list(mediaWrapper.getMedia()).flatMap(subs -> {
            if (subs.isEmpty()) {
                return Single.<List<UiSubItem>>just(Collections.EMPTY_LIST);
            } else {
                final String defaultSubtitle = preferencesHandler.getSubtitleDefaultLanguage();
                return Observable.fromIterable(subs).map(sub -> new UiSubItem(sub, sub.getLanguage().equals(defaultSubtitle))).startWith(new UiSubItem(null, defaultSubtitle == null)).toList();
            }
        }).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new SingleObserver<List<UiSubItem>>() {

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

            @Override
            public void onSuccess(final List<UiSubItem> subs) {
                if (subs.isEmpty()) {
                    view.setSubtitleText(R.string.no_subs_available);
                    subtitleList = null;
                } else {
                    view.setSubtitleEnabled(true);
                    subtitleList = subs;
                    UiSubItem selectedItem = null;
                    for (final UiSubItem sub : subs) {
                        if (sub.isSelected()) {
                            selectedItem = sub;
                            String name = sub.getName();
                            if (TextUtils.isEmpty(name)) {
                                view.setSubtitleText(R.string.no_subs);
                            } else {
                                view.setSubtitleText(name);
                            }
                            break;
                        }
                    }
                    if (selectedItem == null) {
                        selectedItem = subs.get(0);
                    }
                    selectedSub = selectedItem;
                    if (selectedItem.getLanguage() == null) {
                        parentPresenter.selectSubtitle(new SubtitleWrapper());
                    } else {
                        parentPresenter.selectSubtitle(new SubtitleWrapper(selectedItem.getSubtitle()));
                    }
                }
            }

            @Override
            public void onError(final Throwable e) {
                subtitleList = null;
                view.setSubtitleText(R.string.no_subs_available);
                view.setSubtitleEnabled(false);
            }
        });
    } else {
        view.setSubtitleText(R.string.no_subs_available);
        view.setSubtitleEnabled(false);
    }
}
Also used : YouTubeManager(butter.droid.base.manager.internal.youtube.YouTubeManager) StreamInfo(butter.droid.base.providers.media.model.StreamInfo) Single(io.reactivex.Single) AndroidSchedulers(io.reactivex.android.schedulers.AndroidSchedulers) Format(butter.droid.provider.base.model.Format) PlayerManager(butter.droid.base.manager.internal.vlc.PlayerManager) ProviderManager(butter.droid.base.manager.internal.provider.ProviderManager) Observable(io.reactivex.Observable) Schedulers(io.reactivex.schedulers.Schedulers) MediaWrapper(butter.droid.base.providers.media.model.MediaWrapper) MediaDisplayManager(butter.droid.base.manager.internal.media.MediaDisplayManager) R(butter.droid.R) SubtitleWrapper(butter.droid.base.providers.subs.model.SubtitleWrapper) TextUtils(android.text.TextUtils) PreferencesHandler(butter.droid.base.content.preferences.PreferencesHandler) Torrent(butter.droid.provider.base.model.Torrent) Disposable(io.reactivex.disposables.Disposable) List(java.util.List) SingleObserver(io.reactivex.SingleObserver) MediaDetailPresenter(butter.droid.ui.media.detail.MediaDetailPresenter) UiSubItem(butter.droid.ui.media.detail.model.UiSubItem) Genre(butter.droid.provider.base.filter.Genre) Streamable(butter.droid.provider.base.model.Streamable) Movie(butter.droid.provider.base.model.Movie) Collections(java.util.Collections) Resources(android.content.res.Resources) Disposable(io.reactivex.disposables.Disposable) UiSubItem(butter.droid.ui.media.detail.model.UiSubItem) List(java.util.List) SubtitleWrapper(butter.droid.base.providers.subs.model.SubtitleWrapper)

Aggregations

SubtitleWrapper (butter.droid.base.providers.subs.model.SubtitleWrapper)9 MediaWrapper (butter.droid.base.providers.media.model.MediaWrapper)4 StreamInfo (butter.droid.base.providers.media.model.StreamInfo)4 UiSubItem (butter.droid.ui.media.detail.model.UiSubItem)3 Disposable (io.reactivex.disposables.Disposable)3 SubsProvider (butter.droid.provider.subs.SubsProvider)2 Intent (android.content.Intent)1 Resources (android.content.res.Resources)1 Nullable (android.support.annotation.Nullable)1 TextUtils (android.text.TextUtils)1 R (butter.droid.R)1 PreferencesHandler (butter.droid.base.content.preferences.PreferencesHandler)1 MediaDisplayManager (butter.droid.base.manager.internal.media.MediaDisplayManager)1 ProviderManager (butter.droid.base.manager.internal.provider.ProviderManager)1 PlayerManager (butter.droid.base.manager.internal.vlc.PlayerManager)1 YouTubeManager (butter.droid.base.manager.internal.youtube.YouTubeManager)1 Genre (butter.droid.provider.base.filter.Genre)1 Format (butter.droid.provider.base.model.Format)1 Movie (butter.droid.provider.base.model.Movie)1 Streamable (butter.droid.provider.base.model.Streamable)1