A clean and functional embeddable HTML video player, hosted with Github Pages.
Space
: Play/pause the videoF
: Toggle fullscreenM
: Toggle muteLeft arrow
: Skip back 10 secondsRight arrow
: Skip forward 10 secondsDouble-tap left
: Skip back 10 secondsDouble-tap right
: Skip forward 10 secondsTry out the embed generator to get a feel for CyberVideoPlayer with your own videos.
Example working URL:
https://cybergen49.github.io/CyberVideoPlayer/player/?src=aHR0cDovL2NvbW1vbmRhdGFzdG9yYWdlLmdvb2dsZWFwaXMuY29tL2d0di12aWRlb3MtYnVja2V0L3NhbXBsZS9CaWdCdWNrQnVubnkubXA0&autoplay
Embedding the player on your site:
<!-- `width` and `height` can be changed here to suit your needs, or removed entirely to style with CSS -->
<!-- Be sure to replace `src` with your own link -->
<iframe src="https://cybergen49.github.io/CyberVideoPlayer/player/?src=aHR0cDovL2NvbW1vbmRhdGFzdG9yYWdlLmdvb2dsZWFwaXMuY29tL2d0di12aWRlb3MtYnVja2V0L3NhbXBsZS9CaWdCdWNrQnVubnkubXA0&autoplay"
allow="autoplay; fullscreen"
frameborder=0
width=384
height=216
id="videoPlayer"
>
Without allowing autoplay, the player might have trouble autoplaying the video if the user doesn’t interact with it first. Without allowing fullscreen, all fullscreen functionality will cease to function.
cybergen49.github.io/CyberVideoPlayer
can be replaced with vid.simplecyber.org
for a shorter URL, but only in this specific repository (meaning it won’t work if you clone, download, etc.)
This repository is a template, so it’s easy to clone it for yourself if you want to make changes or use your own domain.
These parameters control various aspects of the player. Pass them after the main URL and a question mark (?), and separate each parameter with an ampersand (&). Parameters without an equal sign don’t need a value.
src=url
: The video file to play, where url
is a base64-encoded absolute (not relative) video URLautoplay
: The video will automatically play on loadstart=t
: The video will move to t
seconds on loadnoDownload
: Removes the Download buttonnoCopyUrl
: Removes the ‘Copy video URL’ context menu optionnoRestore
: Prevents video progress from being saved and restoredsrc
was providedsrc
parameterCyberVideoPlayer allows for its parent site to access some video information. Use the following Javascript on your site to read and save data sent from the player:
// Save messages from the player
var videoData = {};
window.onmessage = function(e) {
// Update the videoData object
Object.assign(window.videoData, e.data);
// Log the most up to date data to the console
console.log(videoData);
};
failed
: true
if the video has failed to loadstatus
: playing
, paused
, finished
, or buffering
time
: The current video position in secondsduration
: The total video duration in secondsNote that the player only sends data as it changes, so you shouldn’t rely on a property existing at any given time. The use of Object.assign()
allows us to update the videoData
object with the most up-to-date data and use it elsewhere.
In addition to reading data from the player, you can also send it commands to control it. Use the following Javascript to send a command to the player.
// Replace 'videoPlayer' with the ID of your <iframe>
var player = document.getElementById("videoPlayer");
// Build the command
var msg = {'cmd': 'pause'};
// Send the message
player.contentWindow.postMessage(msg, '*');
{'cmd': 'play'}
: Plays the video{'cmd': 'pause'}
: Pauses the video{'cmd': 'time', 'time': t}
: Changes the current time of the video, where t
is a number of secondsHotfix commits to the repo aren’t mentioned here.
noBackground
and script
parameters