use of android.media.MediaPlayer in project android_frameworks_base by ResurrectionRemix.
the class CodecTest method prepareAsyncReset.
public static boolean prepareAsyncReset(String filePath) {
//preparesAsync
try {
MediaPlayer mp = new MediaPlayer();
mp.setDataSource(filePath);
mp.prepareAsync();
mp.reset();
mp.release();
} catch (Exception e) {
Log.v(TAG, e.getMessage());
return false;
}
return true;
}
use of android.media.MediaPlayer in project android_frameworks_base by ResurrectionRemix.
the class CodecTest method isLoopingAfterReset.
public static boolean isLoopingAfterReset(String filePath) {
MediaPlayer mp = null;
try {
mp = new MediaPlayer();
mp.setDataSource(filePath);
mp.prepare();
mp.setLooping(true);
mp.reset();
if (mp.isLooping()) {
Log.v(TAG, "MediaPlayer.isLooping() returned true after reset()");
return false;
}
} catch (Exception e) {
Log.v(TAG, "Exception : " + e.toString());
return false;
} finally {
if (mp != null)
mp.release();
}
return true;
}
use of android.media.MediaPlayer in project android_frameworks_base by ResurrectionRemix.
the class CodecTest method resourcesPlayback.
//Load midi file from resources
public static boolean resourcesPlayback(AssetFileDescriptor afd, int expectedDuration) {
int duration = 0;
try {
MediaPlayer mp = new MediaPlayer();
mp.setDataSource(afd.getFileDescriptor(), afd.getStartOffset(), afd.getLength());
mp.prepare();
mp.start();
duration = mp.getDuration();
Thread.sleep(5000);
mp.release();
} catch (Exception e) {
Log.v(TAG, e.getMessage());
}
if (duration > expectedDuration)
return true;
else
return false;
}
use of android.media.MediaPlayer in project android_frameworks_base by ResurrectionRemix.
the class CodecTest method getDuration.
public static int getDuration(String filePath) {
Log.v(TAG, "getDuration - " + filePath);
MediaPlayer mp = new MediaPlayer();
try {
mp.setDataSource(filePath);
mp.prepare();
} catch (Exception e) {
Log.v(TAG, e.toString());
}
int duration = mp.getDuration();
Log.v(TAG, "Duration " + duration);
mp.release();
Log.v(TAG, "release");
return duration;
}
use of android.media.MediaPlayer in project android_frameworks_base by ResurrectionRemix.
the class MediaPlayerPowerTest method audioPlayback.
public void audioPlayback(String filePath) {
try {
MediaPlayer mp = new MediaPlayer();
mp.setDataSource(filePath);
mp.prepare();
mp.start();
Thread.sleep(200000);
mp.stop();
mp.release();
} catch (Exception e) {
Log.v(TAG, e.toString());
assertTrue("MP3 Playback", false);
}
}
Aggregations