@Override
 protected void onActivityResult(int requestCode, int resultCode, Intent data) {
   super.onActivityResult(requestCode, resultCode, data);
   if (requestCode == VIEW_REQUEST_CODE && resultCode == RESULT_OK) {
     //            Note note = (Note) data.getSerializableExtra("request_note");
     mNote = (Note) data.getSerializableExtra("request_note");
     tvTitle.setText(mNote.getTitle());
     tvContent.setText(mNote.getContent());
     tvViewCategory.setText(mNote.getCategory());
     String imagePath = mNote.getImagePath();
     //            System.out.println("imagePath: " + imagePath);
     if (!TextUtils.isEmpty(imagePath)) {
       BitmapUtils bitmapUtils = new BitmapUtils(this);
       bitmapUtils.display(ivShowPhoto, imagePath);
       ivShowPhoto.setVisibility(View.VISIBLE);
     }
     String videoPath = mNote.getVideoPath();
     if (!TextUtils.isEmpty(videoPath)) {
       vvViewVideo.setVideoURI(Uri.parse(videoPath));
       vvViewVideo.setVisibility(View.VISIBLE);
       if (!vvViewVideo.isPlaying()) {
         vvViewVideo.start();
       }
     }
   }
 }
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    Context context = getActivity();

    // Inflate the layout for this fragment
    View view = inflater.inflate(R.layout.fragment_training_detail, container, false);

    // Expandable Summary
    ExpandList = (ExpandableListView) view.findViewById(R.id.training_summary);

    Bundle bundle = getArguments();
    String trainingCode = bundle.getString("trainingCode");

    trainingUrl = String.format("http://eas.elephorm.com/api/v1/trainings/%1$s", trainingCode);

    training_title = (TextView) view.findViewById(R.id.training_title);

    training_video = (VideoView) view.findViewById(R.id.training_video);
    training_video.setMediaController(new MediaController(context));

    // BOITE DE DIALOGUE
    pDialog = new ProgressDialog(getActivity());
    pDialog.setMessage("Chargement...");
    pDialog.setCancelable(false);

    makeJsonObjectRequest();

    ExpandList.setOnChildClickListener(
        new ExpandableListView.OnChildClickListener() {
          @Override
          public boolean onChildClick(
              ExpandableListView expandableListView,
              View view,
              int parentPosition,
              int childPosition,
              long l) {
            String courseId = list.get(parentPosition).getItems().get(childPosition).getId();
            Intent intent = new Intent(getActivity(), CourseActivity.class);
            intent.putExtra("courseId", courseId);
            intent.putExtra("trainingUrl", trainingUrl);
            startActivity(intent);
            return false;
          }
        });

    training_video.start();

    training_video.setOnCompletionListener(
        new MediaPlayer.OnCompletionListener() {
          @Override
          public void onCompletion(MediaPlayer mediaPlayer) {
            System.out.println("C'est fini :(");
            saveHistory();
          }
        });

    return view;
  }
  private void initViews() {

    tvTitle = (TextView) findViewById(R.id.tvTitle);
    tvTitle.setText(mNote.getTitle());

    tvViewCategory = (TextView) findViewById(R.id.tvViewCategory);
    tvViewCategory.setText(mNote.getCategory());

    tvContent = (TextView) findViewById(R.id.tvContent);
    tvContent.setText(mNote.getContent());

    ivShowPhoto = (ImageView) findViewById(R.id.ivShowPhoto);
    String imagePath = mNote.getImagePath();
    if (!TextUtils.isEmpty(imagePath)) {
      BitmapUtils bitmapUtils = new BitmapUtils(this);
      bitmapUtils.display(ivShowPhoto, imagePath);
      ivShowPhoto.setVisibility(View.VISIBLE);
    }

    vvViewVideo = (VideoView) findViewById(R.id.vvViewVideo);
    String videoPath = mNote.getVideoPath();
    if (!TextUtils.isEmpty(videoPath)) {
      vvViewVideo.setVideoURI(Uri.parse(videoPath));
      vvViewVideo.setVisibility(View.VISIBLE);
      if (!vvViewVideo.isPlaying()) {
        vvViewVideo.start();
      }
    }
  }
        @Override
        public void run() {
          if (nextItemIndex >= slideshow.size()) {
            // if there is music playing
            if (mediaPlayer != null && mediaPlayer.isPlaying())
              mediaPlayer.reset(); // slideshow done, reset mediaPlayer
            finish(); // return to launching Activity
          } // end if
          else {
            MediaItem item = slideshow.getMediaItemAt(nextItemIndex);

            if (item.getType() == MediaItem.MediaType.IMAGE) {
              imageView.setVisibility(View.VISIBLE); // show imageView
              videoView.setVisibility(View.INVISIBLE); // hide videoView
              new LoadImageTask().execute(Uri.parse(item.getPath()));
            } // end if
            else {
              imageView.setVisibility(View.INVISIBLE); // hide imageView
              videoView.setVisibility(View.VISIBLE); // show videoView
              playVideo(Uri.parse(item.getPath())); // plays the video
            } // end else

            ++nextItemIndex;
          } // end else
        } // end method run
