gpt4 book ai didi

javascript - 如何在调用 onclick 函数时在 jwplayer 中播放视频....播放列表

转载 作者:行者123 更新时间:2023-11-29 17:00:47 25 4
gpt4 key购买 nike

i am working on MVC5 video website with embedded jwplayer, the "file" value is assigned dynamically from @viewBag.VideoUrl to jwplayer and video plays with no problem...All videos from database loaded on the episodeList view, now for multiple videos or video_playlist, i want to play video which i select by clicking as can be seen from snapshot at the end..i been reading about doing the playlist technique via RSS feed,,,Is it the only way to create PlayList Rss feed???

播放器脚本

<div id="mediaplayer"></div>
<script type="text/javascript">
$(document).ready(function(){
jwplayer('mediaplayer').setup({
'file': 'rtmp://872083564.r.cdnsun.net/872083564/_definst_/mp4:872083564/
@ViewBag.VideoUrl',
'autostart': true,
'width': 320,
'height': 240,
rtmp: {
securetoken: "fsdf5sdfsdf43f5"
},
});
});
</script>

查看用于在表格的 3 列中显示所有视频的代码,使用 foreach 循环执行每个项目,我想尝试“onclick for href”但不知道该怎么做,没有别的

   const int NumberOfColumns = 3; int skip = 0; var items = Model.Skip(skip).Take(NumberOfColumns);
while (items.Count() > 0) {
<tr>
@foreach (var item in items) {
<td width="450">
<table class="thumbmain">
<tr>
<td>
<a href="" />
<img src="@Url.Content(item.PosterUrl)" width="120" height="120" class="imageclass"
onclick="someAction" />
</td>
</tr>
<tr>
<td style="text-align: center; font-weight: bold; color: Teal">
@item.Title
</td>
</tr>
</table>
</td>
}
</tr>
skip += NumberOfColumns; items = Model.Skip(skip).Take(NumberOfColumns); } } </table>
</div> </div> </div>

Controller 操作

public ActionResult EpisodeList(Guid? id)
{
IQueryable<VideoEpisodeDM> episodesdm = db.VideoEpisode
.Where(ve => ve.VideoId == id);

string video;

foreach (var item in episodesdm)
{
video = item.Title;
ViewBag.VideoUrl = item.VideoUrl;
}


return View(episodesdm.ToList());
}

输出:

enter image description here

i want to play videos accordingly like if i click "downTo" it should load/play "downTo" video, if "finaltick" then finaltick url should load in file''....if there is a way please help or reference will be appreciated...Thanks for your time

最佳答案

你的意思是这样的吗?

http://support.jwplayer.com/customer/portal/articles/1439570-example-loading-new-playlists

将以下嵌入代码放在您希望播放器出现的位置:

<div id="myElement"></div>

<script>
jwplayer("myElement").setup({
image: "/uploads/myPoster.jpg",
file: "/uploads/myVideo.mp4",
title: "My Cool Trailer"
});
</script>

其次,添加 JavaScript 来实现加载行为:

<script>
function loadVideo(myFile,myImage) {
jwplayer().load([{
file: myFile,
image: myImage
}]);
jwplayer().play();
};
</script>

最后,添加一些使用正确的文件和图像调用此函数的 HTML:

<li><a href="javascript:loadVideo('file1.mp4','image1.jpg')">Video 1</a></li>
<li><a href="javascript:loadVideo('file2.mp4','image2.jpg')">Video 2</a></li>
<li><a href="javascript:loadVideo('file3.mp4','image3.jpg')">Video 3</a></li>

关于javascript - 如何在调用 onclick 函数时在 jwplayer 中播放视频....播放列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28344799/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com