Ask A Question


You’re not receiving notifications from this thread.

Changing currentTime of video in Rails webpacker-react component

gjaros asked in Rails

So I was able to put a react component in a sandbox and get it working as I wanted. In isolation it just manages the currentTime of a video. In the main app clicking a button changes the state of timestamp (in Redux) which is supplied to the featured component VideoPlayer which then changes currentTime of the referenced video.

In my Rails project (repo) it is supposed to do that as well as control the state of a post containing video and reviews with comments (called tips) using Redux. However, when I put the component in my Rails project the component fails to seek through the video despite the component receiving the timestamp and having the right reference to the video.

Here is me clicking on buttons in the modal and what is being sent back via console.log(). The feedback "inside seek" tells me (1) that the function seek() in app/javascript/owc_post/components/VideoPlayer.js, responsible for setting the currentTime, is being called, (2) the timestamp is being received, and (3) my video's currentTime property is being referenced and accessed correctly. Yet, the currentTime is not being changed to timestamp. However, it does reset to 0 (the video property, not Redux state) every time I update the state by clicking a button. (idk, might be important?) The other than 0 numbers you are seeing is when I let the video play and then I click a button; it returns the above feedback as well as where the video's currentTime.

The videos are uploaded to Rails Active Storage when a post is created and the urls are sent to my webpacker-react component rendered in app/views/posts/_post_modal.html.haml.

#owc-post-payload{ post: post.to_json, video: url_for(, reviews: reviews.to_json, profiles: profiles.to_json, tips: tips.to_json }
= javascript_pack_tag 'owc_post'

From searching for a solution it might have to do with byte range support but I'm not getting any of the errors that are described in those questions so I'm at a loss for what to do. Let me know if you guys need anything else and thank you in advance for your help.

Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 83,453+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.