本文整理汇总了C++中MediaPlayer::setDataSource方法的典型用法代码示例。如果您正苦于以下问题:C++ MediaPlayer::setDataSource方法的具体用法?C++ MediaPlayer::setDataSource怎么用?C++ MediaPlayer::setDataSource使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MediaPlayer
的用法示例。
在下文中一共展示了MediaPlayer::setDataSource方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getMediaPlayer
static void
com_media_ffmpeg_FFMpegPlayer_setDataSourceAndHeaders(
JNIEnv *env, jobject thiz, jstring path, jobject headers) {
MediaPlayer* mp = getMediaPlayer(env, thiz);
if (mp == NULL ) {
jniThrowException(env, "java/lang/IllegalStateException", NULL);
return;
}
if (path == NULL) {
jniThrowException(env, "java/lang/IllegalArgumentException", NULL);
return;
}
const char *pathStr = env->GetStringUTFChars(path, NULL);
if (pathStr == NULL) { // Out of memory
jniThrowException(env, "java/lang/RuntimeException", "Out of memory");
return;
}
__android_log_print(ANDROID_LOG_INFO, TAG, "setDataSource: path %s", pathStr);
status_t opStatus = mp->setDataSource(pathStr);
__android_log_print(ANDROID_LOG_INFO, TAG, "opStatus---->0x%X", opStatus);
// Make sure that local ref is released before a potential exception
env->ReleaseStringUTFChars(path, pathStr);
process_media_player_call(
env, thiz, opStatus, "java/io/IOException",
"setDataSource failed." );
}
示例2: newMediaPlayer
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;
}
示例3: getMediaPlayer
static void
wseemann_media_FFmpegMediaPlayer_setDataSourceFD(JNIEnv *env, jobject thiz, jobject fileDescriptor, jlong offset, jlong length)
{
MediaPlayer* mp = getMediaPlayer(env, thiz);
if (mp == NULL ) {
jniThrowException(env, "java/lang/IllegalStateException", NULL);
return;
}
if (fileDescriptor == NULL) {
jniThrowException(env, "java/lang/IllegalArgumentException", NULL);
return;
}
int fd = jniGetFDFromFileDescriptor(env, fileDescriptor);
__android_log_print(ANDROID_LOG_VERBOSE, LOG_TAG, "setDataSourceFD: fd %d", fd);
process_media_player_call( env, thiz, mp->setDataSource(fd, offset, length), "java/io/IOException", "setDataSourceFD failed." );
}
示例4: bootMusic
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();
}
}
}
示例5: newMediaPlayer
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;
}
示例6: main
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);
}