Jump to content

rubing

Members
  • Posts

    366
  • Joined

  • Last visited

    Never

Posts posted by rubing

  1. Sorry!  Let me clean that up a bit:

     

    If the original code to make a specific sound object is this (soundmanager2 script): 

    var mySoundObj = soundManager.createSound(
          {
             id: "mySound",
             url: "http://www.birminghammusiclive.com/Rick.mp3",
           });
    

     

    I want to change this into a function whose arguments are the essetial parameters, so I can create any sound object I want just by calling that function.  But I think the use of my function arguments may be wrong here?

     

    function makesoundobj(mSO, id, url) {
      var mSO = soundManager.createSound(
          {
             id:= id,
             url: = url,
            
          }); 
      }
    
    

     

     

     

  2. I am trying to make and execute the following function:

     

    function makesoundobj(mSO, id, url) {
      var mSO = soundManager.createSound(
          {
             id:= id,
             url: = url,
             onfinish: function()
             {
                playerButton.src = "http://www.birminghammusiclive.com/images/bigplay.png";
             }
          }); //uses object literal notation just to be safe
      }
    
    makesoundobj('mySoundObj','mysound','http://www.birminghammusiclive.com/Rick.mp3');
    

     

    parameter 1 (mso) is the name of the sound object i want to create

    paramater 2(id) and 3(url) are 2 parameters of the sound object.

     

    The code works fine when it's not written as a function: 

    <script type="text/javascript">
       soundManager.onload = function()
       {
          soundManager.url = "http://www.birminghammusiclive.com/soundmanager2.swf"; // override default SWF url
          soundManager.debugMode = false;
          soundManager.consoleOnly = false;
    
          var playerButton = document.getElementById("player"); //need it before the onfinish event
    
          var mySoundObj = soundManager.createSound(
          {
             id: "mySound",
             url: "http://www.birminghammusiclive.com/Rick.mp3",
             onfinish: function()
             {
                playerButton.src = "http://www.birminghammusiclive.com/images/bigplay.png";
             }
          }); //uses object literal notation just to be safe
    
          playerButton.onclick = function()
          {
             if(this.src == "http://www.birminghammusiclive.com/images/bigplay.png")
             {
                this.src = "http://www.birminghammusiclive.com/images/bigpause.png";
                mySoundObj.play();
             }
             else
             {
                this.src = "http://www.birminghammusiclive.com/images/bigplay.png";
                mySoundObj.pause();
             } //end else
          } //end onclick
       } //end onload
    </script>

     

  3. Yup it works perfect!  8)

     

    I owe you a beer whenever you're in bham.

     

    This has been quite a fast and dirty intro javascript...much better than reading the beginning wrox book at my library.

     

    Now, I gotta try and make an array of sound objects with php.  ;D

  4. Before I got your code I got it to work on this page: 

    http://www.birminghammusiclive.com/indexd.php

    , althought your code is very similar for some reason it does not work (see page indexb.php)

     

    I rather reset the image by referencing the playState property.  Unless, I can use onfinish for playing a sequence of music clips and resetting the image  ???

  5. Ok, I put it back your script, but commented out the onfinish function. B/c it turns out there is no

    there is no global soundManager.onfinish() handler.  It works other than being stuck with a big pause button at the end of the clip. 

     

    The basic api with onfinish examples can be found here:  http://schillmania.com/projects/soundmanager2/demo/basic/

     

    Usually, it's used to play a series of sounds (which, is what i eventually want to do).  So, I rather find some other means of resetting the play button. 

     

    One of the SMSound (Sound Object) Properties listed is playState:

    playState

    Numeric value indicating the current playing state of the sound.

    0 = stopped/uninitialised

    1 = playing or buffering sound (play has been called, waiting for data etc.)

    Note that a 1 may not always guarantee that sound is being heard, given buffering and autoPlay status.

     

    Maybe I can tell it to switch to /images/bigplay.png if playState==0 ??  Unfortunately, I tried coding something like that before and it failed.

     

     

     

     

  6. Yes, it works fine...so no problem i guess, just strange.

     

    My problem seems to be in getting onfinish function to work right.

     

    If i tell it to do something like:

     

    alert(this.sID+' finished playing');

     

    It works fine and throws out an alert on finish, however if I try to get it to replace the image as follows:

    this.src="http://www.birminghammusiclive.com/images/bigplay.png"

     

    The whole player breaks and shows this error in the debug window:

     

    Warning: soundManager.onload() is undefined.

     

     

  7. Yes... of course you only need to check for 1 value!!

     

    For some reason the relative path in my first if statement:

    if(this.src == "images/bigplay.png")

     

    is evaulated as false, so instead I have to use the full URL.  wierd.

     

    i still haven't gotten that onfinish:function() to work.  i'm gonna try to poke around on the soundmanager2 site for more info.  maybe i can use one of the class variables - playState instead. 

     

     

     

     

  8. I am all in favor of unobtrusiveness!  :D

     

    Unfortunately, it doesn't seem to work now that i took out the anchor.  Maybe you could also clue me in to your code workings, for instance:

     if(this.src == "images/bigplay.png")
             {
                this.src = "images/bigpause.png";
                soundManager.play("mySound");
             }
             else
             {
                this.src="images/bigplay.png";
                soundManager.pause("mySound");
             }

     

    My understanding is as follows: 

     

    If when clicked the image is bigplay.png, we want to change it to bigpause.png and start playing the music (Great!!).

     

    ,but the next 2 lines I don't get:

     

    Else the image is bigplay.pn, and we tell it to pause.

     

    Shouldn't this be an elseif statement that basically says if the image is bigpause.png when clicked, then change it to bigplay.png and pause the music.

     

     

     

     

     

     

     

     

  9. Yup, soundmanager does have a native onfinish.  Its used to play a sequence of sounds, for example:

    soundManager.play('aDrumSound',{onfinish:function(){soundManager.play('aCymbalSound');}})

     

    How is setting the image tag to toggle instead of the anchor going to reset the image when its done playing?

     

    It didn't seem to work.

     

     

  10. hey all!

     

    i'm working with an mp3 streaming javascript (soundmanager2).

     

    I have a function for switching a play button to a pause button while playing and vise versa:

    <script type="text/javascript">
    var playing = false;
    
    function playMusic(soundID) {
      if (playing) {
    document.player.src='/images/bigplay.png';    
    soundManager.pause(soundID);
        playing = false;
      } else {
        soundManager.play(soundID);
        playing = true;
    
    document.player.src='/images/bigpause.png';
    
    
      }
    }
    </script>

     

    However after it finishes playing the song it does not switch back to the play button :-(

     

    I tried adding the following code based on a soundmanager event to my anchor tag, which didn't work:

     

    onfinish:function() {document.player.src='/images/bigplay.png'};

     

     

     

  11. sounds like you've had experience with this script!  i appreciate the advise!  There's something about the javascript syntax that really bugs me, like for instance:

     

     

    why does the sound manager put brackets inside parenthesis...e.g.:

    soundManager.createSound({

    id:'mySound1',

    url:'../mpc/audio/CHINA_1.mp3'

    });

     

  12. Yeah, after you said it I remebered reading that somewhere  ;D

     

    I want to write some code to switch out the play button for a pause button while the music is playing.  Can I do that in the anchor's onclick code.  Or should i place that in the head??

     

     

     

  13. I had some code working fine, that was being generated dynamically by php.  Now, I entered it manually and can't get it to work at all either by pseudo or onclick method. 

     

     

    <a href="javascript_required.html" onclick="soundManager.play('mySound','Rick.mp3')"><img src='images/bigplay.png' /></a>
    

  14. slick! 

     

    i really don't want to learn javascript but that's pretty cool.

     

    Yes, I was planning on playing multiple clips on the page... I don't want to worry about that yet.  I still have a lot of the basics to figure out here.  Thanks!

  15. This is a silly question, but google has a hard time searching for atypical characters. 

     

    Here is a line in a javascript program I am trying to understand:

     

      this.url = (smURL||'soundmanager2.swf');

     

    What is the meaning of  || ?

     

    I thought || meant OR, but that wouldn't make sense in this context.

     

     

  16. Hey all,  I love php, but am addled by this javascript.  maybe you all can help me with something simple.

    I am streaming mp3s on my site by making a call to a javascript api called soundmanager2.  This works fine: 

     

    <a href=\"javascript:soundManager.play('mySound0','/clips/RickCarterJessica.mp3')\"><img align='left' src='images/play_button.png' alt='play' /></a>

     

    However, I would like to let my visitors stop this sound from playing when they click on the link again.

  17. I run mysql 5.0.45.

     

    This LEFT JOIN works fine, on my two tables:

     

    SELECT tableA.colA,tableA.colB,tableB.colA,tableB.colB,tableBcolC 
    FROM tableA LEFT JOIN tableB ON tableA.colA=tableB.colB
    WHERE Date = '2008-05-20' ORDER BY tableBcolB ASC"; 

     

    However I now want to add a third table to this LEFT JOIN, such that TableB.colD = TableCcolB.  Do I need to use a different Syntax to do this?

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.