Dönüştürülmüş videoların oynatılmasına izin verecek bir HTML5 VIDEO etiketi içerecek bir test sayfası oluşturmaya çalışıyorum. Videoları dönüştürüp bunları yerel olarak sunucuda depolayabiliyorum, ancak tüm videoları başka bir .aspx sayfası üzerinden aktarabilirim..NET HTML5 üzerinden MP4 videosu akışı
, ben Video ikili sağlamak dışında hiçbir şey yapacak HTML kodu ve getvideo.aspx sayfayı içerecek bir player.aspx sayfası vardır varsayarsak ben aşağıdaki kod benim player.aspx sayfasında iyi çalışır düşünüyordu:
Response.clearheaders
Response.AddHeader("Content-Type", "video/mp4")
Response.AddHeader("Content-Disposition", "inline;filename=""newvideo.mp4""")
dim Err as string = ""
Dim iStream As System.IO.Stream
' Buffer to read 10K bytes in chunk:
Dim buffer(buffersize) As Byte
' Length of the file:
Dim length As Integer
' Total bytes to read:
Dim dataToRead As Long
' Identify the file to download including its path.
Dim filepath As String = "./outout/videos/newvideo.mp4"
' Identify the file name.
Dim filename As String = System.IO.Path.GetFileName(filepath)
' Open the file.
try
iStream = New System.IO.FileStream(filepath, System.IO.FileMode.Open, IO.FileAccess.Read, IO.FileShare.Read)
catch ex as exception
throw new exception("Could not create FileStream for [" & filepath & "], error follows." & vbcrlf & ex.toString)
end try
Try
' Total bytes to read:
dataToRead = iStream.Length
' Read the bytes.
While dataToRead > 0
' Verify that the client is connected.
If system.web.httpcontext.current.Response.IsClientConnected Then
' Read the data in buffer
length = iStream.Read(buffer, 0, buffersize)
' Write the data to the current output stream.
system.web.httpcontext.current.Response.OutputStream.Write(buffer, 0, length)
' Flush the data to the HTML output.
system.web.httpcontext.current.Response.Flush()
ReDim buffer(buffersize) ' Clear the buffer
dataToRead = dataToRead - length
Else
'prevent infinite loop if user disconnects
dataToRead = -1
End If
End While
Catch ex As Exception
' Trap the error, if any.
err = "Error accessing " & filepath & " : " & ex.tostring
Finally
If IsNothing(iStream) = False Then
' Close the file.
iStream.Close()
End If
End Try
if err<>"" then throw new exception(err)
benim sayfa çıktısı almak Bütün bir HTML Video zaman aşımına görünüyor çalar (Chrome'un temel çalar) ve geçerli:
<div style="text-align:center">
<video controls autoplay id="video1" width="920">
<source src="http://www.mywebsite.com/getvideo.aspx?getvideo=1" type="video/mp4">
Your browser does not support HTML5 video.
</video>
getvideo.aspx sayfası aşağıdaki vb.net kodunu içeren PLAY düğmesi griye gider. Chrome Geliştirici araçlarındaki Ağ aracı, 45mb indirmenin ve 200 yanıt kodu aldığını gösterir. Bu bana iyi çalıştığını gösteriyor. "İptal" durumuyla ikinci bir GET talebi alsam da mı?
www.mywebsite.com/output/videos/myvideo.mp4 adresini ziyaret edersem, bu tarayıcıda düzgün bir şekilde oynatılır, dolayısıyla IIS'nin videoyu doğru şekilde akışa alacak şekilde yapılandırıldığını biliyorum.
Ben tepki içerik yapısını değiştirmek Ayrıca eğer benim ASPX sayfasına giderek, ancak bu da doğru HTML player oynamak vermediğinde "eki" ardından tarayıcı doğru videonun indirilmesini zorlar. .net üzerinden video yayınlamak için bir .aspx dosyası durduran HTML5 VIDEO etiketi ile 'zeki' oluyor mu? Yoksa cevap başlığını mı kaçırıyorum?
Teşekkürler!
araştırmak için devam hala iki URL de aynı ve Scott Mitchell yazılan her ikisi noktası bu – JLo