JW Player Embedding and JavaScript Guide.pdf

(198 KB) Pobierz
445453298 UNPDF
JWPlayerforFlashandHTML5
Release5.3
EmbeddingGuide
October 20, 2010
445453298.001.png
CONTENTS
1 Embedding the player
1
1.1 Upload . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1
1.2 SWFObject . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1
1.3 Embedding Without JavaScript . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2
1.4 JW Embedder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3
2 Player API 11
2.1 Getting started . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
2.2 Selecting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
2.3 Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
2.4 Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
2.5 Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
2.6 Chaining . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
i
ii
CHAPTER
ONE
EMBEDDINGTHEPLAYER
Like every other Flash object, the JW Player has to be embedded into the HTML of a webpage using specific embed
codes. Overall, there are three methods for embedding the JW Player:
• Using a generic JavaScript embedder (like SWFObject ) .
• Using a HTML tag (like <object> or <embed>).
• Using the JW Embedder, the JW Player’s own JavaScript embedder (jwplayer.js).
For embedding the JW Player for Flash, we recommend using SWFObject, since it works in all browsers and many
examples exist on the web to get you up and running quickly. If you want the new HTML5 features of the JW Player,
or if you want to leverage the new and improved JavaScript API , you’ll want to use the JW Embedder. Detailed
instructions can be found below.
1.1Upload
First, a primer on uploading. This may sound obvious, but for the JW Player to work on your website, you must
upload the player.swf file onto your webserver. If you want to play YouTube videos, you must also upload the yt.swf
file - this is the bridge between the player and YouTube. Finally, to use the JW Embedder and HTML5 player, upload
jwplayer.js.
Note: We recommend putting everything in a folder called “jwplayer” at the root of your site. This enables the Quick
Embed method of setting up the player. The file structure should look like this:
[WebRoot]/jwplayer/player.swf
[WebRoot]/jwplayer/jwplayer.js
[WebRoot]/jwplayer/yt.swf
1.2SWFObject
There’s a wide array of good, open source libraries available for embedding Flash. SWFObject is the most widely
used one. It has excellent documentation .
Before embedding any players on the page, make sure to include the swfobject.js script in the <head> of your HTML.
You can download the script and host it yourself, or leverage the copy provided by Google :
<script type="text/javascript"
src="http://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js" >
</script>
1
445453298.002.png 445453298.003.png 445453298.004.png
Zgłoś jeśli naruszono regulamin