Start play of Object sound in MZ

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Andrew Poulos

    Start play of Object sound in MZ

    As a follow on to the 'fun' I had with IE I'm now trying to play sounds
    using an Object tag (no Embed) in MZ. Sadly whenever 'playButton' gets
    clicked MZ says that "audObj.Pla y is not a function":

    window.onload = function() {
    var audObj = document.create Element("object ");
    audObj.setAttri bute("id", "objmedia") ;
    audObj.setAttri bute("type","au dio/x-aiff");
    audObj.setAttri bute("data","me dia/aif_sample.aif" );

    audParam = document.create Element("param" );
    audParam.setAtt ribute("name"," AutoStart");
    audParam.setAtt ribute("value", "false");
    audObj.appendCh ild(audParam);

    document.body.a ppendChild(audO bj);

    document.getEle mentById("playB utton").onclick = function() {
    audObj.Play();
    //document.getEle mentById("objme dia").Play();
    }
    }


    If I change AutoStart to 'true' then the audio starts playing so this
    implies that the sound gets load correctly. Is there a way to get
    playing to start with a mouse click?

    Andrew Poulos
  • Andrew Thompson

    #2
    Re: Start play of Object sound in MZ

    On Wed, 22 Dec 2004 10:36:55 +1100, Andrew Poulos wrote:
    [color=blue]
    > document.getEle mentById("playB utton").onclick = function() {
    > audObj.Play();[/color]

    Try the lowercase version (untested)..

    audObj.play();

    --
    Andrew Thompson
    http://www.PhySci.org/codes/ Web & IT Help
    http://www.PhySci.org/ Open-source software suite
    http://www.1point1C.org/ Science & Technology
    http://www.LensEscapes.com/ Images that escape the mundane

    Comment

    • Andrew Poulos

      #3
      Re: Start play of Object sound in MZ

      Andrew Thompson wrote:
      [color=blue]
      > On Wed, 22 Dec 2004 10:36:55 +1100, Andrew Poulos wrote:
      >
      >[color=green]
      >> document.getEle mentById("playB utton").onclick = function() {
      >> audObj.Play();[/color]
      >
      >
      > Try the lowercase version (untested)..
      >
      > audObj.play();[/color]

      Tried it and various other words (start, DoPlay, run,...) no joy.

      Andrew Poulos

      Comment

      • Michael Winter

        #4
        Re: Start play of Object sound in MZ

        On Wed, 22 Dec 2004 11:30:51 +1100, Andrew Poulos <ap_prog@hotmai l.com>
        wrote:

        [snip]
        [color=blue]
        > Tried it and various other words (start, DoPlay, run,...) no joy.[/color]

        I'd expect Mozilla to only expose the standard properties of an OBJECT
        element unless perhaps a plug-in was involved, though I could be wrong.

        Mike

        --
        Michael Winter
        Replace ".invalid" with ".uk" to reply by e-mail.

        Comment

        • Andrew Poulos

          #5
          Re: Start play of Object sound in MZ

          Michael Winter wrote:
          [color=blue]
          > On Wed, 22 Dec 2004 11:30:51 +1100, Andrew Poulos <ap_prog@hotmai l.com>
          > wrote:
          >
          > [snip]
          >[color=green]
          >> Tried it and various other words (start, DoPlay, run,...) no joy.[/color]
          >
          >
          > I'd expect Mozilla to only expose the standard properties of an OBJECT
          > element unless perhaps a plug-in was involved, though I could be wrong.
          >
          > Mike
          >[/color]
          I was kind of afraid of that.

          Instead of trying to call an non-existent Play property, I could delete
          the child and then create a new OBJECT element with AutoStart set to
          true. As the sound file has already been downloaded it should be in the
          cache and therefore start playing almost immediately.

          Is this an ok way to go?

          Andrew Poulos

          Comment

          • Martin Honnen

            #6
            Re: Start play of Object sound in MZ



            Andrew Poulos wrote:
            [color=blue]
            > As a follow on to the 'fun' I had with IE I'm now trying to play sounds
            > using an Object tag (no Embed) in MZ. Sadly whenever 'playButton' gets
            > clicked MZ says that "audObj.Pla y is not a function":
            >
            > window.onload = function() {
            > var audObj = document.create Element("object ");
            > audObj.setAttri bute("id", "objmedia") ;
            > audObj.setAttri bute("type","au dio/x-aiff");
            > audObj.setAttri bute("data","me dia/aif_sample.aif" );
            >
            > audParam = document.create Element("param" );
            > audParam.setAtt ribute("name"," AutoStart");
            > audParam.setAtt ribute("value", "false");
            > audObj.appendCh ild(audParam);
            >
            > document.body.a ppendChild(audO bj);
            >
            > document.getEle mentById("playB utton").onclick = function() {
            > audObj.Play();
            > //document.getEle mentById("objme dia").Play();
            > }
            > }
            >
            >
            > If I change AutoStart to 'true' then the audio starts playing so this
            > implies that the sound gets load correctly. Is there a way to get
            > playing to start with a mouse click?[/color]

            A plugin is going to play the audio file, not the browser itself. And if
            you want to script that plugin then it needs to expose an API to the
            script. Thus whether there is any method and whether it is called 'Play'
            depends on the plugin registered with Mozilla for that MIME type
            audio/x-aiff. Unless you know your customers have a certain plugin
            installed with Mozilla and you find the documention of that plugin and
            whether and what kind of method it exposes you can't build that stuff
            reliably, it might indeed be more successful to create and insert an
            object or embed with autostart being true whenever you want a sound to
            be played. Of course even then there needs to be a plugin installed with
            Mozilla to handle that MIME type thus if you want Mozilla users on
            different platforms to be able to hear that sound then you need to do
            some research on what sound format is well supported on different platforms.


            --

            Martin Honnen

            Comment

            • Andrew Poulos

              #7
              Re: Start play of Object sound in MZ

              Martin Honnen wrote:[color=blue]
              >
              >
              > Andrew Poulos wrote:
              >[color=green]
              >> As a follow on to the 'fun' I had with IE I'm now trying to play
              >> sounds using an Object tag (no Embed) in MZ. Sadly whenever
              >> 'playButton' gets clicked MZ says that "audObj.Pla y is not a function":
              >>
              >> window.onload = function() {
              >> var audObj = document.create Element("object ");
              >> audObj.setAttri bute("id", "objmedia") ;
              >> audObj.setAttri bute("type","au dio/x-aiff");
              >> audObj.setAttri bute("data","me dia/aif_sample.aif" );
              >> audParam = document.create Element("param" );
              >> audParam.setAtt ribute("name"," AutoStart");
              >> audParam.setAtt ribute("value", "false");
              >> audObj.appendCh ild(audParam);
              >> document.body.a ppendChild(audO bj);
              >> document.getEle mentById("playB utton").onclick = function() {
              >> audObj.Play();
              >> //document.getEle mentById("objme dia").Play();
              >> }
              >> }
              >>
              >> If I change AutoStart to 'true' then the audio starts playing so this
              >> implies that the sound gets load correctly. Is there a way to get
              >> playing to start with a mouse click?[/color]
              >
              >
              > A plugin is going to play the audio file, not the browser itself. And if
              > you want to script that plugin then it needs to expose an API to the
              > script. Thus whether there is any method and whether it is called 'Play'
              > depends on the plugin registered with Mozilla for that MIME type
              > audio/x-aiff. Unless you know your customers have a certain plugin
              > installed with Mozilla and you find the documention of that plugin and
              > whether and what kind of method it exposes you can't build that stuff
              > reliably, it might indeed be more successful to create and insert an
              > object or embed with autostart being true whenever you want a sound to
              > be played. Of course even then there needs to be a plugin installed with
              > Mozilla to handle that MIME type thus if you want Mozilla users on
              > different platforms to be able to hear that sound then you need to do
              > some research on what sound format is well supported on different
              > platforms.[/color]

              Thanks for the reply. I did some research, if you could call it that, by
              googling about the internet and a number of things surprised me:
              - most of the code samples are more than 5 years old
              - there is no clear, standards compliant way to play sounds. Many big
              company sites use an EMBED tag which is non-standard. Even Microsoft
              documents a variety of ways to play sounds on Windows [yet Michael
              Winter pointed out that the TYPE attribute appears not to be able to
              actually be set.]
              - Mozilla doesn't have a solution
              - I'm tempted to put all sounds into a Flash file and then most of the
              "issues" disappear, except that Flash is proprietary.
              - I still have to "solve" it for a few other audio formats (and then I
              have to look at video)

              I wrongly imagined that these sorts of problems had been "solved" years ago.

              Andrew Poulos

              Comment

              Working...