Tips for hearing AntRadio streams in Linux - [But we prefer if you use Windows...]


Download Microsoft Windows Media Player 9 Series - Windows / MacOS / Solaris / CE - http://www.microsoft.com/windows/windowsmedia


 	
**********************************************************************
	Quick guide to using mplayer for windows media stream 
	playing under linux.
	Mark Kent.  4/12/03

	Document licence:  GNU free documentation licence.  
	Brief summary of the GNU FDL (this is not normative!):
	You can reproduce all or part of this document,
	so long as you leave my ownership of the original parts,
	and highlight those parts which are/have changed, and
	indicate the owner of those parts, and that you do not
	re-distribute under a more restrictive licence.
**********************************************************************

1. Introduction
This document briefly describes how mplayer can be used to render/ play
WMS streams on x86 linux based machines.  I do not know if this approach
will work on other architectures.

It is possible to use mplayer in both console mode from browsers such
as lynx, as well as in X.

This document was originally written by Mark Kent, after a discussion
with Marek Dziembowski regarding listening to 702 Talk Radio, which
is based in Jo'burg, South Africa.

You can contact me on mark@ellandroad.demon.co.uk.  I do not promise
acres of tech support, nor am I an mplayer or mailcap guru.   Also, 
I'm not South African, nor do I live in South Africa.

Please let me know if any changes are required, or if you have any
further information, and I will endeavour to re-issue this document
with the changes made.

Document created 4th December 03.

2. Ultra quick guide
All of this has been tested on debian stable, and debian testing/
unstable machines.  I have not tried any other than x86 architecture,
not have I tried other linux distributions.  I have no reason to believe
that these methods will not work under other distribitions.

2.1  Grab mplayer source from http://www.MPlayerHQ.hu 
You might be able to use the version of mplayer packaged with your
distribution, but many of them lack the codecs you'll need.

2.2  Get the Win32 codecs onto your linux partition  
Obviously, you can *only* do this if you have a windows machine with
these codecs[1].  You can either copy them from your windows partition,
or to make it easier, you can download the Win32 codecs from
http://www.mplayerhq.hu/MPlayer/releases/codecs/

These should be installed in /usr/lib/win32/...

Note 1.  You should only do this if you are fully confident that 
you have an appropriate licence to use this software.  

2.3 Configure & compile mplayer
./configure in the mplayer source directory will kick off the
pre-compilation stage. The result of the configure script will be a
list of which codecs and i/o devices are supported, and which are not.
Download any additional libraries you need - you need an absolute minimum
of 1 input method, 1 codec and 1 output method (eg., oss) for sound.

If you want everything mplayer can do supported, you'll probably need
to do multiple ./configures.  In debian, the development libraries are
indicated with a -dev on their name!

make & make install

2.4 Manually starting mplayer
If you don't mind starting mplayer by hand, you can download the
start-file from the website for the stream you'd like to listen to.

Try downloading this one:

http://www.antfarm.co.za/clients/702/702_16.asx

If you look inside the file, it'll look something like this:





        702 Talk Radio

        2002, Primedia Broadcasting

        Powered by The Antfarm and Internet Solutions

        Streaming radio, live from Johannesburg

	



	

	

       		702 Talk Radio

	        Powered by The Antfarm and Internet Solutions

	        2002, Primedia Broadcasting

	        Streaming radio, live from Johannesburg

	        

	        

	        

	        

	        

	        

	



Save the file locally, using the name 702_16.asx, as you'll need it in
a moment...

At this point, you can tell mplayer to use the downloaded file as a
playlist, simply by putting the filename onto mplayer's command line
as follows:

	$ mplayer 702_16.asx

mplayer will attempt to play the file as a media file first:

	Playing 702_16.asx

It will then try to use it as a playlist and start the stream:

	Falling back on trying to parse playlist 702_16.asx...

And you'll get an output like this:

