Loading flash videos into div with ajax

若如初见. 提交于 2020-01-02 16:18:12

问题


I have a client that wants to be able to select from a playlist of video thumbnails and it replaces a video that is on the page already. I also need to watch loading times, so thought it would be better requesting each video if and when it's clicked with ajax? I'm new to ajax so not really sure if this is the best option.

My page is as follows:

<div id="container">
<div id="video">
</div>
<div id="videoSelector">
</div>
</div>

The videoSelector div will have thumbnails that the user will click and the video will load into the video div.

Any help will be great

Thanks


回答1:


You do not really need AJAX to achieve this functionality. You can do with something like:

<script>
 function changeVideo(filename) {
 document.getElementById('video').innerHTML = 'CODE DEPENDING ON PLAYER'+filename+'REMAINING CODE';
}
</script>
<div id="video"></div>
<div id="videoSelector">
<a href="javascript:void();" onclick="javascript:changeVideo('filename');">Thumbnail 1</a>
<a href="javascript:void();" onclick="javascript:changeVideo('filename2');">Thumbnail 2</a>
<a href="javascript:void();" onclick="javascript:changeVideo('filename3');">Thumbnail 3</a>
</div>

Something as simple as above. You can definitely improve the above using class selectors, jQuery etc. But I hope this is a start.




回答2:


If you use jQuery, there is flashembed from jQuery Tools.

If you're not into jQuery, there is a more popular Flash embedding tool SWFObject.

Both are very easy to use and there are lots of example from their website.



来源:https://stackoverflow.com/questions/1516202/loading-flash-videos-into-div-with-ajax

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!