How to use the Jwplayer player

Source: Internet
Author: User

1, jwplayer player download:

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; Save current player for action

$ (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

});



Play Pause

$ ('. Player-play '). Click (function () {

if (theplayer.getstate () = ' PLAYING ') {

Theplayer.play (TRUE);

This.value = ' pause ';

} else {

Theplayer.play (FALSE);

This.value = ' play ';

}

});



Stop it

$ ('. Player-stop '). Click (function () {theplayer.stop ();});



Get status

$ ('. Player-status '). Click (function () {

var state = Theplayer.getstate ();

var msg;

Switch (state) {

Case ' buffering ':

msg = ' loading in ';

Break

Case ' PLAYING ':

msg = ' playing ';

Break

Case ' PAUSED ':

msg = ' pause ';

Break

Case ' IDLE ':

msg = ' Stop ';

Break

}

Alert (msg);

});



Get Playback Progress

$ ('. Player-current '). Click (function () {alert (theplayer.getposition ());});



Jump to a specified position play

$ ('. Player-goto '). Click (function () {

if (theplayer.getstate ()! = ' PLAYING ') {//If it is not currently playing, start the player first

Theplayer.play ();

}

Theplayer.seek (30); Start playback from the specified position (in seconds)

});



Get video length

$ ('. Player-length '). Click (function () {alert (theplayer.getduration ());});

});

</script>



3. HTML

<body>

<!--video Playback--

<div id= "Container2" ></div>

<!--

<input type= "button" class= "Player-play" value= "Play"/>

<input type= "button" class= "Player-stop" value= "Stop"/>

<input type= "button" class= "Player-status" value= "Get Status"/>

<input type= "button" class= "Player-current" value= "current playing seconds"/>

<input type= "button" class= "Player-goto" value= "go to 30th second play"/>

<input type= "button" class= "Player-length" value= "video duration (seconds)"/>

-

</body>

How to use Jwplayer player

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.