我听说 Android 设备不播放 html5 中的某些音频文件(例如,它们支持 mp3,但不播放借助一些标准软件创建的文件:链接)。
我尝试了不同的变体,但没有一个适合我。
例如这里的标准示例:
Ext.create('Ext.Container', {
fullscreen: true,
layout: {
type: 'vbox',
pack: 'center'
},
items: [
{
xtype : 'toolbar',
docked: 'top',
title : 'Ext.Audio'
},
{
xtype: 'toolbar',
docked: 'bottom',
defaults: {
xtype: 'button',
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');
}
},
items: [
{ text: 'Play', flex: 1 }
]
},
{
html: 'Hidden audio!',
styleHtmlContent: true
},
{
xtype : 'audio',
hidden: true,
url : 'touch/examples/audio/crash.mp3'
}
]
});
和 html 中的音频:
<audio controls>
<source src="resources/sound/1.mp3" type="audio/mpeg">
Can't play sound on your device.
</audio>
当我在 Chrome 浏览器的帮助下调试我的应用程序时,我听到了声音,但我在真实设备(Android 2.3.5)上听不到它。
在 html 变体的情况下,我看到一个滑块抽动并立即停留在进度条的末尾。在“播放”按钮的情况下,一切正常(图形、播放/暂停),除了缺少的声音。
我没有找到任何特殊的 Android 声音权限选项,所以,我认为权限不是原因。
问题。我错了,是否可以播放任何 mp3 音频?最简单的工作是什么?