translate AudioPlayer into English

translate AudioPlayer into English
pull/112/head
xufulong 5 years ago
parent b80c7bfb11
commit 2f5f77703e
  1. 33
      app/src/main/java/com/frank/ffmpeg/AudioPlayer.java

@ -5,7 +5,7 @@ import android.media.AudioManager;
import android.media.AudioTrack; import android.media.AudioTrack;
/** /**
* 音频播放器 * AudioPlayer: use AudioTrack and OpenSL ES to play audio
* Created by frank on 2018/2/1. * Created by frank on 2018/2/1.
*/ */
@ -13,20 +13,22 @@ public class AudioPlayer {
static { static {
System.loadLibrary("media-handle"); System.loadLibrary("media-handle");
} }
//调用AudioTrack播放
//using AudioTrack to play
public native void play(String audioPath); public native void play(String audioPath);
//调用OpenSL ES播放
//using OpenSL ES to play
public native void playAudio(String audioPath); public native void playAudio(String audioPath);
//调用OpenSL ES播放
public native void stop(); public native void stop();
public native static void lameInitDefault(); public native static void lameInitDefault();
public native static void lameInit(int inSamplerate, int outChannel, public native static void lameInit(int inSamplerate, int outChannel,
int outSamplerate, int outBitrate, float scaleInput, int mode, int vbrMode, int outSamplerate, int outBitrate, float scaleInput, int mode, int vbrMode,
int quality, int vbrQuality, int abrMeanBitrate, int lowpassFreq, int highpassFreq, String id3tagTitle, int quality, int vbrQuality, int abrMeanBitrate, int lowpassFreq, int highpassFreq, String id3tagTitle,
String id3tagArtist, String id3tagAlbum, String id3tagYear, String id3tagArtist, String id3tagAlbum, String id3tagYear,
String id3tagComment); String id3tagComment);
public native static int lameEncode(short[] buffer_l, short[] buffer_r, public native static int lameEncode(short[] buffer_l, short[] buffer_r,
int samples, byte[] mp3buf); int samples, byte[] mp3buf);
@ -39,19 +41,20 @@ public class AudioPlayer {
public native static void lameClose(); public native static void lameClose();
/** /**
* 创建一个AudioTrack对象 * Create an AudioTrack instance for JNI call
* @param sampleRate 采样率 *
* @param channels 声道布局 * @param sampleRate sampleRate
* @param channels channel layout
* @return AudioTrack * @return AudioTrack
*/ */
public AudioTrack createAudioTrack(int sampleRate, int channels){ public AudioTrack createAudioTrack(int sampleRate, int channels) {
int audioFormat = AudioFormat.ENCODING_PCM_16BIT; int audioFormat = AudioFormat.ENCODING_PCM_16BIT;
int channelConfig; int channelConfig;
if(channels == 1){ if (channels == 1) {
channelConfig = AudioFormat.CHANNEL_OUT_MONO; channelConfig = AudioFormat.CHANNEL_OUT_MONO;
}else if(channels == 2){ } else if (channels == 2) {
channelConfig = AudioFormat.CHANNEL_OUT_STEREO; channelConfig = AudioFormat.CHANNEL_OUT_STEREO;
}else{ } else {
channelConfig = AudioFormat.CHANNEL_OUT_STEREO; channelConfig = AudioFormat.CHANNEL_OUT_STEREO;
} }

Loading…
Cancel
Save