码迷,mamicode.com
首页 > 其他好文 > 详细

jwPlayer播放器使用方法

时间:2015-02-27 15:00:35      阅读:197      评论:0      收藏:0      [点我收藏+]

标签:

1、jwPlayer播放器的下载:

http://developer.longtailvideo.com/trac/browser/tags/mediaplayer-5.0

 

2、JS:

<script type="text/javascript" src="${basePath}/resources/ /jquery.js"></script>

<script type="text/javascript" src="${basePath}/resources/jwplayer/jwplayer.js"></script>

 

<script type="text/javascript">

        var thePlayer;  //保存当前播放器以便操作

        $(function() {

            thePlayer = jwplayer(‘container2‘).setup({

                flashplayer: ‘${basePath}/resources/jwplayer/player.swf‘,

                //file: ‘${basePath}/resources/jwplayer/video.mp4‘,

                playlist: [

                  //{ duration: 32, file: "/uploads/video.mp4", image: "/uploads/video.jpg" },

                  //{ duration: 124, file: "/uploads/bbb.mp4", image: "/uploads/bbb.jpg" },

                  //{ duration: 542, file: "/uploads/ed.mp4", image: "/uploads/ed.jpg" }

                  <#list cacheVEDs as cVED>

                     {  file: ‘${basePath}/${tempDir}/${cVED.localFilePath}‘, title:‘${cVED.localFilePath}‘ },

                  </#list>

              ],

              "playlist.position": "right",

              "playlist.size": 100,

                width: 600,

                height: 350,

                dock: false

            });

             

            //播放 暂停

            $(‘.player-play‘).click(function() {

                if (thePlayer.getState() != ‘PLAYING‘) {

                    thePlayer.play(true);

                    this.value = ‘暂停‘;

                } else {

                    thePlayer.play(false);

                    this.value = ‘播放‘;

                }

            });

             

            //停止

            $(‘.player-stop‘).click(function() { thePlayer.stop(); });

             

            //获取状态

            $(‘.player-status‘).click(function() {

                var state = thePlayer.getState();

                var msg;

                switch (state) {

                    case ‘BUFFERING‘:

                        msg = ‘加载中‘;

                        break;

                    case ‘PLAYING‘:

                        msg = ‘正在播放‘;

                        break;

                    case ‘PAUSED‘:

                        msg = ‘暂停‘;

                        break;

                    case ‘IDLE‘:

                        msg = ‘停止‘;

                        break;

                }

                alert(msg);

            });

             

            //获取播放进度

            $(‘.player-current‘).click(function() { alert(thePlayer.getPosition()); });

     

            //跳转到指定位置播放

            $(‘.player-goto‘).click(function() {

                if (thePlayer.getState() != ‘PLAYING‘) {    //若当前未播放,先启动播放器

                    thePlayer.play();

                }

                thePlayer.seek(30); //从指定位置开始播放(单位:秒)

            });

              

            //获取视频长度

            $(‘.player-length‘).click(function() { alert(thePlayer.getDuration()); });

        });

    </script>

 

3、HTML

<body>

    <!-- 视频播放 -->

    <div id="container2"></div>

    <!--

    <input type="button" class="player-play" value="播放" />

    <input type="button" class="player-stop" value="停止" />

    <input type="button" class="player-status" value="取得状态" />

    <input type="button" class="player-current" value="当前播放秒数" />

    <input type="button" class="player-goto" value="转到第30秒播放" />

    <input type="button" class="player-length" value="视频时长(秒)" />

     -->

</body>

jwPlayer播放器使用方法

标签:

原文地址:http://www.cnblogs.com/phpxuetang/p/4303183.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!