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
Posts: 120
Registered: ‎05-20-2011
My Device: Touch 9800
My Carrier: Vodafone

Streaming audio from the URL

Hello Members,

I am building an application that will stream media basically an audio(radio streaming) from the url.

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

 

Now , my problem is that this code works pretty good on WIFI mode but when i try using data plan i.e. BIS plan the player does not stream anymore.

 

I even tried to invoke the j2me player and then tested using BIS plan but it also fails. PFB the code for it:-

 

public class AudioPlayer extends MainScreen {
    Player player;
    VolumeControl volumeControl;
    String url;
    
    public AudioPlayer() {
        super(NO_VERTICAL_SCROLL);
                
        url = "http://www.onlinepc.com.au/audio/wod.mp3";

        AudioThread audio = new AudioThread(this);
        audio.start();
    }

    VolumeControl getVolumeControl( Player p ) {
        return (VolumeControl)p.getControl( "VolumeControl" );
    }

    public void stopAudio() {
        if(player != null) {
            try {
                if (volumeControl != null)
                    volumeControl.setLevel(0);
                player.stop();
            } catch (MediaException e) {
            }
        }
    }

    protected boolean onSavePrompt() {
        // Suppress the save dialog
        return true;
    }     
    
    public boolean onClose() {
        stopAudio();
        return super.onClose();
    }        
}

class AudioThread extends Thread {
    AudioPlayer mainscreen;
    AudioThread(AudioPlayer mainscreen) {
        this.mainscreen = mainscreen;
    }

    public void run() {
        try {
            mainscreen.url += ";deviceside=true";
            mainscreen.player = javax.microedition.media.Manager.createPlayer( mainscreen.url );
            mainscreen.player.realize();
            
            mainscreen.volumeControl = mainscreen.getVolumeControl(mainscreen.player);

            if (mainscreen.volumeControl != null)
                mainscreen.volumeControl.setLevel(100);
            
            mainscreen.player.prefetch();
            mainscreen.player.start();
        } catch (Exception e) {
        }
    }
}

 

Can anybody suggests me what will be the best way to stream audio using BIS plan. I have found many apps that frequently run on BIS plan,

Thanks and waiting for your assistance......

Amar