Ejemplo n.º 1
1
  /** 2nd */
  private void playVideoOrDownload() {
    Log.d("INSIDE playVideoOrDownload", "INSIDE playVideoOrDownload");

    try {
      if (streamMode) {
        // seekBar.setSecondaryProgress(seekBar.getMax());
        this.startVideo(Uri.parse(embedUrlStr));

      } else {
        if (this.isOnline()
            && (!tempFile.exists() || (tempFile.exists() && tempFile.length() == 0L))) {
          this.downloadThread =
              new VideoDownloader(this.embedUrlStr, this.pathToFile, this.tempFile, this);
          this.downloadThread.start();
          // if (!videoView.isPlaying())
          // startVideo(Uri.parse(embedUrlStr));
        } else if (!this.isOnline() && !tempFile.exists()) {
          this.showErrorAlert(
              getString(R.string.error_message_title), getString(R.string.error_no_connection));
        }

        if (tempFile.exists() && tempFile.length() > 0) {
          Log.d("Start VIDEO with PATH", this.pathToFile);
          seekBar.setSecondaryProgress(seekBar.getMax());
          this.startVideo(Uri.parse("file:/" + this.pathToFile));
        }
      }
    } catch (Exception e) {
      Log.e("TAG", "error: " + e.getMessage(), e);
      if (videoView != null) {
        videoView.stopPlayback();
      }
    }
  }
 @Override
 protected void onPause() {
   super.onPause();
   state_onpause = true;
   seekPosition = VideoPlayer.getCurrentPosition();
   VideoPlayer.stopPlayback();
 }
Ejemplo n.º 3
0
  private void playVideo() {
    try {
      final String path = mPath.getText().toString();
      Log.v(TAG, "path: " + path);
      if (path == null || path.length() == 0) {
        Toast.makeText(VideoViewDemo.this, "File URL/path is empty", Toast.LENGTH_LONG).show();

      } else {
        // If the path has not changed, just start the media player
        if (path.equals(current) && mVideoView != null) {
          mVideoView.start();
          mVideoView.requestFocus();
          return;
        }
        current = path;
        mVideoView.setVideoPath(getDataSource(path));
        mVideoView.start();
        mVideoView.requestFocus();
      }
    } catch (Exception e) {
      Log.e(TAG, "error: " + e.getMessage(), e);
      if (mVideoView != null) {
        mVideoView.stopPlayback();
      }
    }
  }
Ejemplo n.º 4
0
        @Override
        public void onReceive(final Context context, final Intent intent) {

          if (intent.getAction().equals(VideoConst.SEND_HOSTDP_TO_VIDEOPLAYER)) {
            String mVideoAction = intent.getStringExtra(VideoConst.EXTRA_NAME);

            if (mVideoAction.equals(VideoConst.EXTRA_VALUE_VIDEO_PLAYER_PLAY)) {

              mVideoView.start();
            } else if (mVideoAction.equals(VideoConst.EXTRA_VALUE_VIDEO_PLAYER_STOP)) {
              mVideoView.stopPlayback();
              finish();
            } else if (mVideoAction.equals(VideoConst.EXTRA_VALUE_VIDEO_PLAYER_PAUSE)) {

              mVideoView.pause();
            } else if (mVideoAction.equals(VideoConst.EXTRA_VALUE_VIDEO_PLAYER_RESUME)) {

              mVideoView.resume();
              mVideoView.start();
            } else if (mVideoAction.equals(VideoConst.EXTRA_VALUE_VIDEO_PLAYER_SEEK)) {
              int pos = intent.getIntExtra("pos", -1);
              mVideoView.seekTo(pos);
            }
          }
        }
Ejemplo n.º 5
0
 @Override
 protected void onPause() {
   // Pause video playing when activity is placed in background.
   videoView.stopPlayback();
   videoView = null;
   Log.d("onPause", "Stopping video.");
   super.onPause();
 }
Ejemplo n.º 6
0
  void stopAll() {
    if (videoView.isPlaying()) {

      videoView.stopPlayback();
    }
    if (voiceDispatcher != null) voiceDispatcher.stop();
    if (sourceDispatcher != null) sourceDispatcher.stop();
  }
Ejemplo n.º 7
0
 private void openVideo() {
   if (progress != null) {
     progress.setVisibility(View.VISIBLE);
   }
   videoView.stopPlayback();
   final Uri uri = getArguments().<Uri>getParcelable(EXTRA_SOURCE_URI);
   videoView.setVideoURI(uri);
 }
Ejemplo n.º 8
0
 public void stopVideo() {
   if ((mVideoView != null)) {
     if (LOCAL_LOGV) {
       Log.v(TAG, "Stopping video playback.");
     }
     mVideoView.stopPlayback();
   }
 }
Ejemplo n.º 9
0
 @Override
 public void stopVideo(boolean fade) {
   boolean playing = super.isPlaying();
   if (playing) {
     super.stopPlayback();
   }
   if (fade) {
     setVisibility(View.INVISIBLE);
   }
 }
Ejemplo n.º 10
0
 /** Release media player, assets, listeners, etc. Load up the Caster activity */
 private void loadNextLevel() {
   Log.e(TAG, "finished. Loading Caster");
   try {
     travel.stopPlayback();
     Intent ourIntent = new Intent(TravelScene.this, Class.forName("org.MAG.Caster"));
     travel.setOnTouchListener(null);
     travel.setOnCompletionListener(null);
     ourIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
     startActivity(ourIntent);
     finish();
   } catch (ClassNotFoundException ex) {
     Log.e(TAG, "Failed to jump to another activity");
   }
 }
