Methods Summary |
---|
private void | attachMediaController()
if (mMediaPlayer != null && mMediaController != null) {
if (!mMediaControllerAttached) {
mMediaController.setMediaPlayer(this);
View anchorView = this.getParent() instanceof View ?
(View)this.getParent() : this;
mMediaController.setAnchorView(anchorView);
mMediaController.setEnabled(true);
mMediaControllerAttached = true;
}
mMediaController.show();
}
|
public boolean | canPause()
return true;
|
public boolean | canSeekBackward()
return true;
|
public boolean | canSeekForward()
return true;
|
public int | getAudioSessionId()
return 0;
|
public int | getBufferPercentage()
return 1;
|
public int | getCurrentPosition()
if (isInPlaybackState()) {
return mMediaPlayer.getCurrentPosition();
}
return 0;
|
public int | getDuration()
return mMediaPlayer.getDuration();
|
private boolean | isInPlaybackState()
return (mMediaPlayer != null && mMediaPlayer.isPlaying());
|
public boolean | isPlaying()
return isInPlaybackState() && mMediaPlayer.isPlaying();
|
public void | onPause()
stopPlayback();
super.onPause();
|
public void | onResume()
Log.d(TAG, "onResume");
mMediaPlayer = new MediaPlayer();
try {
mMediaPlayer.setDataSource(VideoDumpConfig.VIDEO_URI);
class RGBFilter implements FilenameFilter {
public boolean accept(File dir, String name) {
return (name.endsWith(VideoDumpConfig.IMAGE_SUFFIX));
}
}
File dump_dir = new File(VideoDumpConfig.ROOT_DIR);
File[] dump_files = dump_dir.listFiles(new RGBFilter());
for (File dump_file :dump_files) {
dump_file.delete();
}
File image_list = new File(VideoDumpConfig.ROOT_DIR
+ VideoDumpConfig.IMAGES_LIST);
image_list.delete();
mImageListWriter = new BufferedWriter(new FileWriter(image_list));
} catch (java.io.IOException e) {
Log.e(TAG, e.getMessage(), e);
}
queueEvent(new Runnable(){
public void run() {
mRenderer.setMediaPlayer(mMediaPlayer);
mRenderer.setImageListWriter(mImageListWriter);
}});
super.onResume();
|
public boolean | onTouchEvent(android.view.MotionEvent ev)
attachMediaController();
return true;
|
public void | pause()
mMediaPlayer.pause();
try {
mImageListWriter.flush();
} catch (java.io.IOException e) {
Log.e(TAG, e.getMessage(), e);
}
|
public void | seekTo(int pos)
mMediaPlayer.seekTo(pos);
|
public void | setMediaController(android.widget.MediaController controller)
if (mMediaController != null) {
mMediaController.hide();
}
mMediaController = controller;
|
public void | start()
mMediaPlayer.start();
|
public void | stopPlayback()
Log.d(TAG, "stopPlayback");
if (mMediaPlayer != null) {
mMediaPlayer.stop();
mMediaPlayer.release();
mMediaPlayer = null;
}
if (mImageListWriter != null) {
try {
mImageListWriter.flush();
mImageListWriter.close();
} catch (java.io.IOException e) {
Log.e(TAG, e.getMessage(), e);
}
} else {
Log.d(TAG, "image list file was not written successfully.");
}
|