我有一个ASP网站,根据HTTP参数播放视频 'id'
服务器端:
Public vidurl As String
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim id As String = Request.QueryString("id")
Dim DT As New DataTable
Dim vidInfo As VideoInfo
Try
If id IsNot Nothing Then
Dim SQLConnection_Cont As New SqlConnection(SQLConntStr)
DT = f.GetVideoInfo(id, SQLConnection_Cont)
If DT IsNot Nothing Then
If DT.Rows.Count > 0 Then
vidInfo = New VideoInfo With {
.ID = DT.Rows(0).Item("FTPID"),
.Processed = DT.Rows(0).Item("Processed"),
.URL = DT.Rows(0).Item("URL"),
.VideoName = DT.Rows(0).Item("VideoName"),
.VidID = DT.Rows(0).Item("VidID"),
.Created = DT.Rows(0).Item("Created"),
.MonthDiff = DT.Rows(0).Item("Monthdiff")}
If vidInfo.MonthDiff = 0 Then
vidurl = "http://webpath.com/virtualdirectory/content/" & vidInfo.VideoName
End If
End If
End If
End If
Catch ex As Exception
WriteExToFile("Video.aspx.vb", ex.ToString)
End Try
End Sub
客户端:
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Video Player</title>
<link href="css/style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<form id="form1" runat="server">
<div>
<div id="vidplay">
<video height="400" controls style="position: relative; top: 23px;">
<source src=<%= vidurl %> type="video/mp4" codecs="avc1.42E01E, mp4a.40.2"/>
<object data=src=<%= vidurl %> width="320" height="240"></object>
</video>
</div>
</div>
</form>
</body>
</html>
所以我在全局变量 vidurl
中传递虚拟目录中的视频路径
当我在Google Chrome for Desktop上播放时,我只会听到视频中的声音,并带有黑色图像 .
当我在手机上播放时,会出现黑色视频,但它根本不播放任何内容 .
可能是什么问题?
Please note that all the videos in the virtual directory are in mp4 format.
UPDATE:
我去了我视频中的 Codec Information ,
它说: MPEG-4 Video (mp4v)
这可能是问题吗?
优先考虑视频在移动设备上运行 .
3 回答
某些浏览器不支持某些文件格式 . 尝试添加其他网络视频格式来源 .
不幸的是,在所有浏览器中播放视频都很痛苦 . 对我来说仍然有效的解决方案是mediaelement.js(即使是ie8) . 设置非常简单,是前端世界最好的大脑推荐使用的图书馆 . 唯一的问题是,在使用闪回后备时,很难让它具有响应性 .
即使您提供所有可能的格式,您仍会看到多个问题,例如提供错误的视频时间,跨设备的不同控制选项 . 还有一些转换器在保持Web标准方面不能很好地工作 . 对我来说最好的是http://www.mirovideoconverter.com/ for mac . 格式/编解码器的支持也因浏览操作系统安装的程序而异,所以总是很好地使用一些东西作为后备(flash) .
除了mediaelement之外,你可以使用其他几个较新的库,但在我的测试中,大多数都工作得很差 . 最好的一个是video.js(polyfill一样)和爆米花播放器 .
好吧,我不知道你的代码是否与你的示例代码相同,但是这里有一些你可以根据你的示例代码尝试的建议
用引号括起你的
<%= vidurl %>
将您的对象
data=src
更改为data-src
希望能帮助到你 ;)