merajghaniwala / mobile-web-development-with-phonegap

Automatically exported from code.google.com/p/mobile-web-development-with-phonegap
0 stars 0 forks source link

how to add multiple Audio ? #33

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Hi,

i made on audio player app using this tutorial :-
http://www.mobiledevelopersolutions.com/home/start/twominutetutorials/tmt1part1

everything work perfect !

but i have little question here if i wants to add multiple Audio 
in my app 

Example :- i have 4or5 pages (data-role="page") each page have deferent audio 
so how can i call deferent audios from one main.js file ?

Hope you understand what i'm trying to say
Thanks in advance

Original issue reported on code.google.com by abhijeet...@gmail.com on 7 Jun 2011 at 11:41

GoogleCodeExporter commented 8 years ago

Original comment by paul.beu...@gmail.com on 7 Jun 2011 at 11:50

GoogleCodeExporter commented 8 years ago
Great! Glad to hear of your success. Below I describe what I think you might be 
planning (let me know if different).

jQuery multi-pages like: <div data-role="page" id="page-one"> etc in index.html.

Each page has it's own start/stop/pause buttons like:
<div data-role="button" id="playaudio-page-one">Play</div> etc

Then the click event handlers for each pages' play buttons would have a 
different id and could define different functions in main.js (like diff. values 
for var src):

    $("#playaudio-page-one").live('tap click', function() {     
        var src = 'http://audio.ibeat.org/....mp3';                
        playAudio(src);
    });
    // similarly define live(...) for other buttons $("#playaudio-page-two") etc

This is a very basic design for the code. Depending on how your audio files are 
organized and chosen, you could probably make the code more efficient than my 
example once it's working as you like.

If you'd like the music to start playing automatically when a page is shown, 
use the playAudio() function in a handler for the jQuery Mobile "pageshow" 
event instead of a button's click event.

Good luck and thanks for the interesting question!

Original comment by libby.ba...@gmail.com on 8 Jun 2011 at 12:27

GoogleCodeExporter commented 8 years ago
cool its working

thanks for fast replay

Original comment by abhijeet...@gmail.com on 8 Jun 2011 at 3:18

GoogleCodeExporter commented 8 years ago

Original comment by libby.ba...@gmail.com on 8 Jun 2011 at 3:49