好的,所以我希望在我的网站上有很多可供选择的视频,所有这些视频都来自archive.org。我最初认为可能是iframe,当用户点击视频标题时,iframes源会更改为所选视频。只是想知道有更好的方法吗?欢迎任何建议和建议。 我尝试过播放列表的archive.org&iframe。
<script>
jwplayer("playa").setup({
"playlist": [
{ duration:5,
title:"camels",
image:"https://archive.org/download/camels/format=Thumbnail",
sources:[
{file:"https://archive.org/download/camels/camels.mp4"},
{file:"https://archive.org/download/camels/camels.ogv"} ]
},
{ duration:115,
title:"commute",
image:"https://archive.org/download/commute/format=Thumbnail",
sources:[
{file:"https://archive.org/download/commute/commute.mp4"},
{file:"https://archive.org/download/commute/commute.ogv"} ]
},
{ duration:5717,
title:"night of the living dead",
image:"https://archive.org/download/night_of_the_living_dead/format=Thumbnail",
sources:[
{file:"https://archive.org/download/night_of_the_living_dead/night_of_the_living_dead_512kb.mp4"},
{file:"https://archive.org/download/night_of_the_living_dead/night_of_the_living_dead.ogv"} ]
}
],
"startparam":"start",
"repeat":"list",
"width":714,
// adjust these 2 lines if you'd like to omit/resize playlist, etc:
listbar:{position:"bottom",size:100,layout:"basic"},
"height":360,
});
</script></div>
&#13;
<div id="playa"> </div>
&#13;
但这并不是我想要的。对不起它非常广泛,我只是不确定如何尝试这个。
答案 0 :(得分:1)
与此JSFiddle一样,我使用每个链接href
的属性<a>
的值将其作为src
值注入iframe
元素
<强> JS:强>
$('.links').on('click', function(evt){
evt.preventDefault();
var vidSrc = $(this).attr('href');
$('iframe').attr('src', vidSrc);
});
<强> HTML:强>
<div id="titles">
<a class="links" href="https://archive.org/embed/FinalFantasy2_356">Final Fantasy 2</a>
<a class="links" href="https://archive.org/embed/MortalKombatSM_14337">Mortal Kombat SM</a>
<a class="links" href="https://archive.org/embed/Quake4_20954">Quake4</a>
</div>
<iframe src="" width="400" height="300" frameborder="0"></iframe>