1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
//
// Created by Duke
//
#ifndef UM_AUDIOPLAYER_H
#define UM_AUDIOPLAYER_H
#include <jni.h>
#include "SLAudioPlayer.h"
namespace Unreal {
class NativeAudioPlayer {
public:
//FFmpeg+OpenSLES的播放器实现
SLAudioPlayer *player = NULL;
public:
static jlong s_create(JNIEnv *env, jobject clazz);
static void s_play(JNIEnv *env, jobject clazz, jlong objHandle);
static void s_stop(JNIEnv *env, jobject clazz, jlong objHandle);
static void s_destory(JNIEnv *env, jobject clazz, jlong objHandle);
NativeAudioPlayer();
~NativeAudioPlayer();
void play();
void stop();
};
//动态注册函数对应关系
static const JNINativeMethod methods[] = {
{"nCreate", "()J", (void *) NativeAudioPlayer::s_create},
{"nPlay", "(J)V", (void *) NativeAudioPlayer::s_play},
{"nStop", "(J)V", (void *) NativeAudioPlayer::s_stop},
{"nDestory", "(J)V", (void *) NativeAudioPlayer::s_destory}
};
const static char *className = "com/qfleng/um/audio/FFAudioPlayer";
}
#endif //UM_AUDIOPLAYER_H
|