Clip info:
 name: 702 Talk Radio (16k Mono Stream)
 author: Powered by the Antfarm
 copyright: 2002, Primedia Broadcasting
 comments: 702 Talk Radio - Broadcast radio from Johannesburg, South Africa
==========================================================================
Opening audio decoder: [ffmpeg] FFmpeg/libavcodec audio decoders
AUDIO: 22050 Hz, 1 ch, 16 bit (0x10), ratio: 2002->44100 (16.0 kbit)
Selected audio codec: [ffwmav2] afm:ffmpeg (DivX audio v2 (ffmpeg))
==========================================================================
Checking audio filter chain for 22050Hz/1ch/16bit -> 22050Hz/2ch/16bit...
AF_pre: af format: 2 bps, 1 ch, 22050 hz, little endian signed int 
AF_pre: 22050Hz 1ch Signed 16-bit (Little-Endian)
AO: [oss] 22050Hz 2ch Signed 16-bit (Little-Endian) (2 bps)
Building audio filter chain for 22050Hz/1ch/16bit -> 22050Hz/2ch/16bit...
Video: no video
Starting playback...
A:   3.4  0.8% 6%    

And you're off.  The dulcet tones of 702 talk radio will appear from
your loudspeakers.

2.5 Automatically starting the stream 

If you'd rather things were a little more automated than this, that is
no problem, just go through the following steps.

2.5.1 Konqueror
Start up the browser, and enter the following url in the location box:

        http://www.antfarm.co.za/clients/702/702_16.asx

At the 'Question' dialogue box, choose 'Open'.
At the Applications dialogue box, click on the blue 'file dialogue'
button to the right of the 'Open with' box.
Then put the path to your mplayer into the newly opened file
dialogue.

	/usr/bin/mplayer
	
... and click on the 'Run in terminal' tick-box at the bottom of
the dialogue box. 
Choose 'OK' to accept the settings.

I'm not a Konqueror user, so I'm not sure how to make this a permanent
setting.

2.5.2 Mozilla
For Mozilla, under Edit-Preferences->Navigator->Helper Applications
create a new mime type using the 'New' button. Put 
 	video/x-ms-asf  	in the MIME Type field
	/usr/bin/mplayer	in the Application field
		(press the 'Application' radio button).
	Click 'Okay'.
	
	This will start mplayer in the background.  You'll need
	to kill it with the command 
		$ kill $(pidof mplayer) 
	when you've finished listening.

2.5.3 Netscape (with no other browser)
If you're going to use another browser such as lynx, then skip this
bit and go on to the Lynx section below, which will work for both Lynx
and Netscape.

For Netscape 4, under Edit->Preferences->Navigator->Applications,
create a new mime type using the 'New' button.  Put 
	video/x-ms-asf  in the MIMEType field,
	asf,asx		in the suffixes field,
	xterm -e /usr/bin/mplayer '%s' in the Application box
		(you need to press the radio button to enable the box).

	This will start mplayer in an xterm, which is useful in 'audio
	playback only' mode, as you can kill it with a control-c when
	you've finished listening.

	You could just put /usr/bin/mplayer in the application box, but
	you'd have to kill radio programmes with a kill $(pidof mplayer)
	command in a term.

2.5.4 Lynx (or Lynx and Netscape)
For Lynx, and for multiple browser types such as both lynx and Netscape,
*or* if you have a networked home dir so that your dotfiles are shared
across multiple machines, then  you'll need to modify your .mailcap file.
This sounds painful, but in fact, it's dead easy.

It's also worth noting that mplayer will work just fine in the console,
so console junkies (like me) can use Lynx to stream.  

2.5.4.1 create/edit your .mailcap file
You might or might not already have a .mailcap file, if you haven't,
you can simply create one using any text editor, or with the following
console commands.

In your home directory, and logged in as yourself, do this:

