android soundpool 參數說明

來源:互聯網
上載者:User

標籤:android   音樂   play   

SoundPool 類的建構函式如下:

SoundPool(int maxStreams, int streamType, int srcQuality)

作用:執行個體化一個SoundPool 執行個體

第一個參數:允許同時播放的聲音最大值

第二個參數:聲音類型

第三個參數:聲音的品質

SoundPool 類中常用的函數如下:

int load(Context context, int resId, int priority)

作用:載入音樂檔案,返迴音樂ID(音樂流檔案資料)

第一個參數:Context 執行個體

第二個參數:音樂檔案Id

第三個參數:標識優先考慮的聲音。目前使用沒有任何效果,只是具備了相容性價值

int play(int soundID, float leftVolume, float rightVolume, int priority, int loop, floatrate)

作用:音樂播放,播放失敗返回0,正常播放返回非0 值

第一個參數:載入後得到的音樂檔案ID

第二個參數:音量的左聲道,範圍:0.0~1.0

第三個參數:音量的右聲道,範圍:0.0~1.0

第四個參數:音樂流的優先順序,0 是最低優先順序

第五個參數:音樂的播放次數,-1 表示無限迴圈,0 表示正常一次,大於0 則表示迴圈次數

第六個參數:播放速率,取值範圍:0.5~2.0,1.0 表示正常播放

pause(int streamID)

作用:暫停音樂播放

參數:音樂檔案載入後的流ID

stop(int streamID)

作用:結束音樂播放

參數: 音樂檔案載入後的流ID

release()

作用:釋放SoundPool 的資源

setLoop(int streamID, int loop)

作用:設定迴圈次數

第一個參數:音樂檔案載入後的流ID

第二個參數:迴圈次數

setRate(int streamID, float rate)

作用:設定播放速率

第一個參數:音樂檔案載入後的流ID

第二個參數:速率值

setVolume(int streamID, float leftVolume, float rightVolume)

作用:設定音量大小

第一個參數:音樂檔案載入後的流ID

第二個參數:左聲道音量

第三個參數:右聲道音量

setPriority(int streamID, int priority)

作用:設定流的優先順序

第一個參數:音樂檔案載入後的流ID

第二個參數:優先順序值

android soundpool 參數說明

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.