# videos.bentasker.co.uk

A set of javascript used to simplify embedding a video player into other sites (allowing playback from a core, cacheable video domain).


### Issues

The project is tracked in JIRA project [VID](https://jiralist.bentasker.co.uk/browse/VID.html)


----


### Uploading Videos

For now, videos should be SCP'd up, ideally as HLS

    scp -r 20170111-noisy-bearing/ hiyori:/usr/share/nginx/static/videos/2017/


### Embedding Videos

The player will take on the dimensions of it's parent container, so it's probably desirable to wrap the call to it in a div of the desired size.

Call in the `embed` script, and then call the embed function passing the video path to it:

    <div style="width: 60%">
       <script type="text/javascript" src="https://videos.bentasker.co.uk/resources/embed/embed.min.js"></script>
       <script type="text/javascript">embedBensPlayer('2017/20170111-noisy-bearing/noisy_bearing_master.m3u8');</script>
    </div>

Videos must be hosted on https://videos.bentasker.co.uk otherwise the player will refuse to play them.

The path is simply the path under the docroot (i.e. the path as seen below `/usr/share/nginx/static/videos/` on hiyori).


#### Non-HLS media

It's preferred that media be HLS, however if `embedBensPlayer` will attempt to determine the mimetype based on the filename extension of the playpath it's provided.

It can currently recognise

* `m3u8`
* `avi`
* `mp3`
* `mkv`
* `webm`
* `mov`
* `mpg`
* `mpeg`
* `mp4`
* `mp4a`
* `wav`

If it cannot identify from the filename extension, then `video/mp4` will be assumed


----

### Caching

As of [CDN-13](https://jiralist.bentasker.co.uk/browse/CDN-13.html) media files are cached in a dedicated cache zone on the edge, and will be kept in cache for a year (assuming they aren't LRU'd out first).


----

### Release

All embeds use a minified copy of the codebase by default, so the various scripts need to be minified in order for them to actually be used. The `nodejs` script `uglifyjs` is used for this purpose. In order to install:

	sudo apt-get install node-uglify

To create the release files we do

	./do_release.sh [version number]

e.g.

	./do_release.sh 0.15

This will create the minifed files which should then be uploaded to the prod server.


----

### Copyright

Copyright (c) 2019 [B Tasker](https://www.bentasker.co.uk/)