echo "video/x-ms-asf; /usr/bin/xmplayer '%s'; needsterminal; test=test -z $DISPLAY" >> .mailcap
echo "video/x-ms-asx; /usr/bin/xmplayer '%s'; needsterminal; test=test -z $DISPLAY" >> .mailcap
echo "video/x-ms-asf;xterm -e /usr/bin/xmplayer '%s'; needsterminal;" >> .mailcap
echo "video/x-ms-asx;xterm -e /usr/bin/xmplayer '%s'; needsterminal;" >> .mailcap

If you already have a .mailcap, this will append these these lines to
it, if you do not, you'll get an error message on the first line, but
a .mailcap file will be created.
                                                                 
Or, if you've a text editor, use it to edit your .mailcap file and put
the following lines in (in this order):

video/x-ms-asf; /usr/bin/xmplayer '%s'; needsterminal; test=test -z $DISPLAY
video/x-ms-asx; /usr/bin/xmplayer '%s'; needsterminal; test=test -z $DISPLAY
video/x-ms-asf;xterm -e /usr/bin/xmplayer '%s'; needsterminal;
video/x-ms-asx;xterm -e /usr/bin/xmplayer '%s'; needsterminal;

2.5.4.2 Install metamail
You'll need to have metamail installed on your machine for this method to
work.  And lynx, of course.  Metalmail is part of the debian distribution,
and probably most others as well.

Links does not use the .mailcap file, so I've no idea how to make this
work with Links.  Personally, I think links should be fixed.

What's highlighted in this document is a bare bones setup.  Much more
comprehensive settings can be achieved using scripts, urlview and
more imaginative .mailcap setups.

2.6 Play some radio

You're now in a position to test your various setups.  Enter the following
url into your newly configured browser

	http://www.antfarm.co.za/clients/702/702_16.asx

With a following wind, you should now be sailing away to the dulcet
tones of 702 talk radio.

3. Are there other ways of doing this?
I understand that xine may also be able to play wms streams, but it
would also need the appropriate codecs.

You could consider using an MS Windows machine.

You could try wine and MS's media player.

You could try cross-over office and MS's media player.

Buy a radio. :-)

4.  Will  be available in ogg, mp3 or real?

Here is what Marek said to me on this subject, when I asked this question
with regards to 702 talk radio:

	"Unfortunately we don't get enough request to justify the expense
	of deploying an oggs / mp3s / real stream service - with regards
	to hardware and hosting space.

	The option is always open - but based on requests for the service,
	which to date have been very low."

So there you have it.  If enough people are interested, it might happen
in the future, but /please/ be polite when asking, and if the answer is
'no' or 'not yet', express your disappointment in a non- confrontational
manner.  Okay, we all get irritated, but write your response when you've
relaxed a bit :-)  Linux will get far more support if its proponents
are pleasant to deal with.

It's probably worth pointing out to any radio stations you talk to
that the Microsoft streaming format is proprietary, so that those
people without a licence will not be able to listen to their station on
non-Windows machines.  Most radio stations are funded by advertising, so
that if enough people are wanting to listen, but cannot due to technical
lock-out, then the stations may be prepared to stream in other formats
to keep up their advertising revenues.

Please don't over-Evangelise, though!

5. What about other formats and lynx? 

With careful manipulation of the .mailcap file, and construction of
a couple of simple scripts, and the urlview programme, it's possible 
to use Lynx to stream mp3 and ogg (okay, strictly speaking, to start
the streaming process).  You need mpg123 for mp3 streams, ogg123 for
ogg streams, and TRplayer can be used to stream realmedia streams 
from the console too.  

The basic principle is to use urlview to find the URLs within the
playlists, then by setting your media player as $BROWSER, your
media player will be started by urlview. 

For some unusual streams, mpg123 struggles, but you can still get
copies of the 'listen' programme developed by the icecast guys which
can be used to manage the stream (but has other limitations).

I created a script which allows me to choose between various 
different streaming programmes.

6. End.
Hope it helped you - Mark.