简体   繁体   English

未定义媒体-如何在Eclipse的PhoneGap应用中启用媒体

[英]Media is not defined - How do I enable Media in a PhoneGap app in Eclipse

I'm developing an application using PhoneGap in Eclipse and whenever I use the Media object I get an exception on this line: 我正在使用Eclipse中的PhoneGap开发应用程序,每当我使用Media对象时,都会在此行上遇到异常:

var test = new Media("/android_asset/www/sound/music/Weird.mp3", null, null, null);

12-31 13:52:56.775: E/Web Console(3688): Uncaught ReferenceError: Media is not defined:25 12-31 13:52:56.775:E / Web控制台(3688):未捕获的ReferenceError:未定义媒体:25

This exception is, supposedly , due to the fact that I haven't implemented the Media plugin. 据推测 ,该例外是由于我尚未实现Media插件。 I just upgraded from 2.9 to 3.3 so there were some changes with the new plugin-system that I haven't used before. 我刚刚从2.9升级到3.3,所以我以前从未使用过的新插件系统发生了一些变化。

I tried to follow the instructions in the PhoneGap Media documentation but it kept refering to the use of their Command Line Interface. 我试图按照PhoneGap Media文档中的说明进行操作,但它始终引用其命令行界面的用法。 I'm working in Eclipse and I have created the entire project in eclipse, built the Cordova-3.3.0.jar file myself and then added it to the project. 我正在Eclipse中工作,并且已经在eclipse中创建了整个项目,自己构建了Cordova-3.3.0.jar文件,然后将其添加到项目中。 Everything works fine up until the use of the Media object. 一切正常,直到使用Media对象为止。

Anyone have any idea how to add support for Media to a PhoneGap 3.3.0 project? 有谁知道如何在PhoneGap 3.3.0项目中增加对Media的支持? Can I use the CLI on a project created in Eclipse? 我可以在Eclipse中创建的项目上使用CLI吗?

I tried to just add support for it by adding the following to my res/xml/config.xml file: 我试图通过将以下内容添加到我的res / xml / config.xml文件中来添加对它的支持:

<feature name="Media">
    <param name="android-package" value="org.apache.cordova.AudioHandler" />
</feature>

and then adding the proper permissions in my AndroidManifest file: 然后在我的AndroidManifest文件中添加适当的权限:

<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" />

but that didn't work very well either. 但这也不是很好。 Any help would be greatly appreciated! 任何帮助将不胜感激!

Right. 对。 The problem was that I created my Eclipse project using only the Cordova-3.3.0.jar file I had manually built from the source. 问题是我仅使用从源代码手动构建的Cordova-3.3.0.jar文件创建了Eclipse项目。 I should've just created the project using the Command Line Interface as the manual clearly states, added the Media (also through the CLI) and then imported the entire project into Eclipse using File => New => Other => Android from Existing Source . 我应该使用手册明确指出的那样使用命令行界面创建项目, 添加媒体(也通过CLI) ,然后使用File => New => Other => Android from Existing Source将整个项目导入Eclipse。

I got it working now doing it as I described above, hopefully this might help someone some day :P 如上所述,我现在可以正常运行了,希望有一天能对某人有所帮助:P

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

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