我正在尝试通过 ashx 页面将 flv 文件加载到 JWPlayer 中。但是我总是收到以下错误:
Task Queue failed at step 5: Playlist could not be loaded: Playlist file did not contain a valid playlist
如果我直接在 Firefox 中加载 ashx 页面,视频将加载并自动播放。如果我将 flvplayer 更改为直接指向 flvfile,它就可以正常工作。所以我对问题是什么感到有些困惑!我注意到的一件事是,当直接通过浏览器播放时,ashx 页面后面的代码运行了两次,第二次没有可用的 session 变量,尽管 Fiddler 只检测到来自浏览器的一个请求。 JWPlayer调用ashx页面时,代码只执行一次。
如有任何帮助,我们将不胜感激!
<%@ WebHandler Language="C#" Class="CourseVideoHandler" %>
using System;
using System.Web;
using System.Web.SessionState;
using System.IO;
public class CourseVideoHandler : IHttpHandler, IReadOnlySessionState
{
public void ProcessRequest(HttpContext context)
{
context.Response.ClearContent();
context.Response.ClearHeaders();
context.Response.ContentType = "video/x-flv";
FileStream fs = File.Open(HttpContext.Current.Server.MapPath("~/content/coursevideos/rowthe boat.flv"),
FileMode.Open);
byte[] b = new byte[fs.Length];
fs.Read(b, 0, (int) fs.Length);
fs.Close();
context.Response.OutputStream.Write(b, 0, b.Length);
}
public bool IsReusable {
get {
return false;
}
}
}
<!-- START OF THE PLAYER EMBEDDING TO COPY-PASTE -->
<div id="mediaplayer">JW Player goes here</div>
<script type="text/javascript" src="jwplayer.js"></script>
<script type="text/javascript">
jwplayer("mediaplayer").setup({
flashplayer: "player.swf",
file: "../../CourseVideoHandler.ashx?t=.flv",
image: "preview.jpg"
});
</script>
<!-- END OF THE PLAYER EMBEDDING -->
最佳答案
您是否收到任何 JS 错误? 你检查过其他浏览器吗?
jwplayer 上的特殊字符也有问题:
有点旧,不过你还是可以看看。
关于c# - JW Player 无法显示通过文件处理程序 (.ashx) 提供的 flv,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8913426/