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

Java Development

Reply
New Developer
hobby_johals
Posts: 120
Registered: ‎05-20-2011
My Device: Touch 9800

Problem in playing audio file from URL

Hello members

I have an issue while playing an audio file from the URL.Please Help me out

 

i am getting Critical Tunnel Failure Exception

 

Here is my code snippet

 

 private class AudioPlaybackDemoScreen extends MainScreen
    {    
        public AudioPlaybackDemoScreen()
        {
            
            UiApplication.getUiApplication().invokeLater(new Runnable() {
                
                public void run() {
                    // TODO Auto-generated method stub
                    // put your code here.
                    
                    try
                    {
                        Player p = javax.microedition.media.Manager.createPlayer("http://www.emp3world.com/to_download.php?id=124217");
                        p.realize();
                        VolumeControl volume = (VolumeControl)p.getControl("VolumeControl");
                        volume.setLevel(30);
                        p.prefetch();
                        p.start();
                 
                    }
                    catch(MediaException me)
                    {
                        Dialog.alert(me.toString());
                    }
                    catch(IOException ioe)
                    {
                        Dialog.alert(ioe.toString());
                    }
                }
            });

 


      }
     }

 

Please let me know if someone has any ideas           

Thanks

Amar
Please use plain text.
New Developer
hobby_johals
Posts: 120
Registered: ‎05-20-2011
My Device: Touch 9800

Re: Problem in playing audio file from URL

Thnx i have solved my solution

Amar
Please use plain text.
Contributor
raj_eemtec
Posts: 10
Registered: ‎09-18-2012
My Device: 9650

Re: Problem in playing audio file from URL

I am stuck with the same can u please help. how u solve it?

Please use plain text.
New Developer
hobby_johals
Posts: 120
Registered: ‎05-20-2011
My Device: Touch 9800

Re: Problem in playing audio file from URL

Use this code and then pass the url to the player:

 


                                    ConnectionFactory cf;

                                      int[] preferredTransportTypes = { TransportInfo.TRANSPORT_WAP2,
                                       TransportInfo.TRANSPORT_TCP_WIFI,
                                       TransportInfo.TRANSPORT_TCP_CELLULAR };
                                       int[] disallowedTransportTypes = { TransportInfo.TRANSPORT_BIS_B,
                                       TransportInfo.TRANSPORT_MDS, TransportInfo.TRANSPORT_WAP };
                                       cf = new ConnectionFactory();
                                       cf.setPreferredTransportTypes(preferredTransportTypes);
                                       cf.setDisallowedTransportTypes(disallowedTransportTypes);
                                      
                                       ConnectionDescriptor cd = cf.getConnection(serviceUrl1);
                                       String serviceUrl = cd.getUrl();

 

service url will be the url that u will pass to the player.

Or you try this code works very fine.

http://supportforums.blackberry.com/t5/Java-Development/Streaming-media-Start-to-finish/ta-p/488255

 

Please press kudos if your problem is solved.

Amar
Please use plain text.
Contributor
raj_eemtec
Posts: 10
Registered: ‎09-18-2012
My Device: 9650

Re: Problem in playing audio file from URL

Thanks dude. Works great

Please use plain text.