Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 streamMP3 from the internet
Index -> Programming, Turing -> Turing Submissions
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
ecliptical




PostPosted: Thu Dec 22, 2005 2:19 am   Post subject: streamMP3 from the internet

I might spend a little more time with this and make a little media player.
Ya I know nothing to special as far as the progress bar is concerned...but i haven't figured that part out yet...and there is also some distortion in the mp3 like with the images..so I suspect Tony was right in that i should do this using binary i'll give it a shoot later..
code:

procedure playMP3
    loop
        Music.PlayFile ("test.mp3")
    end loop
end playMP3

procedure streamMP3 (url : string)
    var count : int := 0
    var progress : int
    var netStream : int
    var net_line : char
    netStream := Net.OpenURLConnection (url)
    if netStream <= 0 then
        put "Unable to download mp3 ", url, "!"
        return
    end if
    var fileNo : int
    open : fileNo, "test.mp3", write
    loop
        exit when eof (netStream)
        count += 1
        locate (1, 1)
        progress := round ((62000 - count) / 1000)
        put "Downloading Count Down:",progress
        get : netStream, net_line
        write : fileNo, net_line
    end loop
    Net.CloseConnection (netStream)
    close : fileNo
    playMP3
end streamMP3

streamMP3 ("http://72.29.76.231/~eclipti/turing/test.mp3")


Sponsor
Sponsor
Sponsor
sponsor
iker




PostPosted: Thu Dec 22, 2005 6:35 pm   Post subject: (No subject)

I think I know what the problem is. Its like changing the song or picture to a text file, then back to .mp3 or .jpg. Try this, get a music file, copy it, change it to a .txt, and then back to the original file, and you will hear some distortion.
Taur




PostPosted: Sun Dec 25, 2005 4:09 pm   Post subject: (No subject)

so you can use this to DL anything right? but it will be messed up to some degree thanks for this, 10 bits
md




PostPosted: Sun Dec 25, 2005 11:32 pm   Post subject: (No subject)

The problem is that you're downloading from a webserver and you're not at all taking into acount things like the http protocol; there is more to getting a file then trying to connect using the url like that (much more).

Binary vs. text here shouldn't make that much of a difference since your just reading one byte(char) at a time.

Note that you're not actually "streaming" here, as you're downloading the entire file before playing it.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Submissions
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 4 Posts ]
Jump to:   


Style:  
Search: