Go2Holidays's Forum Posts

  • But.... obviously right now the PhoneGap audio via CS isn't working.

    So, if AppMobi is the only route, could I just ask for a simple run-down of what is needed to get a game built based on AppMobi?

    ie. I run CS.... and export to AppMobi. That gives me a folder of files on disk. What do I do next with that in order to build it into an Android or iOS package?

    (If the question sounds dim, it is simply because when I visit AppMobi's site I see a whole slew of different products and services, some open-source, some paid, and it's a bit confusing trying to work out which you need to simply take a CS game and get an Android package built based on AppMobi)

    Thanks for any help! :-)

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Hi Ashley,

    I'm new here, but I'd like to ask about the PhoneGap audio issues... you wrote:

    "I've tried, and failed, to get PhoneGap to play audio. It just doesn't support it AFAIK. AppMobi specifically provide an alternative way to play audio which I've plugged in to the Audio object, which is why it works. It would be nice if PhoneGap could play audio, but to be honest after a few months watching what they're doing and trying to prod them in to better supporting games, they just don't appear to be interested. I think they're more about supporting website-style apps. Their open source model also makes it hard to contact anyone in charge or get a clear status on what their plans are. I really like PhoneGap, but it's just not progressing fast enough. AppMobi are doing loads on the other hand, and things like playMobi look really good, which is why we're shifting focus - PhoneGap support is about as good as it can be right now."

    I've not had time to investigate in-depth the JS which CS generates, but I see it attempts to access the PhoneGap media object to play sound, if running via PhoneGap. It 'ought' to work.

    I did an experiment with a construct2 game I made. In the index.html page (which has the canvas on it) I added a standard HTML link to a test.html page. On that page I made some simple use of the PhoneGap media object (as described in PhoneGap's docs) to play some audio. I built this and deployed on the Android emulator on the PC. When run, the first page (the CS game) produced no audio.... but clicking the link to the test page then played the audio via PhoneGap's code just fine. So... the code CAN run in this app, it is just that the CS JS must be doing something a little out of kilter.

    Here's the code in that test.html file I linked to...(taken straight out of the PG docs)

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"

                              "http://www.w3.org/TR/html4/strict.dtd">

        <html>

          <head>

            <title>Media Example</title>

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

            <script type="text/javascript" charset="utf-8">

                // Wait for PhoneGap to load

                //

                document.addEventListener("deviceready", onDeviceReady, false);

                // PhoneGap is ready

                //

                function onDeviceReady() {

                   playAudio("http://audio.ibeat.org/content/p1rj1s/p1rj1s_-_rockGuitar.mp3");

                }

                // Audio player

                //

                var my_media = null;

                var mediaTimer = null;

                // Play audio

                //

                function playAudio(src) {

                   if (my_media == null) {

                        // Create Media object from src

                        my_media = new Media(src, onSuccess, onError);

                   } // else play current audio

                   // 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);

                   }

                }

                // Pause audio

                //

                function pauseAudio() {

                   if (my_media) {

                        my_media.pause();

                   }

                }

                // Stop audio

                //

                function stopAudio() {

                   if (my_media) {

                        my_media.stop();

                   }

                   clearInterval(mediaTimer);

                   mediaTimer = null;

                }

                // onSuccess Callback

                //

                function onSuccess() {

                   console.log("playAudio():Audio Success");

                }

                // onError Callback

                //

                function onError(error) {

                   alert('code: ' + error.code + '\n' +

                      'message: ' + error.message + '\n');

                }

                // Set audio position

                //

                function setAudioPosition(position) {

                   document.getElementById('audio_position').innerHTML = position;

                }

            </script>

          </head>

          <body>

            <a href="#" class="btn large" onclick="playAudio('http://audio.ibeat.org/content/p1rj1s/p1rj1s_-_rockGuitar.mp3');">Play Audio</a>

            <a href="#" class="btn large" onclick="pauseAudio();">Pause Playing Audio</a>

            <a href="#" class="btn large" onclick="stopAudio();">Stop Playing Audio</a>

            <p id="audio_position"></p>

          </body>

        </html>