我有一个剧本可以播放由服务提供给它的电影。
<div id="player1">Loading the player ...</div>
<script type="text/javascript">
jwplayer('player1').setup({
file: "downloadvideo.aspx",
width: "296",
height: "240",
type: "mp4",
});
</script>
以下是提供电影文件的表单加载事件:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim filePath As String = "C:\websites\Website2\wdo.mp4"
Dim Buffer As Byte() = File.ReadAllBytes(filePath)
Context.Response.Clear()
Context.Response.Cache.SetCacheability(HttpCacheability.Public)
Context.Response.Cache.SetLastModified(DateTime.Now)
Context.Response.AppendHeader("Content-Type", "video/mp4")
Context.Response.AddHeader("Content-Disposition", "attachment;filename=wdo.mp4")
Context.Response.AppendHeader("Content-Length", Buffer.Length.ToString())
Context.Response.BinaryWrite(Buffer)
End Sub
适用于Internet Explorer,Google Chrome,Firefox。但不是Safari。
在Safari中,它只有一个可以永久旋转的进度循环。
如果你直接给脚本一个电影文件,它在safari中播放得很好,但我需要用这种方法给剧本提供电影,因为我的电影将存储在数据库中。
答案 0 :(得分:0)
试试这个工作
受保护的子Page_Load(ByVal sender As Object,ByVal e As System.EventArgs)处理Me.Load
Dim filePath As String = "C:\websites\Website2\wdo.mp4"
Dim Buffer As Byte() = File.ReadAllBytes(filePath)
Context.Response.Clear()
Context.Response.AddHeader("Content-Disposition", "attachment;filename=wdo.mp4")
Response.ContentType = "video/mp4"
Context.Response.BinaryWrite(Buffer)
End Sub