Get video length (Interactive Videos)
Submitted by ymdahi on Sat, 04/14/2018 - 04:38
Forums:
I'm wondering if there is a way to pull the length of the video for interactive videos (specifically youtube video in my case).
I'm hoping to do this with the hooks already available, i.e. without having to get youtube api key. Is there a mechanism in h5p to get the current h5p node's video duration?
Thanks in advance.
Summary:
Get video duration from h5p interactive video instance
thomasmars
Wed, 04/18/2018 - 09:00
Permalink
There is indeed, if you look
There is indeed, if you look at the code on github you'll find that the getDuration() function is exported, which allows you to call it.
When inside the H5P iFrame you can call it using the following code:
ymdahi
Wed, 05/02/2018 - 16:15
Permalink
Hi Thomas, Thanks for
Hi Thomas, Thanks for pointing that out, that's very useful. My next goal is to store this value on save/update. Any recommendations on how to approach that would be appreciated. I'll share my solution at the end.
Thanks again!
thomasmars
Thu, 05/03/2018 - 08:26
Permalink
Hi, there's currently no API
Hi, there's currently no API for hooking into the save/update functions of H5P content, and you would not have access to the H5P instance there either way. Depending on what you want to accomplish there may be other ways to achieve what you want.
ymdahi
Tue, 05/08/2018 - 17:20
Permalink
What I'm hoping to do is
What I'm hoping to do is display the length of the video in a view. For example, if the view is display a grid of videos, I would like to also display the length of each video - I've attached a screenshot from a site that demonstrates this visually.
Additionally, it would be ideal if the length of videos in a series can be added together (i.e. Series X with 10 videos is 20 hours long).
Any guidance on how to do this efficiently would be helpful.
tim
Tue, 05/15/2018 - 14:05
Permalink
This is beyond the scope of
This is beyond the scope of H5P. You'll have to write some code to interact with your db to retrieve the lengths of the videos and then display them on in your view.