I have a page with a video in it (using video_tag); the video url is stored in an instance variable in my controller. I'm trying to use jQuery to write my own controls for the video, but I can't seem to make it work.
I am certain that the javascript is rendering properly, because I've replaced the video-related code in the click event with a simple function that changes the background color, and it worked
This makes me believe that I'm improperly targeting the video itself since I'm using video_tag and adding a class attribute instead of an html video tag.
Here is my html and my javascript, including the video_tag and the button:
<div id="video-container">
<%= video_tag @video, class: "actual-video" %>
<button class="playbutton">Play or Pause</div>
</div>
<script>
$(".playbutton").on("click", function() {
if (".actual-video").paused {
$( ".actual-video" ).play();
} else {
$(".actual-video").pause();
}
});
I'm calling on the expertise of some Ruby on Rails peeps to tell me if there's something I need to know about properly targeting a video using video_tag and the class attribute. I believe that this is the problem, but if any of you spot anything fundamentally wrong with my code, please let me know! Thanks in advance!!!