So I have video.js player working OK in a phoenix 1.5.x view. I added "videojs-seek-buttons": "^1.6.0"
to package.json and I’d like to run some raw JS to add some seek buttons to the player in the DOM. I just can’t seem to find the running videojs player to add the seek buttons to. I’m not sure if I’m off-base with my script import locations or it’s a lack of understand of JS?
app.html.eex:
...
<link href="http://vjs.zencdn.net/7.11.0/video-js.css" rel="stylesheet">
<script src="http://vjs.zencdn.net/7.11.0/video.js"></script>
</head>
show.html.eex:
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/videojs-seek-buttons/dist/videojs-seek-buttons.css">
<script src="https://cdn.jsdelivr.net/npm/videojs-seek-buttons/dist/videojs-seek-buttons.min.js"></script>
<video id="my_video" class="video-js" controls preload="none" width="640" height="264" data-setup='{ "playbackRates": [0.5, 0.75, 1, 1.25, 1.5, 1.75, 2] }'>
<source src="<%= Routes.watch_path(@conn, :show, @video) %>" type='<%= @video.content_type %>'>
<p class="vjs-no-js">
To view this video please enable JavaScript, and consider upgrading to a web browser that
<a href="http://videojs.com/html5-video-support/" target="_blank">supports HTML5 video</a>
</p>
</video>
<script>
console.log("my_video")
players = window.videojs.getAllPlayers
console.log("players")
console.log(players)
var player = players[0]
console.log("player[0]")
console.log(player)
player.seekButtons({
forward: 15,
back: 15});
</script>
my_video
ƒ () { return (// Disposed players leave a key with a
null value, so we need to make sure // we filter those out.
player[0]
undefined
Uncaught TypeError: Cannot read property 'seekButtons' of undefined ...