Android Open Source - NPlayer Video Activity






From Project

Back to project page NPlayer.

License

The source code is released under:

Apache License

If you think the Android project NPlayer listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.qinxiandiqi.nplayer;
//w w w .j ava2s .  c  o  m
import android.app.Activity;
import android.media.MediaPlayer;
import android.media.MediaPlayer.OnCompletionListener;
import android.os.Bundle;
import android.view.Menu;
import android.widget.MediaController;
import android.widget.Toast;
import android.widget.VideoView;

import com.qinxiandiqi.utils.CodeUtils;
import com.qinxiandiqi.utils.PlayingUtils;

public class VideoActivity extends Activity {

  private VideoView videoView;
  private MediaController mediaController;

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_video);
    videoView = (VideoView) findViewById(R.id.videoview);

    mediaController = new MediaController(this);
    videoView.setMediaController(mediaController);
    videoView.setOnCompletionListener(new OnCompletionListener() {
      @Override
      public void onCompletion(MediaPlayer mp) {
        CodeUtils.videoFileList.get(CodeUtils.playingVideo)
            .setLastTime(0);
        int next = PlayingUtils.nextOneId(CodeUtils.playingVideoModel,
            CodeUtils.videoListLength, CodeUtils.playingVideo);
        if (next == CodeUtils.NOTNEXTONE) {
          Toast.makeText(VideoActivity.this, R.string.playdone,
              Toast.LENGTH_SHORT).show();
        } else {
          CodeUtils.playingVideo = next;
          PlayingUtils.startVideoPlaying(VideoActivity.this,
              videoView);
        }
      }
    });

    PlayingUtils.startVideoPlaying(this, videoView);

  }

  @Override
  protected void onPause() {
    if (CodeUtils.playingVideo != CodeUtils.NOTNEXTONE) {
      CodeUtils.playingVideoState = CodeUtils.PAUSE;
      CodeUtils.videoFileList.get(CodeUtils.playingVideo).setLastTime(
          videoView.getCurrentPosition());
      CodeUtils.videoAdapter.notifyDataSetChanged();
    }
    super.onPause();
  }

  @Override
  protected void onDestroy() {
    super.onDestroy();
  }

  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    return true;
  }

}




Java Source Code List

com.qinxiandiqi.adapter.MusicAdapter.java
com.qinxiandiqi.adapter.VideoAdapter.java
com.qinxiandiqi.bean.MediaFile.java
com.qinxiandiqi.bean.MusicFile.java
com.qinxiandiqi.bean.VideoFile.java
com.qinxiandiqi.nplayer.MainActivity.java
com.qinxiandiqi.nplayer.MusicActivity.java
com.qinxiandiqi.nplayer.SearchActivity.java
com.qinxiandiqi.nplayer.VideoActivity.java
com.qinxiandiqi.service.MusicService.java
com.qinxiandiqi.utils.AdapterUtils.java
com.qinxiandiqi.utils.CodeUtils.java
com.qinxiandiqi.utils.FileUtils.java
com.qinxiandiqi.utils.MediaUtils.java
com.qinxiandiqi.utils.PlayingUtils.java
com.qinxiandiqi.utils.PreferenceUtils.java
com.qinxiandiqi.utils.XMLUtils.java