There are a number of ways to play your own content through the player. We will go through them in order of difficulty.
Take a look at the demo page. It contains four examples for setting up the player in your own page.
Pros:
- Already hosted.
- Very little work required to use.
Cons:
- Not embedded in your own page.
- Can't change the style.
- URL is long and ugly.
The file should have the following format:
---
title: "Title of the video"
author: "Your name here"
videoId: "tWzslFE9Qvg"
markers:
"0:35": "This thing happened at this time"
"5:04": "Now this happened"
"17:00": "Someone said \"This is how you escape quotes\""
"3:54:09": "Nothing happened for a long time, but now things are happening again"
"17:02:47": "This is a long video"
---
The videoId
field contains Youtube's video ID of the video you want to play (https://youtube.com/watch?v=[this part]
). There's no support for Vimeo yet.
Host this file somewhere that will serve the file contents (and only the contents). This can be easily done with https://gist.github.com:
- Create a new gist and paste in your annotation file.
- Click the "Raw" button to get the url to the file contents.
You're done! Go to http://asafgartner.github.io/annotations_player/player.html#[full url to the raw file here]
and it should play the video while tracking the markers.
Please contact me if you encounter any issues.
Pros:
- Embedded in your own page.
- You can change the player style.
Cons:
- Some setup required.
- Still loads and parses an annotation file before it can start playing.
The file should have the following format:
---
title: "Title of the video"
author: "Your name here"
videoId: "tWzslFE9Qvg"
markers:
"0:35": "This thing happened at this time"
"5:04": "Now this happened"
"17:00": "Someone said \"This is how you escape quotes\""
"3:54:09": "Nothing happened for a long time, but now things are happening again"
"17:02:47": "This is a long video"
---
The videoId
field contains Youtube's video ID of the video you want to play (https://youtube.com/watch?v=[this part]
). There's no support for Vimeo yet.
- Copy both
<style>
segments into your page's CSS. - Copy the
playerContainer
div along with all of its content into your page's HTML. - Copy the inline
<script>
segment into your page's javascript. - Copy the youtube iframe api
<script>
tag into your page's HTML.
NOTE: Make sure the youtube iframe api is the last piece of javascript to load in the page.
NOTE: If you'd like to put the inline js in a file and load it in the <head>
, please make sure generatePlayer
will only be called after the playerContainer
is on the page.
- Hardcoding the annotation file location:
- Find the line that reads
var annotationsFileLocation = null;
- Replace
null
with the full url to your annotation file - Delete the line
var hash = ...
and theif (hash ...
block, since we're no longer reading the url fromlocation.hash
- Change the style:
- You can play with all the values in the
STREAMER STYLE
block in the CSS - You can change the width of the player by setting a fixed width on the
playerContainer
div - You may want to remove the
episodeList
anchor and styles - Instead of setting the author field in the annotation file, search for "Probably Miblo" and change it to another default
- You can change the width of the markers column by changing the width of
.marker .content, .marker .complated
in the CSS - You can move the markers column to the left of the video simply by placing the
markersContainer
div beforevideoContainer
(make sure both stay insidemiddleContainer
) - If you want the video to autoplay when the page is loaded, add
player.playVideo()
to theonPlayerReady
function afterstart()
Please contact me if you encounter any issues.
Pros:
- It might load faster, and you can cache the entire page on your server.
- You can manage the metadata in any way you like (database instead of text file maybe?).
- You can change whatever you like. Maybe you want to change the
author
span to a link to the author's page?
Cons:
- It requires more extensive modifications to the player's code.
- Copy both
<style>
segments into your page's CSS. - Copy the
playerContainer
div along with all of its content into your page's HTML. - Copy the inline
<script>
segment into your page's javascript. - Copy the youtube iframe api
<script>
tag into your page's HTML.
NOTE: Make sure the youtube iframe api is the last piece of javascript to load in the page.
NOTE: If you'd like to put the inline js in a file and load it in the <head>
, please make sure generatePlayer
will only be called after the playerContainer
is on the page.
- Remove all the code under
// Page generation stuff
. - Add your own code to set
domReady = true
and callinitVideo()
once the DOM is ready.
- Fill in the
title
span with your video's title. - Fill in the
author
span with the author's name. - Add a
data-videoId
attribute to the#player
div and set it to Youtube's video ID (https://youtube.com/watch?v=[this part]
).
Each marker is composed of the following HTML structure:
<div class="marker" data-timestamp="500">
<div class="content">The marker's text goes here</div>
<div class="fadedProgress">
<div class="completed">The marker's text goes here</div>
</div>
<div class="progress">
<div class="completed">The marker's text goes here</div>
</div>
</div>
NOTE: data-timestamp
is the number of seconds since the beginning of the video.
NOTE: The same marker's text is rendered three times into different elements. This is required in order to get the filling-in effect. It should be exactly the same text into all three elements.
These marker divs should be put inside the markersContainer
div. They are expected to be sorted by data-timestamp
.
- Change the style:
- You can play with all the values in the
STREAMER STYLE
block in the CSS - You can change the width of the player by setting a fixed width on the
playerContainer
div - You may want to remove the
episodeList
anchor and styles - You can change the width of the markers column by changing the width of
.marker .content, .marker .complated
in the CSS - You can move the markers column to the left of the video simply by placing the
markersContainer
div beforevideoContainer
(make sure both stay insidemiddleContainer
) - If you want the video to autoplay when the page is loaded, add
player.playVideo()
to theonPlayerReady
function afterstart()
Please contact me if you encounter any issues.