Impact

This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact

1 decade ago by christianhood

Hello,

I'm trying to learn how to use Cordova (PhoneGap) to port ImpactJS games over to the phones (Android/iOS/WP7), however (as expected) the sound doesn't work. I've looked at the API for Cordova and saw this:
http://docs.phonegap.com/en/1.8.1/cordova_media_media.md.html#media.play

I'm currently trying to implement this with the Drop sample, but I'm getting the following error:
ReferenceError: Media is not defined

I have the cordova .js file included in my index.html along with the game and impact.js files.

Here is an example of how I attempted to do this:

//sound: new ig.Sound('media/bounce.ogg'),
	sound: new Media('media/bounce.mp3', onSuccess, onError),
    
    // onSuccess Callback
    //
    onSuccess: function() {
        console.log("playAudio():Audio Success");
    },

    // onError Callback 
    //
    onError: function(error) {
        alert('code: '    + error.code    + '\n' + 
                'message: ' + error.message + '\n');
    },

Any help as to what I'm doing wrong is appreciated.

1 decade ago by blueicelt

I just tried implementing this and I got it to work, however I just followed the example and kept all the functions in my index.html file. Did you make sure to load the script in your index?

 	<script type="text/javascript" charset="utf-8" src="cordova-1.9.0.js"></script>
	<script type="text/javascript" src="lib/impact/impact.js"></script>
	<script type="text/javascript" src="lib/game/main.js"></script>

Also after a lot of trial and error, I had to use the following syntax to play the sound file
playAudio("/android_asset/www/media/load.ogg");

1 decade ago by blueicelt

By any chance are you targeting gingerbread?
Page 1 of 1
« first « previous next › last »