Exemple #5
0
  /** We are exiting the app. release the media player and its assets. */
  public void onDestroy() {

    travel.setOnCompletionListener(null);
    travel.setOnTouchListener(null);

    super.onDestroy();
  }
 private void prepareToStart(Track dataSource) {
   try {
     if (dataSource.isVideo()) {
       mediaController.setMediaPlayer(mVideoView);
       mVideoView.setVisibility(VideoView.VISIBLE);
       mVideoView.setVideoPath(dataSource.getPath());
       mVideoView.start();
     } else {
       mediaPlayer.reset();
       mVideoView.setVisibility(VideoView.INVISIBLE);
       mediaPlayer.setDataSource(dataSource.getPath());
       mediaPlayer.prepare();
       mediaPlayer.start();
     }
     ((TextView) findViewById(R.id.now_playing_text))
         .setText(currentPlaylist.getCurrent().getTitle());
   } catch (IllegalArgumentException e) {
     e.printStackTrace();
   } catch (SecurityException e) {
     e.printStackTrace();
   } catch (IllegalStateException e) {
     e.printStackTrace();
   } catch (IOException e) {
     e.printStackTrace();
   }
 }
Exemple #7
0
  /**
   * Called on Activity creation. set the background and video, media player and completion listener
   *
   * @param savedInstanceState
   */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    this.requestWindowFeature(Window.FEATURE_NO_TITLE);
    this.getWindow()
        .setFlags(
            WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

    // TODO: redo the travel video and include audio in it as well.

    setContentView(R.layout.travel);

    travel = (VideoView) findViewById(R.id.travel_background);

    travel.setOnTouchListener(this);
    Uri video = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.travel);

    travel.setOnCompletionListener(this);

    travel.setVideoURI(video);

    travel.start();
  }
  public void showVideo(String advice) {
    VideoView video = new VideoView(this);
    video.setVideoURI(Uri.parse(advice));
    ViewGroup.LayoutParams params =
        new ViewGroup.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    video.setLayoutParams(params);

    MediaController controller =
        new MediaController(this) {
          @Override
          public void hide() {}

          @Override
          public boolean dispatchKeyEvent(KeyEvent event) {
            if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) finish();
            return super.dispatchKeyEvent(event);
          }
        };
    controller.setAnchorView(video);
    video.setMediaController(controller);

    layout.addView(video);
    video.start();
  }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_avplayer);
    mVideoView = (VideoView) findViewById(R.id.videoView1);

    Intent i = getIntent();
    trackList = i.getParcelableArrayListExtra(Track.klass);
    currentPlaylist = new Playlist(trackList, i.getIntExtra("pos", 0));

    mediaPlayer = new MediaPlayer();
    mediaPlayer.setOnPreparedListener(this);

    mediaController = new MediaController(this);
    mVideoView.setMediaController(mediaController);
    mVideoView.setVisibility(VideoView.INVISIBLE);

    //	    set controls for next and previous
    mediaController.setPrevNextListeners(
        new View.OnClickListener() {
          @Override
          public void onClick(View next) {
            prepareToStart(currentPlaylist.getNext());
          }
        },
        new View.OnClickListener() {
          @Override
          public void onClick(View prev) {
            prepareToStart(currentPlaylist.getPrevious());
          }
        });

    prepareToStart(currentPlaylist.getCurrent());
  }
 private void handleCameraVideo(Intent intent) {
   mVideoUri = intent.getData();
   mVideoView.setVideoURI(mVideoUri);
   mImageBitmap = null;
   mVideoView.setVisibility(View.VISIBLE);
   mImageView.setVisibility(View.INVISIBLE);
 }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    VideoView videoView = (VideoView) findViewById(R.id.videoView);
    videoView.setVideoPath("android.resource://" + getPackageName() + "/" + R.raw.demovideo);
    android.widget.MediaController mediaController = new android.widget.MediaController(this);
    mediaController.setAnchorView(videoView);
    videoView.setMediaController(mediaController);
    videoView.start();

    /*
    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
                    .setAction("Action", null).show();
        }
    });
    */
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_level4background);

    myVideoView = (VideoView) findViewById(R.id.videoView);
    myVideoView.setVideoPath("android.resource://" + getPackageName() + "/" + R.raw.level4);
    myVideoView.start();
    myVideoView.setOnCompletionListener(
        new MediaPlayer.OnCompletionListener() {

          @Override
          public void onCompletion(MediaPlayer mp) {
            CallNextActivity();
          }
        });

    RelativeLayout levelbg4 = (RelativeLayout) findViewById(R.id.levelbg4);

    levelbg4.setOnTouchListener(
        new RelativeLayout.OnTouchListener() {
          public boolean onTouch(View v, MotionEvent m) {

            handletouch(m);

            return true;
          }
        });
  }
  private void createView() {
    // Linear Layout
    LinearLayout linearLayout = new LinearLayout(this);
    linearLayout.setId(1);
    linearLayout.setOrientation(LinearLayout.VERTICAL);
    linearLayout.setGravity(Gravity.CENTER);
    linearLayout.setBackgroundColor(Color.BLACK);
    this.setContentView(linearLayout);

    // Relative Layout
    RelativeLayout relativeLayout = new RelativeLayout(this);
    relativeLayout.setId(2);
    relativeLayout.setGravity(Gravity.CENTER);
    relativeLayout.setBackgroundColor(Color.BLACK);
    RelativeLayout.LayoutParams relativeLayoutParams =
        new RelativeLayout.LayoutParams(
            ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT);
    relativeLayout.setLayoutParams(relativeLayoutParams);
    linearLayout.addView(relativeLayout);

    // Video View
    videoView = new VideoView(this);
    videoView.setId(3);
    RelativeLayout.LayoutParams videoViewParams =
        new RelativeLayout.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    videoViewParams.addRule(RelativeLayout.CENTER_IN_PARENT);
    videoView.setLayoutParams(videoViewParams);
    relativeLayout.addView(videoView);
  }
  MraidVideoViewController(
      final Context context,
      final Bundle bundle,
      final long broadcastIdentifier,
      final BaseVideoViewControllerListener baseVideoViewControllerListener) {
    super(context, broadcastIdentifier, baseVideoViewControllerListener);

    mVideoView = new VideoView(context);
    mVideoView.setOnCompletionListener(
        new MediaPlayer.OnCompletionListener() {
          @Override
          public void onCompletion(MediaPlayer mp) {
            mCloseButton.setVisibility(VISIBLE);
            videoCompleted(true);
          }
        });

    mVideoView.setOnErrorListener(
        new MediaPlayer.OnErrorListener() {
          @Override
          public boolean onError(MediaPlayer mediaPlayer, int what, int extra) {
            mCloseButton.setVisibility(VISIBLE);
            videoError(false);

            return false;
          }
        });

    mVideoView.setVideoPath(bundle.getString(VIDEO_URL));
  }
  // This updates the time bar display (if necessary). It is called by
  // mProgressChecker and also from places where the time bar needs
  // to be updated immediately.
  private int setProgress() {
    mVideoPosition = mVideoView.getCurrentPosition();
    // If the video position is smaller than the starting point of trimming,
    // correct it.
    if (mVideoPosition < mTrimStartTime) {
      mVideoView.seekTo(mTrimStartTime);
      mVideoPosition = mTrimStartTime;
    }
    // If the position is bigger than the end point of trimming, show the
    // replay button and pause.
    if (mVideoPosition >= mTrimEndTime && mTrimEndTime > 0) {
      if (mVideoPosition > mTrimEndTime) {
        mVideoView.seekTo(mTrimEndTime);
        mVideoPosition = mTrimEndTime;
      }
      mController.showEnded();
      mVideoView.pause();
    }

    int duration = mVideoView.getDuration();
    if (duration > 0 && mTrimEndTime == 0) {
      mTrimEndTime = duration;
    }
    mController.setTimes(mVideoPosition, duration, mTrimStartTime, mTrimEndTime);
    // Enable save if there's modifications
    mSaveVideoTextView.setEnabled(isModified());
    return mVideoPosition;
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_canciones);

    tituloView = (TextView) findViewById(R.id.texto_canciones);

    server = new BusinessCanciones(php);

    // Creo videoview solo 1 vez
    video = new VideoView(this);
    ViewGroup.LayoutParams params =
        new ViewGroup.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    video.setLayoutParams(params);
    controller =
        new MediaController(this) {
          /*@Override
          public void hide()
          {}*/

          @Override
          public boolean dispatchKeyEvent(KeyEvent event) {
            if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) {
              finish();
            }
            return super.dispatchKeyEvent(event);
          }
        };
    controller.setAnchorView(video);
    video.setMediaController(controller);

    // Cargo la primera cancion
    siguienteCancion();
  }
