Exemplo n.º 1
0
  private void startWebmConversion(Binder binder, MediaUri url) {
    logger.info("Start converting gif to webm");

    // normalize to http://
    String gifUrl = url.toString().replace("https://", "http://");

    // and start conversion!
    conversion =
        gifToVideoService
            .toVideo(gifUrl)
            .compose(binder.get())
            .subscribe(
                result -> {
                  checkMainThread();

                  // create the correct child-viewer
                  MediaView mediaView;
                  if (result.getVideoUrl().isPresent()) {
                    logger.info("Converted successfully, replace with video player");
                    MediaUri webm =
                        url.withUri(
                            Uri.parse(result.getVideoUrl().get()), MediaUri.MediaType.VIDEO);
                    mediaView =
                        MediaViews.newInstance(getContext(), binder, webm, this::onMediaShown);

                  } else {
                    logger.info("Conversion did not work, showing gif");
                    mediaView = new GifMediaView(getContext(), binder, url, this::onMediaShown);
                  }

                  mediaView.removePreviewImage();
                  setChild(mediaView);
                },
                defaultOnError());
  }
Exemplo n.º 2
0
  public static void adaptFragmentLifecycle(Observable<FragmentEvent> lifecycle, MediaView view) {
    lifecycle
        .compose(bindView(view))
        .subscribe(
            event -> {
              if (event == FragmentEvent.RESUME) view.onResume();

              if (event == FragmentEvent.PAUSE) view.onPause();
            });
  }
Exemplo n.º 3
0
        @Override
        public void onScreenSwitched(final int screen) {
          // Check the appropriate button when the user swipes screens.
          switch (screen) {
            case 0:
              break;
            case 1:
              break;
          }

          if (allMedias.size() > 1) {
            handler.removeCallbacks(r);
            startTimer();
            pageIndicator.setSelectedPage(screen);
            MediaView prevMediaView = mediaViewList.get(prevPage);
            MediaView curMediaView = mediaViewList.get(screen);
            prevPage = screen;
            curMediaView.playVideo();
            prevMediaView.pauseVideo();
          }
        }