Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Web and WebWorks Development

Reply
Highlighted
Developer
Posts: 16
Registered: ‎10-18-2010
My Device: Not Specified
Accepted Solution

Sound will NOT play.

I have scanned a few threads here about sound some claim to have fixes but nothing has worked for me so far.

 

From my config.xml

 

  <feature id="blackberry.audio.Player" />

Script:

var playerInstance = new  blackberry.audio.Player("local:///woosh.mp3","audio/mpeg", true); playerInstance.play();

 

I've tried adding the playerInstance.play(); tag to where I need it within my app but it always fails even on actual devices. Is there something obvious that I am missing or is the API broken?

Developer
Posts: 164
Registered: ‎08-26-2010
My Device: Not Specified

Re: Sound will NOT play.

First, put these 2 lines of the feature element completely:

 

<feature id="blackberry.audio" version="1.0.0.0"/> 
<feature id="blackberry.audio.Player" version="1.0.0.0"/> 

 Second, put the mp3 file in the root folder of your application.

New Developer
Posts: 13
Registered: ‎10-19-2010
My Device: 9000
My Carrier: AT&T

Re: Sound will NOT play.

This works for me:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>File I/O Example</title>
    <meta name="HandheldFriendly" content="True" />

    <script type="text/javascript">
      var playerInstance;
        function initialLoad() {
          playerInstance = new  blackberry.audio.Player("local:///sounds/beep.mp3","audio/mpeg", true); 
          // Hint: crashes here if file isn't found
          // despite posting below, it does NOT have to be at the root
          // this will NOT work if your surf to this page - you MUST be embedded and MUST be (i guess) on your original page.
              
        }
    </script>
</head>
<body onload="initialLoad()">
  <a href="javascript&colon;playerInstance.play();">play</a>
  
  <br/>Amazingly, this works.  
  
  <p>
    see: http://supportforums.blackberry.com/t5/Web-and-WebWorks-Development/Sound-will-NOT-play/td-p/1098623
</body>
</html>