admin管理员组文章数量:1355713
I've been trying to get the Media element to work in PhoneGap when deploying to Android. Here's what I did so far:
Download and install the below:
Java (Version 7 Update 25)
.jsp
Java SE Development Kit 7u25 (64 bit)
.html
Ant (1.9.2)
/
NodeJS (v0.10.18 64 bit)
/
Android SDK (ADT Bundle for Windows) 64 bit - version 2013-07-29
.html
Installation folder: E:\PhoneDev\adt-bundle-windows-x86_64-20130729
Set environment variables:
JAVA_HOME = C:\Progra~1\Java\jre7
ANT_HOME = E:\Program Files (x86)\apache-ant-1.9.2
NODEJS = E:\Program Files (x86)\nodejs
Verify that the following paths are added to the PATH Environment variable (separated by semi-colons):
E:\PhoneDev\adt-bundle-windows-x86_64-20130729\sdk\platform-tools
E:\PhoneDev\adt-bundle-windows-x86_64-20130729\sdk\tools
%ANT_HOME%\bin
%NODEJS%
E:\Program Files\Java\jdk1.7.0_25\bin
Install PhoneGap (Right now it's version 3.0.0):
npm install -g phonegap
Create phonegap app:
phonegap create media-app
Build phonegap app:
cd media-app
phonegap local build android
Add in media-app\platforms\android\res\xml\config.xml:
<feature name="Media">
<param name="android-package" value="org.apache.cordova.AudioHandler" />
</feature>
Add in platforms\android\AndroidManifest.xml:
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
Replace the contents of media-app\www\index.html with the "Full Example" on the following page:
.0.0/cordova_media_media.md.html#Media
Run phonegap app in emulator:
media-app\platforms\android\cordova\run.bat
The application runs correctly, but when I try to play a sound I get the following error:
Uncaught ReferenceError: Media is not defined at
file:///android_asset/www/index.html
I also tried doing the same thing from Eclipse which is bundled with the Android SDK. I created an AVD and ran the application from Eclipse. I get the same error. I’ve been trying to understand what the problem is for a while. If someone can shed some light on this problem I would really appreciate it!
I've been trying to get the Media element to work in PhoneGap when deploying to Android. Here's what I did so far:
Download and install the below:
Java (Version 7 Update 25)
http://java./en/download/index.jsp
Java SE Development Kit 7u25 (64 bit)
http://www.oracle./technetwork/java/javase/downloads/jdk7-downloads-1880260.html
Ant (1.9.2)
http://www.apache/dist/ant/binaries/
NodeJS (v0.10.18 64 bit)
http://nodejs/
Android SDK (ADT Bundle for Windows) 64 bit - version 2013-07-29
http://developer.android./sdk/index.html
Installation folder: E:\PhoneDev\adt-bundle-windows-x86_64-20130729
Set environment variables:
JAVA_HOME = C:\Progra~1\Java\jre7
ANT_HOME = E:\Program Files (x86)\apache-ant-1.9.2
NODEJS = E:\Program Files (x86)\nodejs
Verify that the following paths are added to the PATH Environment variable (separated by semi-colons):
E:\PhoneDev\adt-bundle-windows-x86_64-20130729\sdk\platform-tools
E:\PhoneDev\adt-bundle-windows-x86_64-20130729\sdk\tools
%ANT_HOME%\bin
%NODEJS%
E:\Program Files\Java\jdk1.7.0_25\bin
Install PhoneGap (Right now it's version 3.0.0):
npm install -g phonegap
Create phonegap app:
phonegap create media-app
Build phonegap app:
cd media-app
phonegap local build android
Add in media-app\platforms\android\res\xml\config.xml:
<feature name="Media">
<param name="android-package" value="org.apache.cordova.AudioHandler" />
</feature>
Add in platforms\android\AndroidManifest.xml:
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
Replace the contents of media-app\www\index.html with the "Full Example" on the following page:
http://docs.phonegap./en/3.0.0/cordova_media_media.md.html#Media
Run phonegap app in emulator:
media-app\platforms\android\cordova\run.bat
The application runs correctly, but when I try to play a sound I get the following error:
Uncaught ReferenceError: Media is not defined at
file:///android_asset/www/index.html
I also tried doing the same thing from Eclipse which is bundled with the Android SDK. I created an AVD and ran the application from Eclipse. I get the same error. I’ve been trying to understand what the problem is for a while. If someone can shed some light on this problem I would really appreciate it!
Share Improve this question asked Sep 5, 2013 at 18:14 Nader ChehabNader Chehab 2553 silver badges11 bronze badges 2- Well what's in the "index.html" file? – Pointy Commented Sep 5, 2013 at 18:16
- Search for "Full Example" on this page: docs.phonegap./en/3.0.0/cordova_media_media.md.html#Media – Nader Chehab Commented Sep 5, 2013 at 18:18
1 Answer
Reset to default 7As of version 3.0, PhoneGap implements device-level APIs as plugins. Use the CLI's plugin mand, described in The Command-line Interface, to add or remove this feature for a project:
You need to add the media plugin to your project -
phonegap local plugin add https://git-wip-us.apache/repos/asf/cordova-plugin-media.git
Run that above mand within the project's directory and you should be set.
本文标签: javascriptUncaught ReferenceError Media is not definedStack Overflow
版权声明:本文标题:javascript - Uncaught ReferenceError: Media is not defined - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744053114a2582776.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论