use of io.vov.vitamio.MediaPlayer in project ABPlayer by winkstu.
the class MediaPlayerDemo_Audio method createMediaPlayer.
public MediaPlayer createMediaPlayer(Context context, int resid) {
try {
AssetFileDescriptor afd = context.getResources().openRawResourceFd(resid);
MediaPlayer mp = new MediaPlayer(context);
mp.setDataSource(afd.getFileDescriptor());
afd.close();
mp.prepare();
return mp;
} catch (IOException ex) {
Log.d(TAG, "create failed:", ex);
// fall through
} catch (IllegalArgumentException ex) {
Log.d(TAG, "create failed:", ex);
// fall through
} catch (SecurityException ex) {
Log.d(TAG, "create failed:", ex);
// fall through
}
return null;
}
use of io.vov.vitamio.MediaPlayer in project ABPlayer by winkstu.
the class MediaPlayerDemo_Video method playVideo.
private void playVideo(Integer Media) {
doCleanUp();
try {
switch(Media) {
case LOCAL_VIDEO:
/*
* TODO: Set the path variable to a local media file path.
*/
path = "/storage/sdcard0/BaiduNetdisk/�ҵ���Դ/5/33.rmvb";
if (path == "") {
// Tell the user to provide a media file URL.
Toast.makeText(MediaPlayerDemo_Video.this, "Please edit MediaPlayerDemo_Video Activity, " + "and set the path variable to your media file path." + " Your media file must be stored on sdcard.", Toast.LENGTH_LONG).show();
return;
}
break;
case STREAM_VIDEO:
/*
* TODO: Set path variable to progressive streamable mp4 or
* 3gpp format URL. Http protocol should be used.
* Mediaplayer can only play "progressive streamable
* contents" which basically means: 1. the movie atom has to
* precede all the media data atoms. 2. The clip has to be
* reasonably interleaved.
*
*/
// path = "http://devimages.apple.com/iphone/samples/bipbop/bipbopall.m3u8";
path = "http://us-chicago.acgvideo.com/67.159.54.58/1/45/3262388-1.flv?expires=1430688900&ssig=VuoBrnO8dUUG4jyJe3FF2Q&o=401361084&rate=0";
if (path == "") {
// Tell the user to provide a media file URL.
Toast.makeText(MediaPlayerDemo_Video.this, "Please edit MediaPlayerDemo_Video Activity," + " and set the path variable to your media file URL.", Toast.LENGTH_LONG).show();
return;
}
break;
}
// Create a new media player and set the listeners
mMediaPlayer = new MediaPlayer(this);
mMediaPlayer.setDataSource(path);
mMediaPlayer.setDisplay(holder);
mMediaPlayer.prepare();
mMediaPlayer.setOnBufferingUpdateListener(this);
mMediaPlayer.setOnCompletionListener(this);
mMediaPlayer.setOnPreparedListener(this);
mMediaPlayer.setOnVideoSizeChangedListener(this);
setVolumeControlStream(AudioManager.STREAM_MUSIC);
} catch (Exception e) {
Log.e(TAG, "error: " + e.getMessage(), e);
}
}
use of io.vov.vitamio.MediaPlayer in project VitamioBundle by yixia.
the class VideoViewDemo method onCreate.
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
if (!LibsChecker.checkVitamioLibs(this))
return;
setContentView(R.layout.videoview);
mEditText = (EditText) findViewById(R.id.url);
mVideoView = (VideoView) findViewById(R.id.surface_view);
if (path == "") {
// Tell the user to provide a media file URL/path.
Toast.makeText(VideoViewDemo.this, "Please edit VideoViewDemo Activity, and set path" + " variable to your media file URL/path", Toast.LENGTH_LONG).show();
return;
} else {
/*
* Alternatively,for streaming media you can use
* mVideoView.setVideoURI(Uri.parse(URLstring));
*/
mVideoView.setVideoPath(path);
mVideoView.setMediaController(new MediaController(this));
mVideoView.requestFocus();
mVideoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mediaPlayer) {
// optional need Vitamio 4.0
mediaPlayer.setPlaybackSpeed(1.0f);
}
});
}
}
use of io.vov.vitamio.MediaPlayer in project VitamioBundle by yixia.
the class MediaPlayerDemo_Audio method playAudio.
private void playAudio(Integer media) {
try {
switch(media) {
case LOCAL_AUDIO:
/**
* TODO: Set the path variable to a local audio file path.
*/
path = "";
if (path == "") {
// Tell the user to provide an audio file URL.
Toast.makeText(MediaPlayerDemo_Audio.this, "Please edit MediaPlayer_Audio Activity, " + "and set the path variable to your audio file path." + " Your audio file must be stored on sdcard.", Toast.LENGTH_LONG).show();
return;
}
mMediaPlayer = new MediaPlayer(this);
mMediaPlayer.setDataSource(path);
mMediaPlayer.prepare();
mMediaPlayer.start();
break;
case RESOURCES_AUDIO:
/**
* TODO: Upload a audio file to res/raw folder and provide its resid in
* MediaPlayer.create() method.
*/
// Bug need fixed
mMediaPlayer = createMediaPlayer(this, R.raw.test_cbr);
mMediaPlayer.start();
}
tx.setText("Playing audio...");
} catch (Exception e) {
Log.e(TAG, "error: " + e.getMessage(), e);
}
}
use of io.vov.vitamio.MediaPlayer in project VitamioBundle by yixia.
the class VideoViewBuffer method onCreate.
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
if (!LibsChecker.checkVitamioLibs(this))
return;
setContentView(R.layout.videobuffer);
mVideoView = (VideoView) findViewById(R.id.buffer);
pb = (ProgressBar) findViewById(R.id.probar);
downloadRateView = (TextView) findViewById(R.id.download_rate);
loadRateView = (TextView) findViewById(R.id.load_rate);
if (path == "") {
// Tell the user to provide a media file URL/path.
Toast.makeText(VideoViewBuffer.this, "Please edit VideoBuffer Activity, and set path" + " variable to your media file URL/path", Toast.LENGTH_LONG).show();
return;
} else {
/*
* Alternatively,for streaming media you can use
* mVideoView.setVideoURI(Uri.parse(URLstring));
*/
uri = Uri.parse(path);
mVideoView.setVideoURI(uri);
mVideoView.setMediaController(new MediaController(this));
mVideoView.requestFocus();
mVideoView.setOnInfoListener(this);
mVideoView.setOnBufferingUpdateListener(this);
mVideoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mediaPlayer) {
// optional need Vitamio 4.0
mediaPlayer.setPlaybackSpeed(1.0f);
}
});
}
}
Aggregations