<meter id="pryje"><nav id="pryje"><delect id="pryje"></delect></nav></meter>
          <label id="pryje"></label>

          新聞中心

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

          Android多媒體框架初步分析

          作者: 時(shí)間:2016-10-08 來(lái)源:網(wǎng)絡(luò) 收藏

          void stop()

          Stops playback after playback has been stopped or paused.

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

          簡(jiǎn)單的例子:

          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.

          簡(jiǎn)單的例子:

          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

          整體的結(jié)構(gòu)如下圖所示:

          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/

          實(shí)際調(diào)用過(guò)程如下圖所示:


          上一頁(yè) 1 2 下一頁(yè)

          關(guān)鍵詞:

          評(píng)論


          相關(guān)推薦

          技術(shù)專區(qū)

          關(guān)閉
          看屁屁www成人影院,亚洲人妻成人图片,亚洲精品成人午夜在线,日韩在线 欧美成人 (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })();