本文整理汇总了C++中MediaPlayer::setListener方法的典型用法代码示例。如果您正苦于以下问题:C++ MediaPlayer::setListener方法的具体用法?C++ MediaPlayer::setListener怎么用?C++ MediaPlayer::setListener使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MediaPlayer
的用法示例。
在下文中一共展示了MediaPlayer::setListener方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getMediaPlayer
static void
com_media_ffmpeg_FFMpegPlayer_release(JNIEnv *env, jobject thiz)
{
__android_log_print(ANDROID_LOG_INFO, TAG, "com_media_ffmpeg_FFMpegPlayer_release() ");
MediaPlayer* mp = getMediaPlayer(env, thiz);
if (mp != NULL) {
// this prevents native callbacks after the object is released
mp->setListener(0);
delete (mp);
env->SetIntField(thiz, fields.context, (int)NULL);
}
}
示例2: MediaPlayer
static void
com_media_ffmpeg_FFMpegPlayer_native_setup(JNIEnv *env, jobject thiz, jobject weak_this)
{
__android_log_print(ANDROID_LOG_INFO, TAG, "native_setup");
MediaPlayer* mp = new MediaPlayer();
if (mp == NULL) {
jniThrowException(env, "java/lang/RuntimeException", "Out of memory");
return;
}
// create new listener and give it to MediaPlayer
JNIFFmpegMediaPlayerListener* listener = new JNIFFmpegMediaPlayerListener(env, thiz, weak_this);
mp->setListener(listener);
// Stow our new C++ MediaPlayer in an opaque field in the Java object.
setMediaPlayer(env, thiz, mp);
}
示例3: setMediaPlayer
static void
wseemann_media_FFmpegMediaPlayer_release(JNIEnv *env, jobject thiz)
{
__android_log_print(ANDROID_LOG_VERBOSE, LOG_TAG, "release");
//decVideoSurfaceRef(env, thiz);
MediaPlayer* mp = setMediaPlayer(env, thiz, 0);
if (mp != NULL) {
// this prevents native callbacks after the object is released
JNIMediaPlayerListener *listener = (JNIMediaPlayerListener *) mp->getListener();
delete listener;
mp->setListener(0);
mp->disconnect();
delete mp;
setMediaPlayer(env, thiz, 0);
}
}
示例4: MediaPlayer
static void
wseemann_media_FFmpegMediaPlayer_native_setup(JNIEnv *env, jobject thiz, jobject weak_this, jbyteArray buffer)
{
__android_log_print(ANDROID_LOG_VERBOSE, LOG_TAG, "native_setup");
MediaPlayer* mp = new MediaPlayer();
if (mp == NULL) {
jniThrowException(env, "java/lang/RuntimeException", "Out of memory");
return;
}
// create new listener and give it to MediaPlayer
JNIMediaPlayerListener* listener = new JNIMediaPlayerListener(env, thiz, weak_this, buffer);
mp->setListener(listener);
// Stow our new C++ MediaPlayer in an opaque field in the Java object.
setMediaPlayer(env, thiz, (int)mp);
}
示例5: 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);
}