在Android设备无法播放音频 [英] Can't play audio in Android device

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

问题描述

我想要是这样的:

    <audio controls>
    <source src="media/blablabla.mp3" type="audio/mpeg"></source>
</audio>

我跑我的本地主机上的应用程序:8080 /控制台和它的工作(音乐可以播放)。但是,当我运行的应用我的设备上,音乐无法播放。

I run my app on local host :8080/console and it worked (The music can played). But when I run that apps on my device, the music can't played.

我的设备操作系统的是Android 4.1.2

My Device OS is Android 4.1.2

推荐答案

请参阅为回答这个问题:<一href=\"http://stackoverflow.com/questions/22057260/ibm-worklight-6-1-unable-to-play-a-local-media-file-using-cordova\">IBM工作灯6.1 - 无法使用播放本地媒体文件科尔多瓦

See this question for an answer: IBM Worklight 6.1 - Unable to play a local media file using Cordova

我的回答复制粘贴:

...播放本地媒体文件时,需要提供完整的路径
  媒体文件的位置的它会在生成的Andr​​oid
  项目
的。例如,如果你创建一个常见\\音频中的文件夹
  工作灯应用程序,并在其中放置一个.MP3文件,你需要使用
  以下路径(在HTML或JavaScript,或者无论你想...):

... for playing a local media file, you need to provide the full path to the media file's location where it'll be in the generated Android project. For example, if you create a common\audio folder in the Worklight application and place a .mp3 file in it, you need to use the following path (in the HTML or JavaScript, or however you'd like...):

<a href="#" onclick="playAudio('/android_asset/www/default/audio/myMediaFile.mp3');">Play Audio</a>


  
  

示例项目:的Andr​​oid科尔多瓦媒体API

这篇关于在Android设备无法播放音频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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