Exemple #17
0
 public void onShowCustomView(View view, CustomViewCallback customViewCallback) {
   if (view instanceof FrameLayout) {
     FrameLayout frameLayout = (FrameLayout) view;
     View focusedChild = frameLayout.getFocusedChild();
     this.isVideoFullscreen = true;
     this.videoViewContainer = frameLayout;
     this.videoViewCallback = customViewCallback;
     this.activityNonVideoView.setVisibility(4);
     this.activityVideoView.addView(this.videoViewContainer, new LayoutParams(-1, -1));
     this.activityVideoView.setVisibility(0);
     if (focusedChild instanceof VideoView) {
       VideoView videoView = (VideoView) focusedChild;
       videoView.setOnPreparedListener(this);
       videoView.setOnCompletionListener(this);
       videoView.setOnErrorListener(this);
     } else if (this.webView != null
         && this.webView.getSettings().getJavaScriptEnabled()
         && (focusedChild instanceof SurfaceView)) {
       this.webView.loadUrl(
           (((((((("javascript:" + "var _ytrp_html5_video_last;")
                                           + "var _ytrp_html5_video = document.getElementsByTagName('video')[0];")
                                       + "if (_ytrp_html5_video != undefined && _ytrp_html5_video != _ytrp_html5_video_last) {")
                                   + "_ytrp_html5_video_last = _ytrp_html5_video;")
                               + "function _ytrp_html5_video_ended() {")
                           + "_VideoEnabledWebView.notifyVideoEnd();")
                       + "}")
                   + "_ytrp_html5_video.addEventListener('ended', _ytrp_html5_video_ended);")
               + "}");
     }
     if (this.toggledFullscreenCallback != null) {
       this.toggledFullscreenCallback.m9489a(true);
     }
   }
 }
 @Override
 public void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   requestWindowFeature(Window.FEATURE_NO_TITLE);
   getWindow()
       .setFlags(
           WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
   getWindow()
       .setFlags(
           WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON,
           WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
   setContentView(R.layout.main);
   uris.clear();
   uris.add(Uri.parse("file:///mnt/sdcard/st24_iPhone_Retina_1-4.mp4"));
   uris.add(Uri.parse("file:///mnt/sdcard/st24_iPhone_Retina_2-4.mp4"));
   uris.add(Uri.parse("file:///mnt/sdcard/st24_iPhone_Retina_3-4.mp4"));
   uris.add(Uri.parse("file:///mnt/sdcard/st24_iPhone_Retina_4-4.mp4"));
   //		WindowManager.LayoutParams params = new WindowManager.LayoutParams();
   //		params.buttonBrightness = 0;
   //		view.setLayoutParams(params);
   VideoView view = (VideoView) findViewById(R.id.videoView1);
   view.setOnCompletionListener(
       new OnCompletionListener() {
         public void onCompletion(MediaPlayer player) {
           syncVideo();
         }
       });
   syncVideo();
 }
  @Override
  public View onCreateView(
      LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fr_less_15_c, container, false);

    ImageButton button = (ImageButton) view.findViewById(R.id.playVideo);

    videoView = (VideoView) view.findViewById(R.id.less_15_c);
    MediaController mController = new MediaController(getActivity());
    mController.setAnchorView(videoView);
    Uri videoUri =
        Uri.parse("android.resource://com.example.dell.learnerintermediate/raw/less_15_c");
    videoView.setMediaController(mController);
    videoView.setVideoURI(videoUri);

    button.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {

            videoView.start();
          }
        });
    return view;
  }
