jlEmbed is a plugin for jQuery,
which makes it easier to add embedded media players to your webpage. With
support for Adobe Flash, Quicktime, Real Player, Silverlight, Windows
Media Player, and YouTube, you will no longer need to hard-code lengthy,
cumbersome, and invalid HTML for your music or videos. jlEmbed also has
built-in music playlist support, a customizable MP3, SWF, FLV, YouTube
audio player, support for swfobject, YouTube videos, and custom YouTube
video playlists.
Get the free plugin source by following the "Download"
tab above!
As demonstrated below in my demo player, jlEmbed's YouTube API functions allow you to use the YouTube Javascript API and Chromeless YouTube player, giving you the power to create custom YouTube player controls and more!
Note: This is a demo only. This player is not included, but merely demonstrates what you can do with jlEmbed. However, if you're interested, I will sell copies.
With jlEmbed, you'll never receive HTML validation
errors again from your Flash or other embedded media! jlEmbed helps keep
your webpage validating properly even while using embedded media players!
jlEmbed also includes basic plugin detection which kindly links visitors
to the appropriate plugin download page when a required plugin is not
detected, or automatically loads the user's default media player plugin.
Embedding music or video on your webpage is a snap with jlEmbed!
$("#example-id").jlEmbed({
url: 'http://jasonlau.biz/public/mixdown.mp3'
});
That short, simple code installs the default Media Player with default
options on the object example-id!
Internet Explorer |
Firefox |
Chrome |
Opera |
Safari |
View an opensource example of how you can navigate a song array with jlEmbed.
| Notice: Please report any bugs or errors by using the Contact Form. jQuery is required for jlEmbed to work. Be sure to include jQuery before attempting to include jlEmbed. | ||
| Source Code: | Version 4.9.5 Last updated 2/19/2010 | |
| Latest Version: | jlEmbed Latest - You may link to this version if you wish, but I can't guarantee 100% server uptime. Additionally, this version is subject to change without advanced notification. | |
| Changelog: |
|
|
An example of where options are used:
// Options go here
// Separate options with a comma.
format: 'windowsmedia',
playlist: 'http://jasonlau.biz/public/mixdown.mp3|http://jasonlau.biz/public/mixdown.mp3|http://jasonlau.biz/public/mixdown.mp3|http://jasonlau.biz/public/mixdown.mp3',
params: 'width=300 height=40 autoplay=false loop=true shuffle=false'
// No comma following the last option
// End options
});
- autoplay
- caption
- caption_class
- caption_id
- caption_style
- codebase
- flash_version 4.0+
- format
- height
- id
- loop
- musicplayer 3.0+
- params
- playlist 3.0+
- plugin
- pluginspace
- shuffle 4.5+
- src
- titles 3.0+
- url
- width
- youtube 4.0+
- youtubechromeless 4.0+
- youtubedebug 4.0+
- youtubedisplay 4.0+
- youtubekey 4.0+
- youtubevolume 4.0+
- autoplay : Automatically begin to play
the first item when the page loads.
- true
- false (default)
- caption : A text string to be displayed directly below the media player. This option places the media player in a div container with the text placed below the media player. Disabled by default. Simply add text to enable this feature.
- caption_class : The css class used for the caption container.
- caption_id : A string identifier used for the caption container. "myCaption" is the default id.
- caption_style : The style attribute used for the caption container.
- codebase : Used to specify the Adobe Flash or Windows Media Player codebase.
- flash_version : A number used to specify the Adobe Flash Player version. Default is 10.
- format : The HTML code output format.
- object
- embed
- objectembed (default)
- swfobject (4.0+ adobeflash plugin only)
- height : The height of the player. 48 pixels is the default height.
- id : A string identifier for this object. "myMedia" is the default id.
- loop : Automatically restart when the playlist
has completed.
- true (default)
- false
- musicplayer : This option installs
a customizable Flash music player, which is generated and served from
JasonLau.biz. Here
is the music player which is used.
The musicplayer option supports MP3, SWF, and formatted audio files and YouTube videos. Requires both playlist and titles options. See example.
musicplayer Attributes- BGImage : Optional player background image. You may wish to hide the icons or dividers while using this feature. JPEG/JPG format only.
- BackgroundColor : Player background color hex code. 6 characters with no leading # hash mark.
- IconColor : Player control icons color hex code. 6 characters with no leading # hash mark.
- IconActiveColor : Active icon color hex code. 6 characters with no leading # hash mark.
- PlayIconActiveColor : Active play icon color hex code. 6 characters with no leading # hash mark.
- StopIconActiveColor : Active stop icon color hex code. 6 characters with no leading # hash mark.
- Icons : Display player control icons.
- yes (default)
- no
- Dividers : Display dividers between control icons.
- yes (default)
- no
- Fader : Optional color shifter for the player background.
- yes
- no (default)
- Autoplay : Starts the player when the webpage loads.
- yes (default)
- no
- Loop : Continuously plays.
- yes (default)
- no
- Shuffle : Shuffle the playlist
- yes (default)
- no
- playlist : A list of links to audio files and YouTube videos.
Each link must be separated by a |pipe symbol from the next link.
MP3, SWF, or FLV formatted audio files and YouTube video links.
Video will not be displayed.
Example:
playlist: 'http://Song-1-Link.mp3 http://Song-2-Link.swf|http://Song-3-Link.flv|http://www.youtube.com/watch?v=VicwLWPho08|http://www.youtube.com/v/VicwLWPho08' - titles : A list of track titles for each of the links in
the playlist. Each title must be separated by a |pipe (vertical
bar).
Example:
titles: 'Song 1|Song 2|Song 3'
Be sure you have the same number of titles as you do links!
Please refer to the examples.
- params : A list of any or all
options and parameters to pass to the player. Each option or parameter must be separated by
a space from the next. Leave this blank to use default options and parameters.
This option can be used to define any or all of the jlEmbed options and plugin parameters.
Example:params: 'url=myfile.mp3 width=300 height=40 plugin=windowsmedia autoplay=true loop=true' - playlist : A list of links to audio or video files. Each link must be separated by a |pipe symbol from the next link. All media file types which are used in the same playlist must be compatible with the same plugin. Unless used with the musicplayer option, this feature creates a m3u formatted playlist, which is generated and served from JasonLau.biz. When used in conjunction with the musicplayer option, only MP3, SWF, and/or FLV formatted files and YouTube video links may be used. See example.
- plugin : The default browser plugin which
will be used for this object.
- adobeflash
- quicktime
- realplayer
- silverlight
- windowsmedia (default)
- pluginspace : Used to specify the Adobe Flash or Windows Media Player pluginspace.
- shuffle : Boolean. Strictly for use
with the youtube option. Shuffles the youtube playlist if
one exists. Version 4.5+
- true
- false (default)
- src : The resource link for the media file. Same as url. Can be used instead of url variable. No default.
- titles : Used exclusively in conjunction with the musicplayer option
- url : The resource link for the media file. Same as src. Can be used instead of src variable. No default.
- width : The width of the player. 300 pixels is the default width.
- youtube : A text string YouTube video
ID. The YouTube video ID can be found in the video link. See the examples
tab for more information on using YouTube. As of version 4.5, the youtube
option accepts a playlist, which should be made up of a |pipe separated
list of YouTube video id's.
Example playlist: KTHFXeKLv6w|b6CywF3tnEI|Tja6_h4lT6A
Example YouTube Id - In the following YouTub links, the video id is marked in bold - http://www.youtube.com/watch?v=VicwLWPho08 or http://www.youtube.com/v/VicwLWPho08 - youtubechromeless : Load the
YouTube video in the chromeless player. The chromeless player has no
visible controls. Use this option while creating custom controls.
- true
- false (default)
- youtubedebug : Displays some debug
info below the YouTube video.
- true
- false (default)
- youtubedisplay : This controls
the visibility of the YouTube player. The YouTube player is accessible
for scripting even while hidden.
- true (default)
- false
- youtubekey : A text string YouTube Developer Key . Optional if you wish to use your own developer key. The default is the jlEmbed API key.
- youtubevolume : A number used to specify the default YouTube player volume. 0-100
These functions will help you create and control a custom YouTube video player.
Example:
For a more detailed description of each function's purpose, please refer to this YouTube Javascript API Reference Page.
To see many of these functions in action, go to this example page.
Contents
- Queuing Functions
- Playing A Video
- Changing The Player Volume
- Setting The Player Size
- Playback Status
- Playback Quality
- Retrieving Video Information
- Adding An Event Listener
- Hidden Fields
- jlembed_cueVideoById(playerId,videoId, startSeconds, suggestedQuality)
- jlembed_loadVideoById(playerId,videoId)
- jlembed_loadVideoByUrl(playerId,video_url, startSeconds)
- jlembed_playVideo(playerId)
- jlembed_pauseVideo(playerId)
- jlembed_stopVideo(playerId)
- jlembed_seekTo(playerId, seconds, allowSeekAhead)
- jlembed_mute(playerId)
- jlembed_unMute(playerId)
- jlembed_isMuted(playerId)
- jlembed_setVolume(playerId, volume)
- jlembed_getVolume(playerId)
- jlembed_setSize(playerId, width, height)
- jlembed_getVideoBytesLoaded(playerId)
- jlembed_getVideoBytesTotal(playerId)
- jlembed_getVideoStartBytes(playerId)
- jlembed_getPlayerState(playerId)
- jlembed_getCurrentTime(playerId)
- jlembed_getPlaybackQuality(playerId)
- jlembed_setPlaybackQuality(playerId, suggestedQuality)
- jlembed_getAvailableQualityLevels(playerId)
- jlembed_getDuration(playerId)
- jlembed_getVideoUrl(playerId)
- jlembed_getVideoEmbedCode(playerId)
- jlembed_addEventListener(playerId, event, listener)
jlEmbed includes some hidden fields which are intended to help you interact with the YouTube player and to navigate playlists. The hidden field id attributes are listed below with a brief description of their use. You can access the values of these fields easily with jQuery.
Example:
- jlembed_yt_video_url_{player id} :
The URL address for the currently playing item. - jlembed_yt_chromeless_{player id} :
Is this the Chromeless player?- true
- false
- jlembed_yt_autoplay_{player id} :
Player autoplay setting.- true
- false
- jlembed_yt_loop_{player id} :
Player loop setting.- true
- false
- jlembed_yt_player_ready_{player id} :
Is the YouTube player ready for calls?- true
- false
- jlembed_yt_player_state_{player id} :
The current YouTube player state.- Unstarted (-1)
- Ended (0)
- Playing (1)
- Paused (2)
- Buffering (3)
- Video cued (5)
- jlembed_yt_current_playlist_item_{player id} :
The (interger) array index of the currently playing playlist item. 0 is the first item and it increments upward from there. - jlembed_yt_playlist_{player id} :
The current playlist.
Contents
- Including jQuery And jlEmbed
- Default Settings
- Extended Options
- Easy Options
- Playlist
- Music Player
- YouTube
- Including jQuery And jlEmbed - Before you can use jlEmbed, you must include jQuery. Here is an example of how to set up your document to use jlEmbed and jQuery.
<!doctype html>The jlEmbed code is contained within the jQuery code.
<html>
<head>
<title>Your Webpage</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript" src="http://jasonlau.biz/javascript/jquery/plugins/jquery.jlembed.latest.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#example-div").jlEmbed({
url: 'http://jasonlau.biz/public/mixdown.mp3'
});
});
</script>
</head>
<body>
<div id="example-div"></div>
</body>
</html>// Initiate jQuery On Page Load
$(document).ready(function(){
// Begin jlEmbed Code
$("#example-div").jlEmbed({
url: 'http://jasonlau.biz/public/mixdown.mp3'
});
// End jlEmbed Code
});
// End jQuery Code - Default Settings - This example installs the default Windows Media Player
on the object example-id with the default settings. The url is
optional, but there is no default media file.
$("#example-id").jlEmbed({
url: 'http://jasonlau.biz/public/mixdown.mp3'
});
If the browser does not have the required plugin installed, the user will be prompted to install the plugin or the computer's default media player will load in place. These results may vary depending on the user's computer settings.
- Extended Options - This is the long method for defining option values. This example
installs Flash content on the object example-id.
$("#example-id").jlEmbed({
id: 'myMedia',
plugin: 'adobeflash',
url: 'your-flash-file.swf',
width: 300,
height: 48,
loop: 'yes',
autoplay: 'yes',
params: 'allowscriptaccess=local allownetworking=local scale=showall quality=high flashvars= wmode=transparent quality=high', format: 'objectembed', caption: 'My Flash File', caption_style: 'width:308px; text-align:center; padding-top:10px; background-color:#CCCCCC; border:1px; color:#000000;' });
- Easy Options - The short method. Using the params option allows you to define any options values and player plugin parameters. Options and parameters are listed inline and separated from eachother by a space. This example installs Flash
content on the object example-id. As you can see, the params
option allows you to easily pass options and parameters to jlEmbed and to your
media player. All of the options and browser plugin parameters can be defined using this method,
provided there are no spaces in any of the values. Use %20 in place
of spaces in values to avoid errors. In this example, the space in the
caption option, Hello World!, has been properly replaced
with %20 and is now Hello%20World!.
$("#example-id").jlEmbed({
params: 'id=myMedia plugin=adobeflash url=yourFlashFile.swf width=600 height=600 allowscriptaccess=local allownetworking=local scale=showall quality=high flashvars=&myvars=example& wmode=transparent quality=high caption=Hello%20World!'
});
- Playlist - Version 3.0 and higher.
The playlist option can be used to create a music and video
playlist from a |pipe-separated list of links. The playlist links are
encoded, sent to a script at JasonLau.biz, and converted to M3U format
before being served back to the embedded media player. This is not compatible
with Adobe Flash. Easy to use!
$("#example-player").jlEmbed({
params: 'id=myMedia plugin=windowsmedia width=300 height=48 loop=yes autoplay=yes',
playlist: 'http://jasonlau.biz/public/mixdown.mp3|http://jasonlau.biz/public/mixdown.mp3|http://jasonlau.biz/public/mixdown.mp3|http://jasonlau.biz/public/mixdown.mp3'
});
The example above installs Windows Media Player on the object example-id and creates a playlist from a |pipe-separated list of media file links. The links must be the full path. Titles are not used in this case.
- Music Player - Version 3.0
and higher. The musicplayer option installs a customizable
Flash music player, which is generated and served from JasonLau.biz.
Supports MP3, SWF, and FLV formatted audio files only. No video. The
musicplayer has it's own set of attributes, which are easy to
use. When using musicplayer, you must also include the playlist
and titles parameters. Be sure to have the same number of
titles as you do playlist items! See the example below.
$("#example-player").jlEmbed({
musicplayer: 'BGImage= BackgroundColor=00248E IconColor=809FFE IconActiveColor=BFCFFE PlayIconActiveColor=33FF00 StopIconActiveColor=FF0000 Icons=yes Dividers=yes Fader=no Autoplay=no Loop=yes Shuffle=yes',
playlist: 'http://jasonlau.biz/public/mixdown.mp3|http://jasonlau.biz/public/mixdown.mp3|http://jasonlau.biz/public/mixdown.mp3|http://jasonlau.biz/public/mixdown.mp3',
titles: 'Mixdown 1|Mixdown 2|Mixdown 3|Mixdown 4'
});

