Results 1 to 11 of 11
  1.    #1  
    One of the biggest hassles with programming in webOS is Audio. So I want to start a thread for audio information where people can post examples of working audio functions to share and use. I'll go first.

    This enables one to reuse an audio object for multiple files.
    Code:
    //in scene setup
    	this.audioPlayer = new Audio();
    
    //In play button Tap function
    	if (this.audioPlayer.palm) {
    		this.audioPlayer.palm.audioClass = Media.AudioClass.MEDIA;
    	}
    	try {
    		this.audioPlayer.src = Mojo.appPath + "audio/" + this.currentSong + ".wav";
    		this.audioPlayer.load();
    	} 
    	catch (err) {
    		$('currentStatus').update('audio failed');
    	}
    Anyone able to get audio to loop, and also pause or stop midway? would help me
  2. #2  
    pausing the audio goes like this:

    Code:
    this.audioPlayer.pause();
    there apparently is no this.audioPlayer.stop() because I've tried it and it doesn't affect the audio.

    an odd thing i found was that when i used the following code for a stop button:
    Code:
    this.audioPlayer.src = null;
    this.audioPlayer.pause();
    it stopped, but when you press the original button to play the audio again, it resumes where it left off, so setting the src to null didn't do anything, apparently.
  3. #3  
    Stopping audio will work like this:
    Code:
    this.audioPlayer.src = null;
    this.audioPlayer.load();
    This will clear the audio object.

    I haven't tried looping audio yet but I remember reading somewhere about the audio object's "currentTime" attribute which might be set to zero to restart the audio. Not sure, though.
  4. #4  
    Any developer that is using Audio and is not part of the Early Access Program, you might want to think about it. http://developer.palm.com/distributi...php?f=5&t=4436

    NDA won't let me say why. It would just be a good idea.
    Last edited by sacherjj; 01/22/2010 at 10:35 AM.
    Your Pre wants Word Whirl from the App Catalog.

    It told me.
  5. #5  
    A description of the HTML5 Audio object's event handlers can be found here:

    HTML5 Media Elements

    Palm's audio implementation also offers the LOAD event which is fired when a file is completely buffered.
  6. #6  
    Quote Originally Posted by insanefury View Post
    One of the biggest hassles with programming in webOS is Audio. So I want to start a thread for audio information where people can post examples of working audio functions to share and use. I'll go first.

    This enables one to reuse an audio object for multiple files.
    Code:
    //in scene setup
    	this.audioPlayer = new Audio();
    
    //In play button Tap function
    	if (this.audioPlayer.palm) {
    		this.audioPlayer.palm.audioClass = Media.AudioClass.MEDIA;
    	}
    	try {
    		this.audioPlayer.src = Mojo.appPath + "audio/" + this.currentSong + ".wav";
    		this.audioPlayer.load();
    	} 
    	catch (err) {
    		$('currentStatus').update('audio failed');
    	}
    Anyone able to get audio to loop, and also pause or stop midway? would help me
    I loop by calling .play() after the 'ended' event.
    pause midway through.
    Code:
    if(audioElem.currentTime == audioElem.currentTime/2){
    audioElem.pause()
    }
    edit: oops correction it should read if(audioElem.currentTime == audioElem.duration/2)
    Last edited by fain; 01/27/2010 at 10:56 AM.
  7. #7  
    Quote Originally Posted by sacherjj View Post
    Any developer that is using Audio and is not part of the Early Access Program, you might want to think about it. Forums webOS • View topic - If you aren't a member of the early access progrma

    NDA won't let me say why. It would just be a good idea.
    Always teasing everybody, are we?
  8. #8  
    thanks folks - this helped out quite a bit. i was using playNotificationSound for the few sounds i've worked with, which obviously wasn't cutting it!
    My site: Shanerooni, LLC
    Follow me on Twitter
    My apps: GuessWhat? | MazeHunter3D | Small Wonders | PhakePhoney | AutismAware | PicSketcher | Cubix | QuickSolve | QuickSpell | QuickTrace | QuickWhack | QuickSuite | Soccer Shots | Ballooning |
    Cubix
  9. #9  
    Quote Originally Posted by sacherjj View Post
    Any developer that is using Audio and is not part of the Early Access Program, you might want to think about it. Forums webOS • View topic - If you aren't a member of the early access progrma

    NDA won't let me say why. It would just be a good idea.
    I tried joining but they rejected me. I'll try again.
    mobigamedepot.com
  10. #10  
    Hey,

    I just have a slite problem. I want to use a status bar in order to indicate when an audio file reaches it's end. With this code I get the currentTime:

    Code:
    this.bang2.currentTime
    With this I should get the endTime but doesn't.

    Code:
    this.bang2.length
    Anyone got a clue?
  11. #11  
    Quote Originally Posted by JuJulian1987 View Post
    Hey,

    I just have a slite problem. I want to use a status bar in order to indicate when an audio file reaches it's end. With this code I get the currentTime:

    Code:
    this.bang2.currentTime
    With this I should get the endTime but doesn't.

    Code:
    this.bang2.length
    Anyone got a clue?
    this will give you the entire length of the track.
    Code:
    this.bang2.duration
    AmpachPre, your music your way.

Posting Permissions