Jwplayer callback method reserved for JS

Source: Internet
Author: User

Reference Address: http://www.cnblogs.com/lori/archive/2014/05/05/3709459.html

Application situations

The time that the current video was recorded while playing, and the time the write completed when the playback finished, like these functions, we can resolve by the event callback method, that is, assign the corresponding value to the events property.

Attention

When testing, Jwplayer needs to be tested on the official web site, and when opened locally, its Events property is non-starter

Events instances
 var player = Jwplayer ("MediaPlayer"). Setup ({flashplayer: "player.swf"), file: ' Http://localhost/222.mp4 ', Autostart: "true", Bufferlength: ' 20 ', Width: ' 400 ', Height: ' 400 ', Image: ' 111.jpg ', events: {oncomplete:function () {Console.log ("Play End!!!"); }, Onvolume:function () {Console.log ("Change the Sound size!!!"); }, Onready:function () {console.log ("Ready!!!"); }, Onplay:function () {Console.log ("Start playing!!!"); }, OnPause: function () {console.log ("Pause!!!" ); }, Onbufferchange: function () {console.log ("Buffer change!!!" ); }, Onbufferfull: function () {console.log ("Video buffer complete!!!" ); }, OnError: function (obj) {console.log ("Player error!!!" +function (obj) {if (Obj.fullscreen) { Console.log ("full Screen"); } else {Console.log ("not full screen" function (obj) {console.log ("mute/unmute"       
Other callback methods
Player.onbufferchange (function () {alert ("Buffer change!!!");        }); Player.onbufferfull (function () {alert ("Video buffer complete!!!");        }); Player.onerror (function (obj) {alert ("Player error!!!" +Obj.message); }) Player.onfullscreen (function(obj) {if (obj.fullscreen) {alert ("Full Screen"); }else {alert ("not full screen"); } }); Player.onmute (function (obj) {})//Obj. Mute is Silent player.onplaylist (function (obj) {//Video list loading complete alert (obj.playlist[0][' file ']); });var callback =function () {alert ("callback");};//Define a callback method Player.onplaylistitem (callback)//Triggers Obj.index to video index Player.onready (callback) when a video starts playing//Ready Player.onresize (Callback)//Obj.width obj.height Width and height//Obj.oldstate value triggered when entering playback: From buffering pause state to playback state Player.onplay (callback) //  Enter pause Obj.oldstate value 1: From playing buffering state into pause //  Enter load Obj.oldstate value playing, PAUSED or IDLE Player.onidle (callback) // Enter the idle Obj.oldstate value playing, PAUSED or buffering. Player.oncomplete (callback) // end play Player.onvolume (callback) //obj.volume Player.onplay (function () {Console.log ( Span style= "color: #0000ff;" >this.getposition ()); });
Skills

We see that the player above is its current Jwplayer object, and with this object, we can call Jwplayer's related callback method elsewhere in the program, and if you don't define a player object, you can also index

The way to access an Jwplayer instance, such as Jwplayer (0), represents the first Jwplayer object.

Related

Jwplayer callback method reserved for JS

Related Article

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.