You wouldn't be able to use the connect(), initialize(), and disconnect() as those are functions for stimulus. Since your ID attribute of your video player is my-video then you would need to change the selector to document.getElementById('my-video')
Keep in mind that "disabling" the "save video" option is a false sense of security with your video. I actually did not disable it on these videos, but rather I am using Adaptive Bitrate Streaming on all of the videos. So, depending on your internet connection, it will auto select a m3u8 file which would best match your bandwidth. This will stream smaller video files of various qualities. You essentially "lose" the capability of being able to download the video file since it's now just a blob reference to the m3u8. However, there is a lot more involved with transcoding videos with Adaptive Bitrate Streaming. You can check out this video on how I accomplished it.
After adding video_controller.js and updating the content_tags the video is no longer showing, and I'm getting this warning in the console.:
guide.js:19 Please replace data-target="video.player" with data-video-target="player". The data-target attribute is deprecated and will be removed in a future version of Stimulus. video
I'm not sure if the warning is why it's not showing, but I also can't figure out how to format the content_tag to change that attribute. Any advice? Cheers.
Thanks, the second one worked with a minor typo fix (missing curly brace):
<%= content_tag :video, { 'data-video-target': 'player' } do %>
Unfortunately, I'm getting no video or console errors still.
For what it's worth, I did get it to work with the plain js block from the videojs site:
<video id="my-video" class="video-js vjs-big-play-centered item-video" controls preload="auto" data-setup="{}">
<source src="<%= url_for(@item.attachment) %>" type="<%= @item.attachment.content_type %>" />
<p class="vjs-no-js">
To view this video please enable JavaScript, and consider upgrading to a web browser that <a href="https://videojs.com/html5-video-support/" target="_blank">supports HTML5 video</a>
</p>
</video>
Let me know if there's anything else worth trying. Cheers.
packs/application.js
?this.playerTarget
you could use a DOM selector likedocument.getElementById
This one works however it does not seem to be the best solution:
connect()
,initialize()
, anddisconnect()
as those are functions for stimulus. Since your ID attribute of your video player ismy-video
then you would need to change the selector todocument.getElementById('my-video')
So it should look something more like this.
Parcing error: Unterminated string constant
'my-video'
my-video
for the selector, you'd need to set the id attribute.Is there a reason why you're wanting to implement this without Stimulus?
m3u8
file which would best match your bandwidth. This will stream smaller video files of various qualities. You essentially "lose" the capability of being able to download the video file since it's now just a blob reference to them3u8
. However, there is a lot more involved with transcoding videos with Adaptive Bitrate Streaming. You can check out this video on how I accomplished it.https://www.driftingruby.com/episodes/adaptive-bitrate-streaming-with-active-storage
I'm not sure if the warning is why it's not showing, but I also can't figure out how to format the content_tag to change that attribute. Any advice? Cheers.
could be changed to
or
Unfortunately, I'm getting no video or console errors still.
For what it's worth, I did get it to work with the plain js block from the videojs site:
Let me know if there's anything else worth trying. Cheers.