Exemple #20
0
 /*private String getSDPath(){
     File sdDir = null;
     boolean sdCardExist = Environment.getExternalStorageState()
                         .equals(android.os.Environment.MEDIA_MOUNTED);
     if(sdCardExist){
           //��ȡ��Ŀ¼
       sdDir = Environment.getExternalStorageDirectory();
     }
     return sdDir.toString();
 } */
 protected void onResume() {
   super.onResume();
   vv = (VideoView) findViewById(R.id.vv_q1_tg_m_sax);
   vv.setVideoURI(Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.tg_m_sax));
   //        vv.setOnCompletionListener(onCompListener);
   vv.start();
 }
  // useVideoPlayerメソッド(VideoPlayerクラスを使用した動画再生処理)
  private void useVideoPlayer() {
    VideoView vvPlayer = (VideoView) findViewById(R.id.vv_player);

    // 動画のURIを取得
    String urlString =
        getIntent().getStringExtra(PlaytubeSampleActivity.IntentKey.MEDIA_URL.name());

    // 動画のURIを設定
    vvPlayer.setVideoURI(Uri.parse(urlString));

    // 動画タイトルを取得
    String title = getIntent().getStringExtra(PlaytubeSampleActivity.IntentKey.MEDIA_TITLE.name());

    // 動画再生元リスト判定
    flag =
        getIntent()
            .getIntExtra(PlaytubeSampleActivity.IntentKey.FROM_FLAG.name(), FROM_RESULTS_LIST);

    // タイトルバーに動画タイトルを設定
    setTitle(title);

    // メディアコントローラを設定
    vvPlayer.setMediaController(new MediaController(this));

    // 動画を再生
    vvPlayer.start();
  }
