【问题标题】:Audio in sencha Touchsencha Touch 中的音频
【发布时间】:2012-11-21 07:36:29
【问题描述】:

我正在用 sencha touch 播放音轨。它工作正常..但我想要两件事。

1) 如何隐藏音频播放器并自动播放声音。为此我尝试了

autoplay:true, and 
hidden:true,

但这不起作用..

2) 我想添加一个按钮来播放音频,即它包含文本“点击播放” 当它被点击时它变成暂停.. 当暂停点击它变成播放.. 我已经这样做了,但它根本不能正常工作..即首先我必须点击播放器上的播放按钮,然后我的自定义按钮开始起作用.. 请帮助我摆脱困境..

{
     xtype: 'audio',
     url: 'lib/touch/snd/sound.mp3',
     id: 'sound1',
     autoplay:true,
     hidden:true
},
{
     xtype: 'button',
     text:'Tap to play audio',
     handler: function() {
         var container = this.getParent().getParent(),
         // use ComponentQuery to get the audio component (using its xtype)
         audio = container.down('audio');
         audio.toggle();
         this.setText(audio.isPlaying() ? 'Pause' : 'Play');
     }
}

【问题讨论】:

  • 请不要再编辑了,请尝试给我一个解决方案

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


【解决方案1】:

请参考文档... link

应该是这样的

{
 xtype: 'audio',
 url: 'lib/touch/snd/sound.mp3',
 id: 'sound1',
 autoplay:true,
 hidden:true
},
{
 xtype: 'button',
 text:'Tap to play audio',
 handler: function() {
     Ext.getCmp('#sound1').play(this,erg); or
     Ext.getCmp('#sound1').pause(this,0,erg);
 }
}

【讨论】:

  • 这行得通,但我也想隐藏音频播放器.. 它在 Chrome 中工作,但在 iPhone5 模拟器中不工作.. 你能帮帮我吗
  • 我们是否需要特定框架来在 sencha touch 中播放视频?
  • 音频播放器不过是一个带有一些控制功能的盒子...挖掘 CSS 并在该特定盒子上隐藏使用
  • 我说它隐藏在谷歌浏览器中,但没有隐藏在 iPhone5 模拟器中
  • 对不起..我不确定这个...我从来没有在 iphone 上测试过这样的东西
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-06-13
  • 2012-05-27
相关资源
最近更新 更多