Search in sources :

Example 86 with MediaPlayer

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;
}
Also used : IOException(java.io.IOException) MediaPlayer(android.media.MediaPlayer)

Example 87 with MediaPlayer

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;
}
Also used : IOException(java.io.IOException) MediaPlayer(android.media.MediaPlayer)

Example 88 with MediaPlayer

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;
}
Also used : IOException(java.io.IOException) MediaPlayer(android.media.MediaPlayer)

Example 89 with MediaPlayer

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;
}
Also used : IOException(java.io.IOException) MediaPlayer(android.media.MediaPlayer)

Example 90 with MediaPlayer

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);
    }
}
Also used : MediaPlayer(android.media.MediaPlayer)

Aggregations

MediaPlayer (android.media.MediaPlayer)370 IOException (java.io.IOException)180 LargeTest (android.test.suitebuilder.annotation.LargeTest)60 AudioEffect (android.media.audiofx.AudioEffect)54 AudioManager (android.media.AudioManager)50 AssetFileDescriptor (android.content.res.AssetFileDescriptor)28 EnergyProbe (com.android.mediaframeworktest.functional.EnergyProbe)24 MediaRecorder (android.media.MediaRecorder)18 Uri (android.net.Uri)16 SurfaceHolder (android.view.SurfaceHolder)16 CamcorderProfile (android.media.CamcorderProfile)12 File (java.io.File)12 VideoView (android.widget.VideoView)11 Intent (android.content.Intent)8 OnPreparedListener (android.media.MediaPlayer.OnPreparedListener)7 Surface (android.view.Surface)7 View (android.view.View)7 MediaController (android.widget.MediaController)7 MediaFormat (android.media.MediaFormat)6 UtteranceProgressDispatcher (android.speech.tts.TextToSpeechService.UtteranceProgressDispatcher)6