Phonegap + jquery mobile Media未定义

时间:2014-01-23 09:36:20

标签: javascript android jquery jquery-mobile cordova

我遇到最新的phonegap问题。我有一个必须播放声音的应用程序。我已经用phonegap示例测试过,但我无法使用它。我已安装插件,一切都已加载但仍然没有运气。

插件: Cordova插件ls ['org.apache.cordova.media']

RES / config.xml中:

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

头标记之间包含的所有内容:

<script type="text/javascript" src="cordova.js"></script>
    <script src="js/jquery-1.9.1.min.js"></script>
    <script src="js/jquery.mobile-1.4.0.js"></script>

    <script type="text/javascript">
    //
        document.addEventListener("deviceready", onDeviceReady, false);

        // device APIs are available
        //
        function onDeviceReady() {
            console.log('Received Event: Device ready');
                        playAudio("/android_asset/www/audio/a.mp3");
        }

        var my_media = null;
        var mediaTimer = null;

        // Play audio
        //
        function playAudio(src) {
            // Create Media object from src
            my_media = new Media(src, onSuccess, onError);

            // Play audio
            my_media.play();

            // Update my_media position every second
            if (mediaTimer == null) {
                mediaTimer = setInterval(function() {
                    // get my_media position
                    my_media.getCurrentPosition(
                        // success callback
                        function(position) {
                            if (position > -1) {
                                setAudioPosition((position) + " sec");
                            }
                        },
                        // error callback
                        function(e) {
                            console.log("Error getting pos=" + e);
                            setAudioPosition("Error: " + e);
                        }
                    );
                }, 1000);
            }
        }
   </script>

logcat的:

01-22 20:14:34.914: I/chromium(9713): [INFO:CONSOLE(17)] "Received Event: Device ready",    
source: file:///android_asset/www/index.html (17)
01-22 20:14:34.914: D/CordovaLog(9713): file:///android_asset/www/index.html: Line 28 :    
Uncaught ReferenceError: Media is not defined
01-22 20:14:34.914: I/chromium(9713): [INFO:CONSOLE(28)] "Uncaught ReferenceError: Media    
is not defined", source: file:///android_asset/www/index.html (28)

请帮我解决这个问题。

埃丁

0 个答案:

没有答案