视频标记无法在移动设备上运行

时间:2015-06-18 07:22:58

标签: html asp.net vb.net html5 video

我有一个根据HTTP参数'id'

播放视频的ASP网站

服务器端:

  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上播放时,我只会听到视频中的声音,并带有黑色图像。

当我在手机上播放时,会出现黑色视频,但它根本不播放任何内容。

可能是什么问题?

请注意,虚拟目录中的所有视频均采用mp4格式。

更新

我在我的视频中找到了编解码器信息

它说:MPEG-4 Video (mp4v)

这可能是问题吗?

视频适用于手机的优先级。

4 个答案:

答案 0 :(得分:3)

某些浏览器不支持某些文件格式。尝试添加其他网络视频格式来源。

<source src="somevideo.webm" type="video/webm">

答案 1 :(得分:1)

不幸的是,在所有浏览器中播放视频都是痛苦的。对我而言仍然有效的解决方案是mediaelement.js(即使是ie8)。设置非常简单,是前端世界最好的大脑推荐的相当丰富的图书馆。唯一的问题是在使用闪回后备时很难使其响应。

即使您提供了所有可能的格式,您仍会看到多个问题,例如提供错误的视频时间,跨设备的不同控制选项。还有一些转换器在保持Web标准方面不能很好地工作。对我来说最好的一个是mac http://www.mirovideoconverter.com/。格式/编解码器的支持也因浏览*操作系统*安装的程序而异,所以总是很好地使用一些东西作为后备(闪存)。

除了mediaelement之外,你可以使用其他几个较新的库,但在我的测试中,大多数都工作得非常糟糕。最好的一个是video.js(polyfill一样)和爆米花播放器。

答案 2 :(得分:0)

好吧,我不知道您的代码是否与您的示例代码相同,但是您可以根据示例代码尝试一些建议

<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>
  1. 用引号
  2. 附上您的<%= vidurl %>
  3. 将您的对象data=src更改为data-src
  4. 希望它有所帮助;)

答案 3 :(得分:0)

只需在视频代码中添加playsinline属性。

<video playsinline autoplay loop muted style="min-width:100%; min-height:100%;" >
 	<source type="video/mp4" src="//bg.cdn.ustudio.com/app/transcodes/TQAdh6DJdtuY.mp4">
 	<source type="video/webm" src="//bg.cdn.ustudio.com/app/transcodes/TuX1xml2yZsS.webm">
</video>

相关问题