简体   繁体   中英

Cordova media plugin, how to test sound playing in browser? I always got ReferenceError: Media is not defined

due to issues with sound playing in apps builded with cordova (native wrapper) i decided to use cordova media plugin> http://plugins.cordova.io/#/package/org.apache.cordova.media

Problem is that in this case i am not able test sound playing in the Chrome or Ripple browser emulator because i always get error:

ReferenceError: Media is not defined

So I imported cordova.js into app folder to avoid 404 error but i still getting this error.

Is possible to solve it or i must test only on device?

Thanks for any help.

On cordova project directory

$ cordova platform add browser to add browser as platform
$ cordova run browser to run in browser or
$ cordova emulate browser has the same effect
on either case a browser pops up with the corresponding url. You can run multiple projects on browser. You should restart the server after every change in the code to take effect (with pronegap serve no restart is required).

This works on plugins that have implemented browser support (pretty much all). To be sure that the plugin has browser support one of the following folders should exist
cordova-project-dir/plugins/cordova-plugin-folder/src/browser
cordova-project-dir/plugins/cordova-plugin-folder/www/browser

I know it is an old question, but I just stumbled upon the same problem and found the solution.

我解决了以下主题中提到的media.plugin后备问题: http : //forum.ionicframework.com/t/how-to-play-local-audio-files/7479/5

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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