Ejemplo n.º 11
0
 @Override
 public void close() {
   boolean playing = super.isPlaying();
   if (playing) {
     super.stopPlayback();
   }
   setVisibility(View.INVISIBLE);
   showLayers();
   // 从全屏退出之后,显示出之前的视频
   MagazineActivity act = (MagazineActivity) context;
   ArrayList<OnVideoControllerListener> startlistener = act.getvControllers();
   if (startlistener != null && startlistener.size() > 0) {
     for (Iterator iterator = startlistener.iterator(); iterator.hasNext(); ) {
       CustVideoView listener = (CustVideoView) iterator.next();
       listener.setVisibility(View.VISIBLE);
     }
   }
 }
  @Override
  protected void onDestroy() {
    super.onDestroy();

    YouTubeUtility.markVideoAsViewed(this, mVideoId);

    if (mQueryYouTubeTask != null) {
      mQueryYouTubeTask.cancel(true);
    }

    if (mVideoView != null) {
      mVideoView.stopPlayback();
    }

    // clear the flag that keeps the screen ON
    getWindow().clearFlags(android.view.WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

    this.mQueryYouTubeTask = null;
    this.mVideoView = null;
  }
Ejemplo n.º 13
0
  /*
   * The animation in main menu contains 6 videos
   * If a video finished, the next one will be played
   * This function is used for changing the resource of the videoView
   */
  private void setVideo(int id) {
    VideoView videoView = (VideoView) findViewById(R.id.videoView);
    Uri uri = Uri.EMPTY;
    videoId = id;
    if (videoId > 5) {
      unlockAchievement(R.string.achievement_thats_funny);
      videoId = 0;
    }
    if (videoId == 0) {
      uri = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.flipitanimation00);
    } else if (videoId == 1) {
      uri = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.flipitanimation01);
    } else if (videoId == 2) {
      uri = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.flipitanimation02);
    } else if (videoId == 3) {
      uri = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.flipitanimation03);
    } else if (videoId == 4) {
      uri = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.flipitanimation04);
    } else if (videoId == 5) {
      uri = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.flipitanimation05);
    }
    if (videoId == -1) {
      videoView.stopPlayback();
    } else {
      videoId++;

      try {
        videoView.setVideoURI(uri);
        videoView.setVisibility(View.VISIBLE);
        videoView.start();
      } catch (Exception e) {
        videoView.setVisibility(View.INVISIBLE);
        videoView.setOnCompletionListener(null);
      }
    }
  }
 @Override
 public void onDestroy() {
   mVideoView.stopPlayback();
   super.onDestroy();
 }
Ejemplo n.º 15
0
 public void stopVideoView() {
   mVideoView.stopPlayback();
 }
Ejemplo n.º 16
0
 public void stopPlayback() {
   super.stopPlayback();
   for (Iterator iterator = listeners.iterator();
       iterator.hasNext();
       ((PlaybackListener) iterator.next()).stopPlayback()) {}
 }
Ejemplo n.º 17
0
  @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    try {
      // 선택한 파일이 있는 경우
      Uri fileUri = data.getData();

      // 창전환
      windowOne.setVisibility(View.VISIBLE);
      windowTwo.setVisibility(View.GONE);

      if (requestCode == REQUEST_CODE_AUDIO && resultCode == RESULT_OK) {
        // Audio
        // ImageView 와 viewoView 처리
        playerSet("music");

        startMusic(fileUri);
        mBtnPlayer.setImageResource(R.drawable.player_pause);
        mAudioStat = 1;
        if (mVideoView != null) {
          // video player pause
          //                    mVideoView.pause();
          mVideoView.stopPlayback();
          mVideoStat = 0;
        }
        //            Intent intent = new Intent(getApplicationContext(), MusicService.class);
        //            intent.putExtra("uri", fileUri);
        //            startService(intent);

        //            mBtnAudioFilePick.setText(fileUri.getPath());

        //            mFileName.setText(fileUri.getPath());
      } else if (requestCode == REQUEST_CODE_VIDEO && resultCode == RESULT_OK) {
        // Video
        // ImageView 와 viewoView 처리
        playerSet("video");

        startVideo(fileUri);
        mBtnPlayer.setImageResource(R.drawable.player_pause);
        mVideoStat = 1;
        if (mMediaPlayer != null) {
          // music player pause
          //                    mMediaPlayer.pause();
          mMediaPlayer.stop();
          mAudioStat = 0;
        }

        //            mVideoView.setVideoURI(fileUri);
        //            mVideoView.start();

        //            mBtnVideoFilePick.setText(fileUri.getPath());
        //            mFileName.setText(fileUri.getPath());
      }

      // 파일명 자르기
      String getFilePath = String.valueOf(fileUri.getPath());
      String[] filePathSplit = getFilePath.split("/");
      int filePathLength = filePathSplit.length;
      //        mFileName.setText(filePathSplit[filePathSplit.length]);
      mFileName.setText(filePathSplit[filePathLength - 1]);
    } catch (Exception e) {

    }
  }
Ejemplo n.º 18
0
 public void stop() {
   videoView.stopPlayback();
 }
 private void stopPlayback() {
   if (mVideoView != null) {
     mVideoView.stopPlayback();
   }
 }
Ejemplo n.º 20
0
 @Override
 protected void onDestroy() {
   super.onDestroy();
   video.stopPlayback();
 }