Jump to content

file audio server for browser


Recommended Posts

I want create a server for download file audio from other pc/smartphone, this is the code

TCPStartup()

global $MainSocket = TCPListen(@IPAddress1, 555)

While 1

Do

$ConnectedSocket = TCPAccept($MainSocket)

Until $ConnectedSocket > 0

$err = 0

Do

$msg = TCPRecv($ConnectedSocket,1024)

$err = @error

If StringLen($msg) THEN

$file = FileOpen("Gettin_Over_You.mp3", 0)

$FileContent = FileRead($file)

FileClose($file)

TCPSend($connectedSocket, Binary("HTTP/1.1 200 OK" & @CRLF & "Access-Control-Allow-Origin: *" & @CRLF))

TCPSend($connectedSocket, Binary("Content-Length: " & FileGetSize("Gettin_Over_You.mp3") & @CRLF))

TCPSend($connectedSocket, Binary("Content-Type: audio/mpeg" & @CRLF & @CRLF & $FileContent))

sleep(10)

TCPCloseSocket($ConnectedSocket)

endIf

Until $err

WEnd

the problem is that when i load page, the song starts but i don't see the duration and on the screen appears "streaming"

can you help me?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...