static void com_media_ffmpeg_FFMpegPlayer_prepare(JNIEnv *env, jobject thiz) { MediaPlayer* mp = getMediaPlayer(env, thiz); if (mp == NULL ) { jniThrowException(env, "java/lang/IllegalStateException", NULL); return; } process_media_player_call( env, thiz, mp->prepare(), "java/io/IOException", "Prepare failed." ); }
MediaPlayer* CameraService::newMediaPlayer(const char *file) { MediaPlayer* mp = new MediaPlayer(); if (mp->setDataSource(file, NULL) == NO_ERROR) { mp->setAudioStreamType(AUDIO_STREAM_ENFORCED_AUDIBLE); mp->prepare(); } else { LOGE("Failed to load CameraService sounds: %s", file); return NULL; } return mp; }
static void wseemann_media_FFmpegMediaPlayer_prepare(JNIEnv *env, jobject thiz) { MediaPlayer* mp = getMediaPlayer(env, thiz); if (mp == NULL ) { jniThrowException(env, "java/lang/IllegalStateException", NULL); return; } // Handle the case where the display surface was set before the mp was // initialized. We try again to make it stick. //sp<IGraphicBufferProducer> st = getVideoSurfaceTexture(env, thiz); //mp->setVideoSurfaceTexture(st); process_media_player_call( env, thiz, mp->prepare(), "java/io/IOException", "Prepare failed." ); }
void BootAnimation::bootMusic() { int index; MediaPlayer* mp = new MediaPlayer(); if((access(SYSTEM_BOOTMUSIC_FILE,F_OK))!=-1){ if (mp->setDataSource(SYSTEM_BOOTMUSIC_FILE, NULL) == NO_ERROR) { mp->setAudioStreamType(AUDIO_STREAM_ENFORCED_AUDIBLE); mp->prepare(); mp->setLooping(true); } AudioSystem::getStreamVolumeIndex(AUDIO_STREAM_ENFORCED_AUDIBLE, &index); if (index != 0) { mp->seekTo(0); mp->start(); } } }
MediaPlayer* CameraService::newMediaPlayer(const char *file) { #ifdef MTK_CAMERAPROFILE_SUPPORT AutoCPTLog cptlog(Event_CS_newMediaPlayer); #endif #ifdef MTK_CAMERA_BSP_SUPPORT LOG1("[CameraService::newMediaPlayer] + (%s)\r\n", file); #endif MediaPlayer* mp = new MediaPlayer(); if (mp->setDataSource(file, NULL) == NO_ERROR) { mp->setAudioStreamType(AUDIO_STREAM_ENFORCED_AUDIBLE); mp->prepare(); } else { ALOGE("Failed to load CameraService sounds: %s", file); return NULL; } #ifdef MTK_CAMERA_BSP_SUPPORT LOG1("[CameraService::newMediaPlayer] -\r\n"); #endif return mp; }
int main(int argc, char **argv) { if (argc != 2) { ALOGE("filename unspecified"); return 1; } signal(SIGTERM, signalHandler); signal(SIGHUP, signalHandler); signal(SIGPIPE, signalHandler); prctl(PR_SET_PDEATHSIG, SIGKILL); int fd = open(argv[1], O_RDONLY); if (fd < 0) { ALOGE("Error %d: Unable to open %s", argv[1]); return 1; } int64_t length = lseek64(fd, 0, SEEK_END); lseek64(fd, 0, SEEK_SET); OK(pipe(pipefd)); sp<ProcessState> ps = ProcessState::self(); ps->startThreadPool(); MediaPlayer m; OK(m.setListener(new MPListener)); OK(m.setDataSource(fd, 0, length)); OK(m.prepare()); OK(m.start()); int c; TEMP_FAILURE_RETRY(read(pipefd[0], &c, 1)); // Don't bother trying to shut down cleanly, just let mediaplayer deal with the // unexpected disconnect. exit(0); }