Loading ...
Sorry, an error occurred while loading the content.

svg button sound

Expand Messages
  • mizztina21
    i am using netbeans 6.8 to develop my mobile application in j2me. can anyone help me how to make the svg button play a sound when it is clicked.
    Message 1 of 5 , Mar 13, 2010
    • 0 Attachment
      i am using netbeans 6.8 to develop my mobile application in j2me.
      can anyone help me how to make the svg button play a sound when it is clicked.
    • coreymwamba
      ... Yes [I think]! If it s a one-off sound then you can link the button and the sound easily... __________________________
      Message 2 of 5 , Mar 15, 2010
      • 0 Attachment
        --- In svg-developers@yahoogroups.com, "mizztina21" <mizztina21@...> wrote:
        >
        > i am using netbeans 6.8 to develop my mobile application in j2me.
        > can anyone help me how to make the svg button play a sound when it is clicked.
        >

        Yes [I think]! If it's a one-off sound then you can link the button and the sound easily...
        __________________________

        <audio begin="button.click" [other attributes...] />
        <circle id="button" [other attributes...] />
        __________________________

        If you want to control it, it's slightly more complicated... I started a thread here a couple of weeks ago, you might want to have a look at that.

        C.
      • coreymwamba
        Hello again, I ll write a longer example. The concept here is that the audio is linked to the shape [or group of shapes] you draw. I ll draw a circle:
        Message 3 of 5 , Mar 15, 2010
        • 0 Attachment
          Hello again,

          I'll write a longer example.

          The concept here is that the audio is linked to the shape [or group of shapes] you draw.

          I'll draw a circle:


          <svg width="91" height="91" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/2000/svg">

          <g id="button">
          <circle stroke-width="5" stroke="#000000" fill="#FF0000" id="button" r="38.81004" cy="45.31004" cx="45.81004" />
          </g>
          </svg>

          So then I need to call up the audio, say the file is called sound.ogg: this goes into your code like this:

          <svg width="91" height="91" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/2000/svg">

          <audio xlink:href="sound.ogg" type="audio/vorbis" begin="button.click" dur="10s" repeatCount="1" />
          <g id="button">
          <circle stroke-width="5" stroke="#000000" fill="#ff0000" r="38.81004" cy="45.31004" cx="45.81004" />
          </g>
          </svg>

          That's it. When the circle group called "button" is clicked by the mouse, the sound plays.

          Is that clearer?

          C.







          --- In svg-developers@yahoogroups.com, "coreymwamba" <coreymwamba@...> wrote:
          >
          >
          >
          > --- In svg-developers@yahoogroups.com, "mizztina21" <mizztina21@> wrote:
          > >
          > > i am using netbeans 6.8 to develop my mobile application in j2me.
          > > can anyone help me how to make the svg button play a sound when it is clicked.
          > >
          >
          > Yes [I think]! If it's a one-off sound then you can link the button and the sound easily...
          > __________________________
          >
          > <audio begin="button.click" [other attributes...] />
          > <circle id="button" [other attributes...] />
          > __________________________
          >
          > If you want to control it, it's slightly more complicated... I started a thread here a couple of weeks ago, you might want to have a look at that.
          >
          > C.
          >
        • Erik Dahlstrom
          On Mon, 15 Mar 2010 19:49:27 +0100, coreymwamba wrote: ... The type should be audio/ogg if you want to give a hint to the viewer,
          Message 4 of 5 , Mar 16, 2010
          • 0 Attachment
            On Mon, 15 Mar 2010 19:49:27 +0100, coreymwamba <coreymwamba@...>
            wrote:

            ...
            > <audio xlink:href="sound.ogg" type="audio/vorbis" begin="button.click"
            > dur="10s" repeatCount="1" />
            > <g id="button">
            > <circle stroke-width="5" stroke="#000000" fill="#ff0000" r="38.81004"
            > cy="45.31004" cx="45.81004" />
            > </g>
            > </svg>

            The type should be "audio/ogg" if you want to give a hint to the viewer,
            see[1].

            If you want the audio-clip to be of the same length as the file (that is:
            if you don't want to limit it to some other duration), specify dur="media"
            instead.

            Cheers
            /Erik

            [1] http://wiki.xiph.org/MIME_Types_and_File_Extensions

            --
            Erik Dahlstrom, Core Technology Developer, Opera Software
            Co-Chair, W3C SVG Working Group
            Personal blog: http://my.opera.com/macdev_ed
          • coreymwamba
            ... Thanks, I did not know that... I was following the spec example at http://www.w3.org/TR/2004/WD-SVG12-20041027/media.html ... I didn t know that either:
            Message 5 of 5 , Mar 16, 2010
            • 0 Attachment
              --- In svg-developers@yahoogroups.com, "Erik Dahlstrom" <ed@...> wrote:

              > The type should be "audio/ogg" if you want to give a hint to the viewer

              Thanks, I did not know that... I was following the spec example at http://www.w3.org/TR/2004/WD-SVG12-20041027/media.html

              > If you want the audio-clip to be of the same length as the file (that is:
              > if you don't want to limit it to some other duration), specify dur="media"
              > instead.
              >

              I didn't know that either: very handy!
            Your message has been successfully submitted and would be delivered to recipients shortly.