Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Pernet_J_
Beginner
198 Views

Cordova Plugin Media : Media is not defined

Hello everyone.

I have started XDK the last week and I have pass all my weekend for find the problem (I have found lot of good links ... but not for my problem)
I tell my story :

I have Download the last version today of XDK (3769) and create my New Project : "testSon"
In empty folder, I create "www" folder with my .html file (Html5 canvas generate by Animate CC with .js folder)

The problem with the export HTML5 is THE SOUND !! ... yes ... all animations and script run ... but when you put a sound my app crashed.
So ! I go to the web to find my problem and I find a solution : "NO SOUND OUT ON EXPORT XDK !"
Ho !! Oki ... The solution ? 
Cordova-plugin-media ... So lets go !

I put the plugin Media ! And i go to the web site to find the doc.

Yeaaa ! A good exemple to copy and past in my code !

[1] in "onload" of the body, the script of my html5 app start. [2] I put the code in the "init" function.

I call the function "Play_The_Song" in my canvas .js with the ID of my file.

When i simulate, have this message ... so ok ... i go to google for find them !

... a lot of choice : https://cordova.apache.org/docs/en/4.0.0/cordova/events/events.deviceready.html
 or just "Just built it !"
I have try them all ...

Oki ... I have try on the Android 4.4.1 and is "no sound" ... just "a bug".

Have you the same problem ? Can you help me please ? Thx

Tags (2)
0 Kudos
4 Replies
PaulF_IntelCorp
Employee
198 Views

Check out the "audio player" and "hello cordova" samples for an example of how to play sounds. You must wait for the Cordova "deviceready" event before you attempt to use any plugin APIs.

0 Kudos
Pernet_J_
Beginner
198 Views

Hello Paul ! 

Thx to reply ! But when I try this : 

I Add the "hello plugins" and "deviceready"

[1] when i run the app, have "load" alert Run [2] nothing ... 

 

When I search the problem, lot of person say to place this code in the top of the html

<script type="text/javascript" charset="utf-8" src="cordova.js"></script> 

But it's the rong way, because "cordova" start with the app.

 

I have try again other way : Find Here

<script>
    function onDeviceReady () {
     alert("Calling onDeviceReady()");
    }

    setTimeout(function () {
            document.addEventListener('deviceready', onDeviceReady, false);
    }, 9000);
</script>

But nothing run.

Sorry for my bad english. Can you understand me ? Thx ^^)

0 Kudos
PaulF_IntelCorp
Employee
198 Views

Penet -- are you able to successfully run the two examples I pointed you to? First make sure those work so we know if you are able to play media files.

Then, yes, a reference to cordova.js is required, this is not automatically added by the system, you need to include a reference to that script file. See the examples I pointed you to for an example of including the cordova.js file.

0 Kudos
Pernet_J_
Beginner
198 Views

Hi Paul !

Ho  Yes It's Work !!! I use the examples in XDK to create my own app ^^) thx a lot ... but it's not realy easy to understand witch way to take xD

 Good luck for reply to other person ^.^) you are so reactive ! thx a lot !!!

0 Kudos