Search in sources :

Example 1 with ShadowMediaPlayer

use of org.robolectric.shadows.ShadowMediaPlayer in project android_packages_apps_Settings by omnirom.

the class ShadowSettingsMediaPlayer method create.

@Implementation
public static MediaPlayer create(Context context, Uri uri) {
    final DataSource ds = DataSource.toDataSource(context, uri);
    addMediaInfo(ds, new ShadowMediaPlayer.MediaInfo());
    final MediaPlayer mp = new MediaPlayer();
    final ShadowMediaPlayer shadow = Shadow.extract(mp);
    try {
        shadow.setDataSource(ds);
        shadow.setState(INITIALIZED);
        mp.prepare();
    } catch (Exception e) {
        return null;
    }
    return mp;
}
Also used : ShadowMediaPlayer(org.robolectric.shadows.ShadowMediaPlayer) DataSource(org.robolectric.shadows.util.DataSource) MediaPlayer(android.media.MediaPlayer) ShadowMediaPlayer(org.robolectric.shadows.ShadowMediaPlayer) Implementation(org.robolectric.annotation.Implementation)

Aggregations

MediaPlayer (android.media.MediaPlayer)1 Implementation (org.robolectric.annotation.Implementation)1 ShadowMediaPlayer (org.robolectric.shadows.ShadowMediaPlayer)1 DataSource (org.robolectric.shadows.util.DataSource)1