|
How to play Internet streams and radio stations |
![]() ![]()
|
There are three main types of Internet stream:
These streams cannot be loaded through the LoadSound method: for this purpose you must use the LoadInternetStream method which gives the possibility to pass a URL in place of a pathname. Let's see how to manage these different streams.
By default Internet streams are buffered inside a buffer having a length of 5 seconds: you may change this buffer using the SetInternetBufferLength method and obtain the current length using the GetInternetBufferLength method.
Broadcasting streams
Internet radio is a broadcasting service which transmits one or more sound streams via the Internet: for this kind of streams, the control will connect to the remote server and will fire the following sequence of events:
Immediately after starting playback, the control will fire again the DownloadBuffering event with its nState parameter set to STREAMING_PLAYING: note that, during the playback session, the control will continue buffering data from the Internet: if for any reason, for example for a slow connection, the download should stall, the control will notify the container application firing again the DownloadBuffering event with the nState parameter set to STREAMING_BUFFERING: when there will be again enough data to play, the control will automatically resume playback notifying the container application through the DownloadBuffering event with the nState parameter set to STREAMING_PLAYING.
After a stall situation, the Internet stream provider could also close the connection: in this case the control will fire the ServerClosed event.
During playback, the server will usually send information about the radio station and about the song in playback: the control has the capability to notify in real-time the availability of this information, usually called "tags", and to retrieve the various strings composing the same tag: for this purpose the control will fire the MetaTagChanged event: at this point the container application will have the possibility to perform the following sequence of tasks:
Sound files available on a web site
Loading a sound file from a web site is mostly identical to loading a broadcast stream with the following differences:
Playlists which main contain more broadcasting streams and/or sound files
Many radio stations will play a small intro before starting playback of the real broadcasting streams: some achieve this by loading a playlist (usually in ASX or PLS format) which contains the URL pointing to the intro message (usually a WMA or MP3 file stored inside the server) followed by the real URL of the broadcasting stream.
In some cases the playlist may point to other nested playlists: in this case our component will try to manage the situation by updating the playlist with new contents of the nested playlist.
When dealing with playlists, most of events fired by the component will be identical to the ones described for broadcasting streams and for sound files with the following differences:
A sample of access to Internet streams in Visual C# and Visual Basic.NET can be found inside the following sample installed with the product's setup package: - InternetRadio
|