Here is the music player which is used.
This example installs the music player on the object example-player. I have included all of the available musicplayer options in this example. As you can see, the playlist and titles parameters have been included. The playlist links and the titles are each separated by a |pipe (vertical bar). There are no # hash symbols required for the musicplayer color hex codes. Spaces in the titles do not need to be encoded, however, some characters may not appear as intended. Titles are displayed in the right-click context menu for the music player.
- YouTube - Version 4.0 and higher.
The youtube option installs the specified YouTube video on
the object when a YouTube video id is present. As demonstrated below, the YouTube option will also accept a playlist consisting of a |pipe separated list of YouTube video IDs. There are no restrictions to the length of a playlist.
$("#example-player").jlEmbed({
youtube : 'UrVp2BMvtaU|Cw2HAD9A_rw|UrVp2BMvtaU'
});
The following is an example of installing 2 YouTube players on the same page.
$("#example-player").jlEmbed({
id : 'player1',
youtube : 'Cw2HAD9A_rw',
format : 'swfobject',
autoplay : 'no',
youtubechromeless : 'no'
});
$("#example-player2").jlEmbed({
id : 'player2',
youtube : 'VicwLWPho08',
format : 'swfobject',
autoplay : 'yes',
youtubechromeless : 'no',
youtubedebug : true,
youtubedisplay : false
});
Once the YouTube player has loaded, you can call any of the jlEmbed/YouTube Javascript API Functions as in the following example.
<a href="javascript:void(0)" onclick="jlembed_stopVideo('player1');">Stop</a>
<a href="javascript:void(0)" onclick="jlembed_playVideo('player1');">Play</a>
<a href="javascript:void(0)" onclick="jlembed_pauseVideo('player1');">Pause</a>
<a href="javascript:void(0)" onclick="jlembed_loadVideoById('player1', 'Cw2HAD9A_rw');">Load A New Video</a>
<a href="javascript:void(0)" onclick="jlembed_loadVideoByURL('player1', 'http://www.youtube.com/watch?v=VicwLWPho08');">Load A New Video</a>