Js~jwplayer Summary of callback method reserved for JS

Source: Internet
Author: User

For a successful product, it is closed, but is open to the outside, this sentence is not contradictory, let me say that it is closed because its own code does not allow you to modify, and said it is open, because it defines a lot of API for us, or called callback method, for Jwplayer, It gives us a lot of JS callback methods (events), which are included in the events property.

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
varPlayer = 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!!!" +obj.message); }, Onfullscreen:function(obj) {if(Obj.fullscreen) {console.log ("full Screen");}Else{Console.log ("not full screen"); }}, Onmute: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 mutedPlayer.onplaylist (function(obj) {//Video List loading completeAlert (obj.playlist[0][' file ']); }); varcallback =function() {alert ("callback");};//define a callback methodPlayer.onplaylistitem (callback)//triggers Obj.index to video index when a video starts playingPlayer.onready (callback)//Get ReadyPlayer.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: Enter pause from playing buffering state Player.onpause (callback) Player.onbuffer (callback)//Enter load Obj.oldstate value playing, PAUSED or IDLEPlayer.onidle (callback)//Enter the idle obj.oldstate value playing, PAUSED or buffering.Player.oncomplete (callback)//End PlayPlayer.onvolume (callback)//Obj.volumePlayer.onplay (function() {Console.log ( 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

Js~jwplayer Summary of callback method reserved for JS

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.