Sencha touch NestedList:关闭detailsCard时如何停止音频播放器

时间:2013-02-25 00:18:52

标签: extjs sencha-touch-2 html5-audio

我的Sencha touch 2.1应用程序中的NestedList的detailsCard中有一个Ext.Audio组件。 在点击detailCard中的后退按钮时,我无法理解如何停止音频流。我也不明白如何只为detailCard的后退按钮听“后退按钮点击事件”。这是我的代码:

Ext.define('App.view.Lead', {
extend: 'Ext.NestedList',
xtype: 'lead',
config: {
   title: 'Lead',
   iconCls:'lead',
       store: 'LeadStore',
   displayField: 'title',
   detailCard: { html: 'details' }
},
getDetailCard: function(node) {
          if (node) {
              return {
                  xtype: 'container',
                  layout: 'fit',
                  items: [
                      {
                          xtype: 'panel',
                          layout:'fit',
                          html: node.get('text')     
                      },
                      {               
                          xtype: 'audio',
                          docked: 'bottom',
                          url  : node.get('audio'),
                          autoPause: true,
                      },
                      ]
              }
          } 
     }

});

提前致谢

1 个答案:

答案 0 :(得分:1)

您可以为音频提供id配置以供参考:

{               
    xtype: 'audio',
    docked: 'bottom',
    url  : node.get('audio'),
    autoPause: true,
    id: 'audio'
}

要处理后退按钮,您可以使用嵌套列表的back事件以及stop方法来停止音频:

back: function() {
    Ext.getCmp('audio').stop();
}

如果您使用itemId,您将是安全的。

itemId: audio

然后您可以使用Ext.ComponentQuery来检索它:

Ext.ComponentQuery.query('#audio')[0].stop();