Exemple #22
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    this.setContentView(R.layout.q1_tg_m_sax);

    vv = (VideoView) findViewById(R.id.vv_q1_tg_m_sax);
    vv.setVideoURI(Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.tg_m_sax));

    //		vv.setOnCompletionListener(onCompListener);
    vv.start();

    ib = (ImageButton) findViewById(R.id.tg_m_sax_btn);
    ib.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            Intent intent = new Intent(TG_M_SaxActivity.this, Section686Activity.class);
            Bundle bundle = new Bundle();
            bundle.putInt("sec", 3);
            intent.putExtras(bundle);
            startActivity(intent);
            overridePendingTransition(android.R.anim.slide_in_left, android.R.anim.slide_out_right);
          }
        });
  }
Exemple #23
0
  // Start the game
  private void enterGame() {

    if (gameStatus == GAME_MENU) {
      gameStatus = GAME_GOGAME;
      showView(R.id.start, 0, 2);
      showLayout(R.id.main, R.id.start);

      // Show Tips animation
      AnimationDrawable animationDo;
      ImageView doImage = (ImageView) findViewById(R.id.ani_do);
      doImage.setBackgroundResource(R.drawable.animation_do);
      animationDo = (AnimationDrawable) doImage.getBackground();
      animationDo.start();

      AnimationDrawable animationNotDo;
      ImageView ndoImage = (ImageView) findViewById(R.id.ani_notdo);
      ndoImage.setBackgroundResource(R.drawable.animation_notdo);
      animationNotDo = (AnimationDrawable) ndoImage.getBackground();
      animationNotDo.start();

      showView(R.id.ani_do, 600, 4);
      showView(R.id.ani_notdo, 600, 4);

      showView(R.id.text_do, 1000, 4);
      showView(R.id.text_notdo, 1000, 4);

      label01.setText("0");
      label02.setText("00:00");
      label03.setText(getString(R.string.highscore) + " " + Integer.toString(mHighScore));

      VideoView videoView = (VideoView) findViewById(R.id.videoView);
      videoView.pause();
    }
  }
 @Override
 protected void onPause() {
   super.onPause();
   state_onpause = true;
   seekPosition = VideoPlayer.getCurrentPosition();
   VideoPlayer.stopPlayback();
 }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main_screen);

    // Play video in the background on the title screen.
    videoView = (VideoView) findViewById(R.id.VideoView);
    String uri = "android.resource://" + getPackageName() + "/" + R.drawable.dock;
    videoView.setVideoURI(Uri.parse(uri));
    videoView.setOnPreparedListener(
        new MediaPlayer.OnPreparedListener() {
          @Override
          public void onPrepared(MediaPlayer mp) {
            mp.setLooping(true);
          }
        });
    videoView.start();

    // Open login screen.
    signin = (Button) findViewById(R.id.signin);
    signin.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            Intent intent = new Intent(RingToTitleScreen.this, RingToLogin.class);
            startActivity(intent);
          }
        });
  }
 private void openVideo() {
   if (progress != null) {
     progress.setVisibility(View.VISIBLE);
   }
   videoView.stopPlayback();
   final Uri uri = getArguments().<Uri>getParcelable(EXTRA_SOURCE_URI);
   videoView.setVideoURI(uri);
 }
 @Override
 public void onPause() {
   mHasPaused = true;
   mHandler.removeCallbacksAndMessages(null);
   mVideoPosition = mVideoView.getCurrentPosition();
   mVideoView.suspend();
   super.onPause();
 }
