Nestube
An Angular Elements project that generates Web Components that provide a Video.js video player for http streaming. The player integrates a number of Video.js plugins to generate a playlist and provide a user-selectable quality control for HLS sources.
Usage
The following outlines an example usage in Moodle. It assumes that you use the nestube.js script on NES and that you have uploaded a hls video folder prepared with the script contained in this repository (create-hls.sh in the project root folder). The script takes two parameters. The first one is the input file. The second parameter is the name of the output folder. The bash script requires ffmpeg to be installed on the machine. At the time of writing OZ has a working ffmpeg installation that you can use.
<script src="https://www.nes.uni-due.de/lecture-videos/nestube.js"></script>
<custom-video-control id="lecture" video-width="800" video-height="450" playlist-width="800" playlist-height="125" key="bmVzOmxlY3R1cmVzMjAyMA=="
matomo-location="https://project.nes.uni-due.de/matomo/matomo.php" matomo-site-id="1">
<custom-video-file player="lecture" title="Organization" source="https://www.nes.uni-due.de/lecture-videos/pcl/00-Organization"></custom-video-file>
<custom-video-file player="lecture" title="Introduction" source="https://www.nes.uni-due.de/lecture-videos/pcl/01-Introduction"></custom-video-file>
<custom-video-file player="lecture" title="Middelware 1" source="https://www.nes.uni-due.de/lecture-videos/pcl/02-Middleware"></custom-video-file>
</custom-video-control>
You can add this script as a Moodle label. To do this, click on "Add" and select "Label" and then set the editor to HTML mode (there is a code symbol in the toolbar of the HTML Editor, i.e. </>).
The filesystem location of https://www.nes.uni-due.de/lecture-videos is /var/www/extranet/htdocs/lecture-videos.
Note that there are no trailing slashes when defining the video source.
Control
The selected playlist item can be controlled via a hash on the players page. Assuming that your player is running on the page http://mysite.com/pagewithplayer, you can add a hash with an index value to select a particular playlist item. For example, http://mysite.com/pagewithplayer#0 will select the 1st entry and http://mysite.com/pagewithplayer#3 will select the 4th entry. Note that the player will also listen for hash changes so that you can create links on the same page to control the playlist.
Caveats: If you are running multiple players on a single page, all players will react to the same hash. Any hash change (i.e. even hash changes that are not indended for the player) will cause the playlist to be reloaded which may stop the running playback.
Development
Angular Elements has a number of short-comings. Apparently projections are not working properly and there is no really good way to enable component interaction. The approach taken here is that the video-control component sets two functions on its html element which are then called by the video-file component once it finished loading. This works as long as video-file components are hosted inside a video-control component (which is how they are intended to be used). If this is not the case, there will be an "element does not have an addSource function" error. Unfortunately, this approach does not work properly in the "old" Microsoft Edge browser (i.e. the version that is not based on Chromium). As a workaround, we detect this browser and use an id tag to globally detect the player. This is done by a) assigning an id attribute to the video-control and setting the player attribute of the video-file to the same value.
To generate the elements, it is necessary to uncomment the bootstrap components. So for development, you might want to add the bootstrap back to the app module. Then you can use the app component for testing.
The "npm run build" script will generate the final standalone nestube.js script in the dist folder. It is essentially a concatenation of the es5 bundles for maximum compatibility.