使用JWPlayer在网页中嵌入视频

实际就是在页面中嵌入个控件。社区里已有很多解决方案了。jwplayer是最受欢迎的(之一)。
控件包括js、css和swf文件,swf文件就是播放器,它是控件的一部分,引入控件包跟引入其他的前端控件包方法一样,拷贝到项目路径下即可。
视频是个flv文件,flv文件就放哪里都行了。个人建议像图片一样放个单独的服务器。

示例程序在这里,代码已经传到了github上。
jwplayer本身的文档在这里,藏得非常深,个人非常不喜欢这个官网,花里胡哨,张牙舞爪。
官方文档我还是喜欢朴素简洁的那种。

网页代码及其简单,仅此而已:

<!DOCTYPE>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>use jw</title>

    <script src="jwplayer/jwplayer.js"></script>
    <!-- 并不是每个用户独有的身份码,官网给的唯一的,不用改 -->
    <script>jwplayer.key="bAoNHra71KE/mHvb0sirT4HeWLTAkpiYa1mVsA==";</script>
</head>
<body>
    <div id="myElement">Loading the player...</div>
    <script type="text/javascript">
    var playerInstance = jwplayer("myElement");
    playerInstance.setup({
        file: "http://img.zidafone.com/test.flv",
        image: "http://img.zidafone.com/test.jpg",
         640,
        height: 360,
        title: 'Beautiful Woman',
        description: 'This is the most beautiful woman in the world, do you agree?'
    });
    </script>
</body>
</html>

原文地址:https://www.cnblogs.com/frankchia/p/7858339.html