我将视频上传到服务器并将视频和视频路径保存到数据库中。现在我想在我的主页上显示视频列表。我编写了代码,播放视频流的播放器,但不是视频列表。 代码是 - C#代码背后 -
[WebMethod]
public static List<Video> loadVideo(string value)
{
IList<Video> video = VideoManager.GetHomePageVideo();
if (video == null)
{
video = new List<Video>();
}
return video.ToList();
}
以及 -
的HTML和JavaScript代码 PageMethods.loadVideo('', loadVideoSuccess);
function loadVideoSuccess(result) {
$("#dvVideo").html('');
var html = '';
for (var i = 0; i < result.length; i++) {
html += "<div style=\" border: solid 1px gray;\">";
html += "<a style=\"cursor: pointer;\" onclick=\"LoadVideo('" + result[i].VideoPath.split('/')[1] + "');\"><img src=\"" + result[i].ImagePath + "\" width=\"70\" style=\"background-color:black;\" />" + resul[i].Title + "</a>";
//html += " :: <a href=\"Pages/Gallery/Videos.aspx?videoId=" + result[i].ID + " " + result[i].Title + </a>;
html += "</div>";
}
$("#dvVideo").append(html);
}
<div class="widget-main">
<div class="widget-main-title">
<h4 class="widget-title">Latest Videos</h4>
</div>
<div class="widget-inner" id="dvVideo">
<div style="">
<div id="myElement">Loading the player...</div>
</div>
</div>
<script type="text/javascript">
jwplayer("myElement").setup({
file: "Uploads/Ar_Rahman_Edited.mp3",
image: "video/RoboCop.jpg",
height: 320,
width: 332,
skin: "jwplayer-skins/six.xml"
});
function loadVideo(file) {
var filename = 'Uploads/' + file;
jwplayer("myElement").setup({
file: filename,
image: "video/RoboCop.jpg",
height: 320,
width: 332,
autostart: true,
skin: "jwplayer-skins/six.xml"
});
}
</script>
</div>
现在请帮助我为什么不在我的主页上显示视频列表?我该怎么做呢?
答案 0 :(得分:0)
请尝试下面的链接并尝试这种方式,请不要尝试混合和混乱的HTML和JavaScript一起。保持两者分开。
//http://jsfiddle.net/ramp/nF7Mw/