在 android 浏览器中播放 html5 音频 [英] Playing html5 audio in android browser

查看:52
本文介绍了在 android 浏览器中播放 html5 音频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 javascript,它使用 html5 <audio> 标签在浏览器中播放音频.它在 iPhone 浏览器中运行良好,但不适用于 Android.(使用 android 2.1 的 HTC 欲望进行测试.)有人知道为什么吗?

I have a javascript that plays audio in the browser, using the html5 <audio> tag. It works fine in the iPhone browser, but not in Android. (Testing using a htc desire with android 2.1.) Anyone know why?

我的代码:

   function playHTML5(sound, soundcv){
                // sound = url to m4a audio file
                // soundcv = div in which the audioplayer should go

  var audio = document.createElement('audio');
  audio.src = sound;
  audio.controls = "controls";
  if (currentSound != null){
   soundcv.replaceChild(audio,currentSound);
  } else {
   soundcv.appendChild(audio);
  }
  currentSound = audio;
 }

顺便说一下,我也在尝试放大 iphone 中显示的音频按钮(默认的按钮很小),到目前为止还没有运气 - 如有任何想法,我们将不胜感激!

By the way, I am also trying to enlarge the audio button that shows up in the iphone (the default one is quite small), with no luck so far - would be grateful for any ideas!

推荐答案

FroYo 中最新的 Android 浏览器尚不支持 HTML5 音频元素.这不是错误,而是尚未实现的功能.它可能来自姜饼.

The latest Android browser in FroYo does not yet support the HTML5 audio element. This is not a bug, rather a feature that has yet to be implemented. It may come in Gingerbread.

更新:Gingerbread 浏览器具有音频元素.

Update: The Gingerbread browser has the audio element.

这篇关于在 android 浏览器中播放 html5 音频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