Exemple #28
0
  private void initVideoView() {
    mVideoView.setMediaController(new MediaController(this));
    Uri uri = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.bigbuck);
    mVideoView.setVideoURI(uri);

    setVideoViewPosition();
    mVideoView.start();
  }
  void stopAll() {
    if (videoView.isPlaying()) {

      videoView.stopPlayback();
    }
    if (voiceDispatcher != null) voiceDispatcher.stop();
    if (sourceDispatcher != null) sourceDispatcher.stop();
  }
  @Override
  public void onShowCustomView(View view, CustomViewCallback callback) {
    super.onShowCustomView(view, callback);
    // Android SDK版本
    if (Build.VERSION.SDK_INT >= 14) {

      if (view instanceof FrameLayout) {
        FrameLayout frameLayout = (FrameLayout) view; // A video wants to be shown
        View focusedChild = frameLayout.getFocusedChild();
        this.isVideoFullscreen = true;
        this.videoViewContainer = frameLayout;
        this.videoViewCallback = callback;
        activityNonVideoView.setVisibility(View.GONE); // 隐藏掉视频所在布局中除了用来展示全屏视频以外的布局
        activityVideoView.addView(
            videoViewContainer,
            new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
        activityVideoView.setVisibility(View.VISIBLE); // 设置全屏布局可见
        ((Activity) activityVideoView.getContext())
            .setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); // 强制当前页面在手机中横屏
        if (focusedChild instanceof VideoView) { // VideoView (typically API level <11)
          VideoView videoView = (VideoView) focusedChild;
          videoView.setOnPreparedListener(this); // Handle all the required events
          videoView.setOnCompletionListener(this);
          videoView.setOnErrorListener(this);
        } else {
          // Usually android.webkit.HTML5VideoFullScreen$VideoSurfaceView, sometimes
          // android.webkit.HTML5VideoFullScreen$VideoTextureView
          // HTML5VideoFullScreen (typically API level 11+)
          // Handle HTML5 video ended event
          if (webView != null && webView.getSettings().getJavaScriptEnabled()) {
            // Run javascript code that detects the video end and notifies the interface
            String js = "javascript:";
            js += "_ytrp_html5_video = document.getElementsByTagName('video')[0];";
            js += "if (_ytrp_html5_video !== undefined) {";
            {
              js += "function _ytrp_html5_video_ended() {";
              {
                js += "_ytrp_html5_video.removeEventListener('ended', _ytrp_html5_video_ended);";
                js +=
                    "_VideoEnabledWebView.notifyVideoEnd();"; // Must match Javascript interface
                                                              // name and method of
                                                              // VideoEnableWebView
              }
              js += "}";
              js += "_ytrp_html5_video.addEventListener('ended', _ytrp_html5_video_ended);";
            }
            js += "}";
            webView.loadUrl(js);
          }
        }

        // Notify full-screen change
        if (toggledFullscreenCallback != null) {
          toggledFullscreenCallback.toggledFullscreen(true);
        }
      }
    }
  }