简体   繁体   English

在 android @ 网站上播放音频

[英]Playback audio on android @ website

I'm looking for a way to play an audio stream on android without using flash.我正在寻找一种不使用 flash 在 android 上播放音频 stream 的方法。

What I've tried so far:到目前为止我已经尝试过:

This just claims "Sorry, this video cannot be played."这只是声称“抱歉,无法播放此视频”。

<video id="video" controls="controls" preload="none" autoplay="autoplay" src="http://194.106.119.243/powerhit_hi.ogg" tabindex="0"></video>

The following simply doesn't do anything.以下根本不做任何事情。 As far as I googled it looks like Android does not support the audio tag at all till 2.3 and at 2.3 it does support it but non of the codecs work so it doesn't actually work.据我谷歌搜索,Android 在 2.3 之前根本不支持音频标签,在 2.3 时它确实支持它,但没有编解码器工作,所以它实际上不起作用。

<audio id="audio" controls="controls" preload="none" autoplay="autoplay" tabindex="0">
    <source src="http://194.106.119.243/powerhit_hi.ogg"></source>
    <source src="http://194.106.119.243/powerhit_hi.mp3"></source>
</audio>

I have an Android 2.2 device and I can get video to work , though you should note a few things:我有一个 Android 2.2 设备,我可以让video工作,但你应该注意一些事情:

  • it launches a separate window to play video - they don't play inline in the page它会启动一个单独的 window 来播放视频 - 它们不会在页面中内联播放
  • because of the above the controls attribute has no effect因为上面的controls属性没有效果
  • autoplay is generally ignored on mobile devices so users don't incur data charges unless they've explicitly requested the media自动播放通常在移动设备上被忽略,因此用户不会产生数据费用,除非他们明确请求媒体
  • make sure you have the correct MIME types set up in your server config, HTML5 Boilerplate can help with that确保在服务器配置中设置了正确的 MIME 类型, HTML5 Boilerplate 可以提供帮助

I think your example is failing because .ogg is usually an audio file (MIME audio/ogg), the equivalent video container would be .ogv (MIME video/ogg), but simply renaming the file is unlikely to work, you'd have to get the audio encoded into a video file, perhaps with some static picture for the video.我认为您的示例失败了,因为.ogg通常是音频文件(MIME 音频/ogg),等效的视频容器将是.ogv (MIME 视频/ogg),但简单地重命名文件不太可能工作,你有将音频编码为视频文件,可能带有一些 static 图片用于视频。

Like you, I couldn't get audio to play anything on my device .和你一样,我无法在我的设备上播放任何audio

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM