×

Discussion Board

Page 1 of 2 12 LastLast
Results 1 to 15 of 16

Thread: radio streaming

  1. #1
    Regular Contributor
    Join Date
    Mar 2007
    Posts
    54

    radio streaming

    Hi im trying to stream this following link: http://shoutcast.com/sbin/shoutcast-...e=filename.pls
    and/or

    http://mediaweb.musicradio.com/Playlist.asx?StreamID=8 but it fails on realizing the player with an exception indicating realize failed.

    my code is this

    Code:
    debug.append("creating the player using url of " + url + "\n");
                player = Manager.createPlayer(url);
             
                debug.append("Player has been created  and now realizing the player  \n");
                player.realize();        
                debug.append("realize state and now setting it up for prefetch \n");
                player.prefetch();
                debug.append("prefetch state and going to start the playback\n");
     
    //debug is a Form displaying what is happening in the background

  2. #2
    Super Contributor
    Join Date
    Apr 2003
    Location
    USA, CA
    Posts
    7,191

    Re: radio streaming

    That file is a playlist, not a stream. You need to download that pls-file, parse the contents and open a correct stream URL.

    ALso make sure that the device in question suppoorts http-streaming as the URLs in the playlist are all http based. Which device are you using?

    Hartti

  3. #3
    Regular Contributor
    Join Date
    Mar 2007
    Posts
    54

    Re: radio streaming

    im using a motorola v9 device. how would i parse info from the pls file? i have downloaded the file on a desktop pc and opened it in notepad and the content of the file is somthing like this:

    [playlist]
    numberofentries=21
    File1=http://scfire-nyk-aa05.stream.aol.com:80/stream/1071
    Title1=(#1 - 66/500) -=[:: HOT 108 JAMZ ::]=- #1 FOR HIP HOP - 128K HD) * CONNECT FROM OUR WEBSITE ......


    do i use this link "http://scfire-nyk-aa05.stream.aol.com:80/stream/1071" and make a normal http connection? how would i specify and know the stream time when using Player.CreatePlaye("http://scfire-nyk-aa05.stream.aol.com:80/stream/1071", "audio/mp3")
    Last edited by jonneymendoza; 2008-04-01 at 10:56.

  4. #4
    Super Contributor
    Join Date
    Apr 2003
    Location
    USA, CA
    Posts
    7,191

    Re: radio streaming

    The playlist contents really looks that way. If those URLs are mp3 files then you are on the right track!

    Hartti

  5. #5
    Registered User
    Join Date
    Mar 2003
    Posts
    9

    Re: radio streaming

    Quote Originally Posted by hartti View Post
    That file is a playlist, not a stream. You need to download that pls-file, parse the contents and open a correct stream URL.

    ALso make sure that the device in question suppoorts http-streaming as the URLs in the playlist are all http based. Which device are you using?

    Hartti
    Http streaming is supported only for audio/amr and audio/amr-nb(?) and only for S60 3rd FP1 devices. AFAIK

  6. #6
    Registered User
    Join Date
    Sep 2008
    Posts
    9

    Re: radio streaming

    I am facing the same problem. seems I am not able to stream by using the link from pls-file.
    for instance: http://213.251.141.62:8006
    and such an error thrown out:
    javax.microedition.media.MediaException: Cannot create a Player for: Unsupported content type

  7. #7
    Nokia Developer Champion
    Join Date
    Nov 2007
    Location
    Rome, Italy
    Posts
    2,406

    Re: radio streaming

    Hi popeztl,

    error message is self-explaining: you're trying to stream a file whose format is not supported on the device itself.

    You can refer to this document to check supported media types on Nokia devices:

    http://www.forum.nokia.com/info/sw.n..._0_en.xls.html

    Pit

  8. #8
    Registered User
    Join Date
    Sep 2008
    Posts
    9

    Re: radio streaming

    hey jappit,

    thanks for ur reply. I was trying to do it on Nokia N95. and the stream content type is aacp. which should be support by N95.

    I am guessing if it is because the handset can not recognize the content type of the source.
    Last edited by popeztl; 2008-10-02 at 11:08.

  9. #9
    Super Contributor
    Join Date
    Apr 2003
    Location
    USA, CA
    Posts
    7,191

    Re: radio streaming

    aacp... do not think so.
    aac instead, yes

    http://www.forum.nokia.com/info/sw.n..._0_en.xls.html

    Hartti

  10. #10
    Registered User
    Join Date
    Sep 2008
    Posts
    9

    Re: radio streaming

    hey hartti,

    I am quite sure that N95 do support AAC+.
    check this link
    http://www.forum.nokia.com/devices/N95

  11. #11
    Super Contributor
    Join Date
    Apr 2003
    Location
    USA, CA
    Posts
    7,191

    Re: radio streaming

    Ok, so my answer was too cryptic one.

    According to the document I referred to Java ME on N95 supports AAC+, yes.
    But.
    File extension is aac
    and MIME type is audio/aac

    Do you use these?

    Hartti

  12. #12
    Registered User
    Join Date
    Sep 2008
    Posts
    9

    Re: radio streaming

    Hey Hartti,

    thanks for ur helping. I guess I didn't discribe the problem clearly. Actually the problem is I was trying to stream a radio from a pls-file's link. The content type and format are not declared at all.

    url = "http://www.***.com:8032/";
    player = Manager.createPlayer(url);

    and such an error thrown out:
    javax.microedition.media.MediaException: Cannot create a Player for: Unsupported content type.

    I have no idea how to achieve my idea. Could you give me any advisory?

  13. #13
    Regular Contributor
    Join Date
    Mar 2008
    Posts
    51

    Re: radio streaming

    Quote Originally Posted by popeztl View Post
    Hey Hartti,

    thanks for ur helping. I guess I didn't discribe the problem clearly. Actually the problem is I was trying to stream a radio from a pls-file's link. The content type and format are not declared at all.

    url = "http://www.***.com:8032/";
    player = Manager.createPlayer(url);

    and such an error thrown out:
    javax.microedition.media.MediaException: Cannot create a Player for: Unsupported content type.

    I have no idea how to achieve my idea. Could you give me any advisory?
    hi popezt,
    Unsupported content type means that the media format not supported by the device/emulator. have u check what supported content type of ur device/emulator ? and dont forget about the codec too. u must read the device spesification about audio/video codec. i mention this in this thread too if u want to read that :
    http://discussion.forum.nokia.com/fo...d.php?p=489688


    may it helps
    -regards-
    adek aidi

  14. #14
    Registered User
    Join Date
    Feb 2009
    Posts
    6

    Talking Re: radio streaming

    Hi ,
    I am also presently working on the same the theme is i achieved the first step of retrieving the player and playing the song in the mobile here i used the PHP interaction to buffer the data so it is taking more than 15 min to play the song and i observed that it is supporting progressive download. that means it storing the data in to the memory then after it is playing here i set time limit as 24 mins i am sending my code of mine will any one help please..........
    This is the PHP server side coding


    <?
    set_time_limit(1440);

    $all_channels='';

    function parse_radios($xmldata) {

    global $all_channels;

    $channelgroup='';


    $xmldata = mb_convert_encoding($xmldata, "utf-8");
    $xmldata = preg_replace('/&(?![#]?[a-z0-9]+/i', "+", $xmldata);


    $xml = new XMLReader();
    $xml->XML($xmldata);

    while ($xml->read()) { if ($xml->name == "mr") { // "Records"

    $count=0;

    while($xml->read()) {


    if ($xml->name == "channel_group") { // "SubIdStatisticRecord"

    if ($xml->hasAttributes) {

    $channelgroup=$xml->getAttribute("title");

    }

    }else
    if ($xml->name == "channel") { // "SubIdStatisticRecord"

    if ($xml->hasAttributes) {

    $count++;

    //if ($count<500) {
    $all_channels .= $channelgroup.";".mb_convert_encoding($xml->getAttribute("title"), "ISO-8859-1", "utf-8").";".$xml->getAttribute("url")."\n";
    //}
    }
    }

    } //while




    } //if mr


    } //while oberste





    }



    /************************************************************************************************
    Start main program
    *************************************************************************************************/


    $playradio_url = strip_tags($_GET['play']);
    $client_id = strip_tags($_GET['clientid']);

    $rlist = strip_tags($_GET['rlist']);



    if ( ( ($playradio_url!="") && ($client_id!="") ) || ($rlist!="") )
    {


    if ($rlist!="") { //Radioliste laden

    $handle = fopen("mr.xml", "rb");
    $contents = '';
    while (!feof($handle)) {
    $contents .= fread($handle, 8192); //8192
    }
    fclose($handle);


    parse_radios($contents);


    echo $all_channels;


    } else { //play Radio


    $starttime=time();


    $urlpathstart = strpos($playradio_url,"/",7);

    if ($urlpathstart=="") $urlpathstart=strlen($playradio_url);

    $urlportstart = strripos($playradio_url,":",7);



    if ($urlportstart!=0) {

    $host = substr($playradio_url,7, ($urlportstart-7) ); // length 3. param

    } else
    $host = substr($playradio_url,7, ($urlpathstart-7) ); // length 3. param



    $port=80;

    if ($urlportstart!=0) {

    $port = substr($playradio_url, $urlportstart+1, ($urlpathstart-$urlportstart)-1);

    }


    if ($urlpathstart==strlen($playradio_url)) { $path="/"; } else
    $path = substr($playradio_url, $urlpathstart, strlen($playradio_url)-$urlpathstart+1 );


    //echo "host ", $host, " <br>" ;
    //echo "port ", $port, " <br>" ;
    //echo "path ", $path, " <br>" ;


    //1 ICY 200 OK
    //2 icy-notice1:
    //This stream requires Winamp

    //3 icy-notice2:SHOUTcast Distributed Network Audio Server/Linux v1.9.8

    //4 icy-name:Radioseven - www.radioseven.se
    //5 icy-genreance Trance House
    //6 icy-url:http:www.radioseven.se
    //7 content-type:audio/mpeg
    //8 icy-pub:1
    //9 icy-br:128
    //10
    //11 Musikdaten





    $fp = fsockopen($host, $port, $errno, $errstr, 30) or die("Unable to connect to server!");


    $buf = "GET ".$path." HTTP/1.0\r\nIcy-MetaData:0\r\n\r\n";
    fwrite($fp, $buf);

    //get next line
    $buf = fgets($fp, 1024);


    //while pointer is not at EOF
    //get next line
    $buf = fgets($fp, 1024);

    //delete trash (shoutcast headers)
    $buf = fgets($fp, 1024);
    $buf = fgets($fp, 1024);
    $buf = fgets($fp, 1024);
    $buf = fgets($fp, 1024);
    $buf7 = fgets($fp, 1024); //Datentyp
    $buf = fgets($fp, 1024);
    $buf = fgets($fp, 1024);
    $buf = fgets($fp, 1024);


    if ($buf == "\r\n") {
    // echo "break";
    //break;
    // Zeile 10 leere Zeile, ab 11 Daten

    }





    header('Content-Length: 50000000');
    //header('Content-type: audio/mpeg');
    header($buf7);

    $timeover=0;

    while ( (!feof($fp)) && ($timeover==0) ) {


    //echo $buf;


    //$fout = fopen("dump" .$client_id. ".mp3", "w");

    while (!feof($fp)) {

    if ( (time()-$starttime)>1440) { //1440s 24 min

    $timeover=1;
    break;

    }

    $buf = fread($fp, 512); //512 music data
    // fwrite($fout, $buf);
    echo $buf;

    }

    }


    fclose($fp);



    } //play radio




    } //params






    ?>


    This one is the server side xml file

    <mr start="1">
    <channel_group id="9980" title="Techno">
    <channel id="2339" genre="g" title="T4E" url="http://89.146.206.12:8000/" />
    <channel id="2213" genre="g" title="TechnoBase.FM" url="http://78.159.104.181:80/" />
    <channel id="2337" genre="g" title="Pulsradio" url="http://91.121.96.201:5000/" />
    <channel id="2337" genre="g" title="RadioSeven.se" url="http://212.247.153.210:8001/" />

    </channel_group>


    </mr>

  15. #15
    Registered User
    Join Date
    Feb 2009
    Posts
    6

    Talking Re: radio streaming

    This is the RMS in j2me



    import java.io.*;
    import java.util.*;
    import javax.microedition.rms.*;

    public class RMSCache {

    private final String mName;
    private Hashtable mMap;

    public RMSCache(String name) throws RecordStoreException {
    mName = name;
    read();
    }

    // Public methods.
    public void set(String key, String value)
    throws RecordStoreException {
    Object old = mMap.put(key, value);
    if (old == null || !old.equals(value))
    write();
    }

    public void remove(String key) throws RecordStoreException {
    if (mMap.remove(key) != null)
    write();
    }

    public String get(String key) {
    return (String)mMap.get(key);
    }

    // Implementations.
    private void read() throws RecordStoreException {
    RecordStore rs = RecordStore.openRecordStore(mName, true);
    mMap = new Hashtable();
    try {
    RecordEnumeration re =
    rs.enumerateRecords(null, null, false);
    while (re.hasNextElement()) {
    byte[] record = re.nextRecord();

    parseRecord(record);
    }
    }
    finally { rs.closeRecordStore(); }
    }


    private void parseRecord(byte[] record) {
    try {
    ByteArrayInputStream raw =
    new ByteArrayInputStream(record);
    DataInputStream in = new DataInputStream(raw);
    String key = in.readUTF();
    String value = in.readUTF();
    mMap.put(key, value);
    }
    catch (IOException ioe) {
    System.out.println("Bad record in " + mName + ".");
    }
    }


    private void write() throws RecordStoreException {
    // Draconian: delete the old one, write a new one.
    try { RecordStore.deleteRecordStore(mName); }
    catch (RecordStoreNotFoundException rsfe) {} // No problem.
    RecordStore rs = RecordStore.openRecordStore(mName, true);
    try {
    Enumeration keys = mMap.keys();
    while (keys.hasMoreElements()) {
    String key = (String)keys.nextElement();
    String value = (String)mMap.get(key);
    try {
    byte[] record = packRecord(key, value);
    rs.addRecord(record, 0, record.length);
    }
    catch (IOException ioe) {
    System.out.println("Error packing in " + mName + " : " +
    key + " -> " + value);
    }
    }
    }
    finally { rs.closeRecordStore(); }
    }


    private byte[] packRecord(String key, String value)
    throws IOException {
    ByteArrayOutputStream raw = new ByteArrayOutputStream();


    DataOutputStream out = new DataOutputStream(raw);
    out.writeUTF(key);
    out.writeUTF(value);
    return raw.toByteArray();
    }

    }



Similar Threads

  1. Download java based streaming radio
    By srinivasvurrinkala in forum Mobile Java Media (Graphics & Sounds)
    Replies: 3
    Last Post: 2009-03-26, 16:45
  2. Can I streaming Video from internet on S60 3rd edition?
    By jianyu_21 in forum Mobile Java Media (Graphics & Sounds)
    Replies: 8
    Last Post: 2008-04-25, 05:15
  3. 3gp streaming to Nokia 6680/6630
    By wasbo in forum Streaming and Video
    Replies: 23
    Last Post: 2007-04-24, 11:23
  4. Streaming EDGE clip in GPRS coverage
    By zivs in forum Streaming and Video
    Replies: 0
    Last Post: 2006-08-22, 17:22
  5. Audio Streaming in J2ME....
    By senthilkumar05 in forum Mobile Java Media (Graphics & Sounds)
    Replies: 1
    Last Post: 2006-02-22, 14:05

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×