A simple, lightweight, accessible and customizable HTML5, YouTube and Vimeo media player that supports modern browsers.
The Player component uses the Plyr library.
Usage
To apply this component, add the gls-player
class to a <video>
element.
<video class="gls-player"></video>
<video class="gls-player" controls crossorigin playsinline poster="https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-HD.jpg"> <!-- Video files --> <source src="https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-576p.mp4" type="video/mp4" size="576"> <source src="https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-720p.mp4" type="video/mp4" size="720"> <source src="https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-1080p.mp4" type="video/mp4" size="1080"> <source src="https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-1440p.mp4" type="video/mp4" size="1440"> <!-- Caption files --> <track kind="captions" label="English" srclang="en" src="https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-HD.en.vtt" default> <track kind="captions" label="Français" srclang="fr" src="https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-HD.fr.vtt"> </video>
Kaltura Video Embed
This tutorial explains how to embed Kaltura videos in our player. Owners can generate a direct link to MP4 video files for their uploaded media. This link or URL allows you to use your videos within our custom player.
-
The URL for the direct MP4 link has the following structure: "https://www.kaltura.com/p/797802/sp/0/playManifest/entryId/{entryId}/format/url/flavorParamId/{flavorParamId}/video.mp4". Paste this URL (without quotes) in to your favorite plain-text editor and get ready to modify it.
NOTE: Please take notice that certain words appear twice, "entryID" and "flavorParamID". We will be replacing the ones wrapped in curly braces "{}" and leaving the ones not wrapped in curly braces. -
In this step we will be modifying the {flavorParamId}. The flavorParamID designates the quality or flavor of the video. Decide which flavor you would like to use by copying the corresponding ID from the following table:
ID Bitrate Dimensions Description 0 Unknown [auto] x [auto] This is the original media file that you uploaded to Kaltura. 487051 664 640 x [auto] Standard Definition 487081 2628 [auto] x 720 720p 487091 4128 [auto] x 1080 1080p After copying the ID that works for you, paste it into the URL you previously pasted into your plain text editor. You should replace the text {flavorParamId} with the number you copied. Your URL should now look something like this: "https://www.kaltura.com/p/797802/sp/0/playManifest/entryId/{entryId}/format/url/flavorParamId/487081/video.mp4"
-
Now we need to get the entry_id for the video to which you are linking. The entry_id is a unique identifier for every video in Kaltura. You can get your entry_id by going to MediaSpace and navigating to your "My Media". Once in "My Media" click on the title of the media to which you want to link. This takes you to the media page. The URL for a media page has this structure: "https://mediaspace.wisc.edu/media/[Title of Media]/[entry_id]". Here is an example: https://mediaspace.wisc.edu/media/Canvas+-+Faculty+Center+Grade+Prep+Tool+%28UW-Madison%29/0_rl4tg8ta. Copy the entry_id for your media.
-
Paste the entry_id into the URL you modified in step two. You should replace the text {entryId} with your entry_id. Your URL should now look something like this: "https://www.kaltura.com/p/797802/sp/0/playManifest/entryId/0_rl4tg8ta/format/url/flavorParamId/487081/video.mp4".
-
Paste your newly formed URL into your favorite browser. Your video should begin playing. If it doesn't re-check the steps in this tutorial and make sure you copied everything correctly.
<video class="gls-player" controls crossorigin playsinline poster="">
<source src="" type="video/mp4">
</video>
<video class="gls-player" controls crossorigin playsinline poster="http://cfvod.kaltura.com/p/797802/sp/79780200/thumbnail/entry_id/1_z4a9isw1/version/100021"> <source src="https://www.kaltura.com/p/797802/sp/0/playManifest/entryId/1_z4a9isw1/format/url/flavorParamId/487051/video.mp4" type="video/mp4" size="480"> <source src="https://www.kaltura.com/p/797802/sp/0/playManifest/entryId/1_z4a9isw1/format/url/flavorParamId/487081/video.mp4" type="video/mp4" size="720"> <source src="https://www.kaltura.com/p/797802/sp/0/playManifest/entryId/1_z4a9isw1/format/url/flavorParamId/487091/video.mp4" type="video/mp4" size="1080"> </video>
YouTube Embed
To embed YouTube videos.
<div class="gls-player">
<iframe src="" allowfullscreen allowtransparency allow="autoplay"></iframe>
</div>
-
<div class="gls-player"> <iframe src="https://www.youtube.com/embed/bTqVqk7FSmY?origin=https://plyr.io&iv_load_policy=3&modestbranding=1&playsinline=1&showinfo=0&rel=0&enablejsapi=1" allowfullscreen allowtransparency allow="autoplay"></iframe> </div>
Vimeo Embed
To embed Vimeo videos.
<div class="gls-player">
<iframe src="" allowfullscreen allowtransparency allow="autoplay"></iframe>
</div>
-
<div class="gls-player"> <iframe src="https://player.vimeo.com/video/76979871?loop=false&byline=false&portrait=false&title=false&speed=true&transparent=0&gesture=media" allowfullscreen allowtransparency allow="autoplay"></iframe> </div>
Audio
Add an audio player to a page.
<audio class="gls-player" crossorigin playsinline>
<source src="" type="audio/mp3">
<source src="" type="audio/ogg">
</audio>
<audio class="gls-player" crossorigin playsinline> <source src="https://cdn.plyr.io/static/demo/Kishi_Bashi_-_It_All_Began_With_a_Burst.mp3" type="audio/mp3"> <source src="https://cdn.plyr.io/static/demo/Kishi_Bashi_-_It_All_Began_With_a_Burst.ogg" type="audio/ogg"> </audio>
Kaltura Audio Embed
This tutorial explains how to embed Kaltura audio in our player. Owners can generate a direct link to MP3/OGG audio files for their uploaded media. This link or URL allows you to use your videos within our custom player.
-
The URL for the direct MP4 link has the following structure: "https://www.kaltura.com/p/797802/sp/0/playManifest/entryId/{entryId}/format/url/a.mp3". Paste this URL (without quotes) in to your favorite plain-text editor and get ready to modify it.
NOTE: Please take notice that certain the word "entryID" appears twice. We will be replacing the one wrapped in curly braces "{}". -
Now we need to get the entry_id for the video to which you are linking. The entry_id is a unique identifier for every video in Kaltura. You can get your entry_id by going to MediaSpace and navigating to your "My Media". Once in "My Media" click on the title of the media to which you want to link. This takes you to the media page. The URL for a media page has this structure: "https://mediaspace.wisc.edu/media/[Title of Media]/[entry_id]". Here is an example: https://mediaspace.wisc.edu/media/Canvas+-+Faculty+Center+Grade+Prep+Tool+%28UW-Madison%29/0_rl4tg8ta. Copy the entry_id for your media.
-
Paste the entry_id into the URL you modified in step two. You should replace the text {entryId} with your entry_id. Your URL should now look something like this: "https://www.kaltura.com/p/797802/sp/0/playManifest/entryId/0_2euvoird/format/url/a.mp3".
-
Paste your newly formed URL into your favorite browser. Your audio should begin playing. If it doesn't re-check the steps in this tutorial and make sure you copied everything correctly.
<audio class="gls-player" crossorigin playsinline>
<source src="" type="audio/mp3">
<source src="" type="audio/ogg">
</audio>
<audio class="gls-player" crossorigin playsinline> <source src="https://www.kaltura.com/p/797802/sp/0/playManifest/entryId/0_2euvoird/format/url/a.mp3" type="audio/mp3"> <source src="https://www.kaltura.com/p/797802/sp/0/playManifest/entryId/0_2euvoird/format/url/a.ogg" type="audio/ogg"> </audio>
Component options
Options can be passed as an object to the constructor as above or as JSON in data-plyr-config
attribute on each of your target elements:
<video src="{{ baseurl }}/path/to/video.mp4" id="player" controls data-plyr-config='{ "title": "This is an example video", "volume": 1, "debug": true }'></video>
Note the single quotes encapsulating the JSON and double quotes on the object keys. Only string values need double quotes.
Option | Type | Default | Description |
---|---|---|---|
enabled |
Boolean | true |
Completely disable Plyr. This would allow you to do a User Agent check or similar to programmatically enable or disable Plyr for a certain UA. Example below. |
debug |
Boolean | false |
Display debugging information in the console |
controls |
Array, Function or Element | ['play-large', 'play', 'progress', 'current-time', 'mute', 'volume', 'captions', 'settings', 'pip', 'airplay', 'fullscreen'] |
If a function is passed, it is assumed your method will return either an element or HTML string for the controls. Three arguments will be passed to your function; id (the unique id for the player), seektime (the seektime step in seconds), and title (the media title). See controls.md for more info on how the html needs to be structured. |
settings |
Array | ['captions', 'quality', 'speed', 'loop'] |
If you’re using the default controls are used then you can specify which settings to show in the menu |
i18n |
Object | See defaults.js | Used for internationalization (i18n) of the text within the UI. |
loadSprite |
Boolean | true |
Load the SVG sprite specified as the iconUrl option (if a URL). If false , it is assumed you are handling sprite loading yourself. |
iconUrl |
String | null |
Specify a URL or path to the SVG sprite. See the SVG section for more info. |
iconPrefix |
String | plyr |
Specify the id prefix for the icons used in the default controls (e.g. “plyr-play” would be “plyr”). This is to prevent clashes if you’re using your own SVG sprite but with the default controls. Most people can ignore this option. |
blankVideo |
String | https://cdn.plyr.io/static/blank.mp4 |
Specify a URL or path to a blank video file used to properly cancel network requests. |
autoplay |
Boolean | false |
Autoplay the media on load. This is generally advised against on UX grounds. It is also disabled by default in some browsers. If the autoplay attribute is present on a <video> or <audio> element, this will be automatically set to true. |
autopause ¹ |
Boolean | true |
Only allow one player playing at once. |
seekTime |
Number | 10 |
The time, in seconds, to seek when a user hits fast forward or rewind. |
volume |
Number | 1 |
A number, between 0 and 1, representing the initial volume of the player. |
muted |
Boolean | false |
Whether to start playback muted. If the muted attribute is present on a <video> or <audio> element, this will be automatically set to true. |
clickToPlay |
Boolean | true |
Click (or tap) of the video container will toggle play/pause. |
disableContextMenu |
Boolean | true |
Disable right click menu on video to help as very primitive obfuscation to prevent downloads of content. |
hideControls |
Boolean | true |
Hide video controls automatically after 2s of no mouse or focus movement, on control element blur (tab out), on playback start or entering fullscreen. As soon as the mouse is moved, a control element is focused or playback is paused, the controls reappear instantly. |
resetOnEnd |
Boolean | false | Reset the playback to the start once playback is complete. |
keyboard |
Object | { focused: true, global: false } |
Enable keyboard shortcuts for focused players only or globally |
tooltips |
Object | { controls: false, seek: true } |
controls : Display control labels as tooltips on :hover & :focus (by default, the labels are screen reader only). seek : Display a seek tooltip to indicate on click where the media would seek to. |
duration |
Number | null |
Specify a custom duration for media. |
displayDuration |
Boolean | true |
Displays the duration of the media on the “metadataloaded” event (on startup) in the current time display. This will only work if the preload attribute is not set to none (or is not set at all) and you choose not to display the duration (see controls option). |
invertTime |
Boolean | true |
Display the current time as a countdown rather than an incremental counter. |
toggleInvert |
Boolean | true |
Allow users to click to toggle the above. |
listeners |
Object | null |
Allows binding of event listeners to the controls before the default handlers. See the defaults.js for available listeners. If your handler prevents default on the event (event.preventDefault() ), the default handler will not fire. |
captions |
Object | { active: false, language: 'auto', update: false } |
active : Toggles if captions should be active by default. language : Sets the default language to load (if available). ‘auto’ uses the browser language. update : Listen to changes to tracks and update menu. This is needed for some streaming libraries, but can result in unselectable language options). |
fullscreen |
Object | { enabled: true, fallback: true, iosNative: false } |
enabled : Toggles whether fullscreen should be enabled. fallback : Allow fallback to a full-window solution. iosNative : whether to use native iOS fullscreen when entering fullscreen (no custom controls) |
ratio |
String | 16:9 |
The aspect ratio you want to use for embedded players. |
storage |
Object | { enabled: true, key: 'plyr' } |
enabled : Allow use of local storage to store user settings. key : The key name to use. |
speed |
Object | { selected: 1, options: [0.5, 0.75, 1, 1.25, 1.5, 1.75, 2] } |
selected : The default speed for playback. options : Options to display in the menu. Most browsers will refuse to play slower than 0.5. |
quality |
Object | { default: 'default', options: ['hd2160', 'hd1440', 'hd1080', 'hd720', 'large', 'medium', 'small', 'tiny', 'default'] } |
Currently only supported by YouTube. default is the default quality level, determined by YouTube. options are the options to display. |
loop |
Object | { active: false } |
active : Whether to loop the current video. If the loop attribute is present on a <video> or <audio> element, this will be automatically set to true This is an object to support future functionality. |
ads |
Object | { enabled: false, publisherId: '' } |
enabled : Whether to enable vi.ai ads. publisherId : Your unique vi.ai publisher ID. |
urls |
Object | See source. | If you wish to override any API URLs then you can do so here. You can also set a custom download URL for the download button. |
JavaScript
Unlike other components, this does not use Gloss. Learn more about how to use Plyr.
Initialization
new Plyr('#player');