use of android.content.res.AssetFileDescriptor in project VideoPlayerManager by danylovolokh.
the class MediaPlayerWrapperStopTest method testStopStopped.
@Test
public void testStopStopped() throws Exception {
mMediaPlayerWrapper.setDataSource(new AssetFileDescriptor(ParcelFileDescriptor.adoptFd(0), 0, 0));
mMediaPlayerWrapper.prepare();
mMediaPlayerWrapper.start();
mMediaPlayerWrapper.stop();
assertEquals(MediaPlayerWrapper.State.STOPPED, mMediaPlayerWrapper.getCurrentState());
tryToFailStop(MediaPlayerWrapper.State.STOPPED);
}
use of android.content.res.AssetFileDescriptor in project VideoPlayerManager by danylovolokh.
the class MediaPlayerWrapperStopTest method testStopInitialized.
@Test
public void testStopInitialized() throws Exception {
mMediaPlayerWrapper.setDataSource(new AssetFileDescriptor(ParcelFileDescriptor.adoptFd(0), 0, 0));
assertEquals(MediaPlayerWrapper.State.INITIALIZED, mMediaPlayerWrapper.getCurrentState());
tryToFailStop(MediaPlayerWrapper.State.INITIALIZED);
}
use of android.content.res.AssetFileDescriptor in project android-app by eoecn.
the class CaptureActivity method initBeepSound.
/**
* 扫描正确后的震动声音,如果感觉apk大了,可以删除
*/
private void initBeepSound() {
if (playBeep && mediaPlayer == null) {
// The volume on STREAM_SYSTEM is not adjustable, and users found it
// too loud,
// so we now play on the music stream.
setVolumeControlStream(AudioManager.STREAM_MUSIC);
mediaPlayer = new MediaPlayer();
mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
mediaPlayer.setOnCompletionListener(beepListener);
AssetFileDescriptor file = getResources().openRawResourceFd(R.raw.beep);
try {
mediaPlayer.setDataSource(file.getFileDescriptor(), file.getStartOffset(), file.getLength());
file.close();
mediaPlayer.setVolume(BEEP_VOLUME, BEEP_VOLUME);
mediaPlayer.prepare();
} catch (IOException e) {
mediaPlayer = null;
}
}
}
use of android.content.res.AssetFileDescriptor in project android_frameworks_base by ParanoidAndroid.
the class ContentProviderProxy method openAssetFile.
public AssetFileDescriptor openAssetFile(String callingPkg, Uri url, String mode) throws RemoteException, FileNotFoundException {
Parcel data = Parcel.obtain();
Parcel reply = Parcel.obtain();
try {
data.writeInterfaceToken(IContentProvider.descriptor);
data.writeString(callingPkg);
url.writeToParcel(data, 0);
data.writeString(mode);
mRemote.transact(IContentProvider.OPEN_ASSET_FILE_TRANSACTION, data, reply, 0);
DatabaseUtils.readExceptionWithFileNotFoundExceptionFromParcel(reply);
int has = reply.readInt();
AssetFileDescriptor fd = has != 0 ? AssetFileDescriptor.CREATOR.createFromParcel(reply) : null;
return fd;
} finally {
data.recycle();
reply.recycle();
}
}
use of android.content.res.AssetFileDescriptor in project android_frameworks_base by ParanoidAndroid.
the class SoundPool method load.
/**
* Load the sound from the specified APK resource.
*
* Note that the extension is dropped. For example, if you want to load
* a sound from the raw resource file "explosion.mp3", you would specify
* "R.raw.explosion" as the resource ID. Note that this means you cannot
* have both an "explosion.wav" and an "explosion.mp3" in the res/raw
* directory.
*
* @param context the application context
* @param resId the resource ID
* @param priority the priority of the sound. Currently has no effect. Use
* a value of 1 for future compatibility.
* @return a sound ID. This value can be used to play or unload the sound.
*/
public int load(Context context, int resId, int priority) {
AssetFileDescriptor afd = context.getResources().openRawResourceFd(resId);
int id = 0;
if (afd != null) {
id = _load(afd.getFileDescriptor(), afd.getStartOffset(), afd.getLength(), priority);
try {
afd.close();
} catch (java.io.IOException ex) {
//Log.d(TAG, "close failed:", ex);
}
}
return id;
}
Aggregations