Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Play music in webpage

Status
Not open for further replies.

robert201

Programmer
Jul 18, 2007
80
TH
Hello,

The customer wants to download a music file for a path that is on the server, then play that in the web form. So it will be like having window media player embedded in the web form itself.

I have the code for downloading and playing. However, a dialog will popup and when they click open it will play the music. However, the customer doesn't like this and want to play the music in a player that is in the web page itself.

Here is my code so far for downloading and playing the music.

Many thanks



Code:
 Try
            Dim fs As FileStream = Nothing
            Dim contentType As String = String.Empty
            'Dim path As String = "\\10.10.10.31\Inetpub\[URL unfurl="true"]wwwroot\csone\images\Content\"[/URL]
            'Dim fileName As String = "Voice.mp3"
            Dim path As String = "C:\DownloadPicture\"
            Dim fileName As String = "Beethoven.wma"


            fs = File.Open(path & fileName, FileMode.Open)
            Dim fileBytes(fs.Length) As Byte

            fs.Read(fileBytes, 0, fs.Length)
            fs.Close()

            Response.AddHeader("Content-disposition", "attachment; filename=" & fileName)
            Response.ContentType = "application/octet-stream"
            Response.BinaryWrite(fileBytes)
            HttpContext.Current.ApplicationInstance.CompleteRequest()

        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top