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
Developer
hades_6
Posts: 178
Registered: ‎08-26-2009
My Device: Not Specified

Re: Graphical UI for Audio Streaming

If your phone is running on EDGE and not 3G, I don't think streaming would be possible cause it'll be way too slow.

Please use plain text.
Developer
lovish
Posts: 70
Registered: ‎11-24-2009
My Device: Not Specified

Re: Graphical UI for Audio Streaming

Hi Hades,

 

We all were facing the read blocks when we run the app on emulator and that too when we play multiple songs back to back something like maintaining a playlist

 

We havent tested the app on actual device as the app will need cde signing and it may take some time

 

Thanks,

Lovish

Please use plain text.
Developer
lovish
Posts: 70
Registered: ‎11-24-2009
My Device: Not Specified

Re: Graphical UI for Audio Streaming

I have tested the app on device using the wifi interface and have not faced any read block

So this problem is with the simulator only.

 

Refer to my earlier posts that talk abt the suffix to add in the URL

 

Thanks,

Lovish

Please use plain text.
Developer
hades_6
Posts: 178
Registered: ‎08-26-2009
My Device: Not Specified

Re: Graphical UI for Audio Streaming

[ Edited ]

Lovish, could you post your code? I'm facing a few issues now, after the 2nd song the app crashes...also when you switch the song do you create a new limitedsource stream?

Please use plain text.
Developer
hades_6
Posts: 178
Registered: ‎08-26-2009
My Device: Not Specified

Re: Graphical UI for Audio Streaming

Lovish,

 

The app works fine on the simulator but not on the actual device? Any idea why?? I play the first song which works perfectly but then the moment i switch to the next song I get a read block. I use the interface=wifi as well. I reduced the read_chunk variable to 512bytes.

Please use plain text.
Developer
lovish
Posts: 70
Registered: ‎11-24-2009
My Device: Not Specified

Re: Graphical UI for Audio Streaming

Hi Hades,

 

You may want to read the available bytes only

 

int nAvailable = 1;
int nLength = 0;

 

nAvailable = m_StreamForHttp.available();
byte[] data = new byte[nAvailable];
nLength = stream.read(data,0,nAvailable);

 

I am doing this way.

 

As for the crash, I think its better to clean the last instance of the playback before starting the next song.

 

Hope this helps!!

Please use plain text.
Developer
hades_6
Posts: 178
Registered: ‎08-26-2009
My Device: Not Specified

Re: Graphical UI for Audio Streaming

Hi Lovish,

 

Thanks for that code, but my problem is closing the stream. How do you close the stream when switching to the next song?

 

 

if (_source != null)
			{				
				_source.stop();
				_source.disconnect();
				_source = null;				
			}

 

 

when I say stop which is suppose to stop the ConnectionThread, it gives me an exception. Any idea why?

Please use plain text.
Developer
lovish
Posts: 70
Registered: ‎11-24-2009
My Device: Not Specified

Re: Graphical UI for Audio Streaming

I am assuming that your _source is StreamingMediaSource class and that extends DataSource.

 

So the function that clean the last instance is like this

 

public void cleanLast()
    {
        if (Player != null) <------ your j2me player
        {
            try
            {
                Player.stop();
            }
            catch (MediaException e)
            {
                System.out.println(e.getMessage());
            }
            Player = null;
        }
        
        if(_source != null)
        {
            try
            {
                _source.stop();
            }
            catch (IOException e)
            {
                System.out.println(e.getMessage());
            }
            _source.disconnect();
            _source = null;
        }
    }

 

Now your stop method of StreamingMediaSource class would just stop the downloader thread

 

disconnect method will be like

 

public void disconnect()
    {
        try
        {
            if (httpStrm != null)  <----------- SharedInputStream that reads from network
            {
                httpStrm.close();
                httpStrm = null;
            }


            if(conn != null) <----------- your http connection created using the URL
            {
                conn.close();
                conn = null;
            }
            if(playerStrm != null)
            {
                playerStrm.close();
                playerStrm = null;
            }
           stopDownloadThread = true;
            
        }
        catch (IOException e)
        {
            System.err.println(e.getMessage());
        }        
    }

 

Please let me know if that helps. Looking to start my kudos account :smileywink:

Please use plain text.
Developer
hades_6
Posts: 178
Registered: ‎08-26-2009
My Device: Not Specified

Re: Graphical UI for Audio Streaming

That's exactly what I do. :smileysad:

Please use plain text.
Developer
lovish
Posts: 70
Registered: ‎11-24-2009
My Device: Not Specified

Re: Graphical UI for Audio Streaming

hmm..

What exception are you getting ?

Please use plain text.