1
每次在傳送帶中顯示新面板時,我都希望播放一個小型MP3。我使用自動播放的音頻xtype,但這會導致啓動時發出一陣雜音。所有設備(模擬器,Chrome,ipad和nexus7)都會出現問題。現在,我使用一個可以激活聲音的按鈕,但是我希望它在需要時自動播放(在活動面板上)。它「聽起來」很簡單,但我無法實現它的工作。任何幫助表示讚賞。傳送帶中的Sencha觸摸音頻
這是一個旋轉木馬項目(一個按鈕):
{
layout: {
type: 'vbox',
align: 'stretch',
},
items: [
{
flex:4,
xtype: 'image',
src: 'resources/images/hond.png',
},
{
xtype: 'button',
text: 'Play',
iconCls: 'arrow_right',
cls: 'knopsound',
handler: function() {
Ext.getCmp('hond').toggle();
this.setText(Ext.getCmp('hond').isPlaying() ? 'Pause' : 'Play');
}
},
{
xtype: 'audio',
url: 'resources/images/hond.mp3',
id: 'hond',
loop: false,
enableControls: false,
hidden:true
},
{
flex:3,
xtype: 'video',
url: 'resources/images/test.mp4',
posterUrl: 'resources/images/bekijkgebaar.png',
cls: 'videoplayknop',
autoResume: true,
autoPause: true,
enableControls: false,
}]},
感謝Anubis,我在activeitemchange函數中使用偵聽器來工作:document.getElementById(activeIndex).play(); – BastiaanW