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;
}
Aggregations