色婷婷AⅤ一区二区三区|亚洲精品第一国产综合亚AV|久久精品官方网视频|日本28视频香蕉

          新聞中心

          EEPW首頁 > 嵌入式系統(tǒng) > 設計應用 > Android多媒體框架初步分析

          Android多媒體框架初步分析

          作者: 時間:2016-10-08 來源:網(wǎng)絡 收藏

          void stop()

          Stops playback after playback has been stopped or paused.

          我們可以看出MediaPlayer類提供了一個多媒體播放器的基本操作,播放,暫停,停止,設置音量等等。

          簡單的例子:

          Playing a File

          MediaPlayer mp = new MediaPlayer();

          mp.setDataSource(PATH_TO_FILE);

          mp.prepare();

          mp.start();

          Playing a Raw Resource

          MediaPlayer mp = MediaPlayer.create(context, R.raw.sound_file_1);

          mp.start();

          Media Recorder

          提供的基本接口如下:

          Public Method:

          void prepare()

          Prepares the recorder to begin capturing and encoding data.

          void release()

          Releases resources associated with this MediaRecorder object.

          void reset()

          Restarts the MediaRecorder to its idle state.

          void setAudioEncoder(int audio_encoder)

          Sets the audio encoder to be used for recording.

          void setAudioSource(int audio_source)

          Sets the audio source to be used for recording.

          void setOutputFile(String path)

          Sets the path of the output file to be produced.

          void setOutputFormat(int output_format)

          Sets the format of the output file produced during recording.

          void setPreviewDisplay(Surface sv)

          Sets a Surface to show a preview of recorded media (video).

          void start()

          Begins capturing and encoding data to the file specified with setOutputFile().

          void stop()

          Stops recording.

          簡單的例子:

          Example:

          MediaRecorder recorder = new MediaRecorder();

          recorder.setAudioSource(MediaRecorder.AudioSource.MIC);

          recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);

          recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);

          recorder.setOutputFile(PATH_NAME);

          recorder.prepare();

          recorder.start(); // Recording is now started ... recorder.stop();

          recorder.reset(); // You can reuse the object by going back to

          setAudioSource() step

          recorder.release(); // Now the object cannot be reused

          整體的結構如下圖所示:

          l MediaPlayer JNI

          代碼位置 /frameworks/base/media/jni

          l MediaPlayer (Native)

          代碼位置 /frameworks/base/media/libmedia

          l MediaPlayerService (Server)

          代碼位置 /frameworks/base/media/libmediaplayerservice

          l MediaPlayerService Host Process

          代碼位置 /frameworks/base/media/mediaserver/main_mediaserver.cpp

          l PVPlayer

          代碼位置 /external/opencore/android/

          實際調用過程如下圖所示:


          上一頁 1 2 下一頁

          關鍵詞:

          評論


          相關推薦

          技術專區(qū)

          關閉