Code Monkey home page Code Monkey logo

Comments (5)

dmlap avatar dmlap commented on July 22, 2024

Currently, selectPlaylist() is called every time a chunk finishes downloading. The size of the chunk is not exposed but it is possible to determine the amount of time it took to download it and the estimated bitrate of the network connection based on the download time. What are you thinking of doing with the chunk size and timing info?

from videojs-contrib-hls.

ryan-clancy avatar ryan-clancy commented on July 22, 2024

@dmlap Thanks.

I require the start and end of the download time of each chunk to calculate metrics based on the video playback.

How is it that I could determine the start time of the download? Also, is it possible to listen for the start and end of the download, or would I have to fork the project and add my own code into the selectPlaylist() function?

from videojs-contrib-hls.

dmlap avatar dmlap commented on July 22, 2024

The total download time is exposed as player.hls.segmentXhrTime after each chunk is downloaded. I'll update the README so that's clearer. If you need an absolute start time for the download, you should be able to subtract that value from Date.now() to get it.

selectPlaylist() is a public part of the API so you don't need to fork the repo to modify it. I would save a reference to the default implementation and override it with a function that calculates your metrics and then delegates back to the original. Patching over selectPlaylist() does seem a little weird for what you're trying to achieve and we may end up adding a first-class event for segment downloads if this turns out to be common. The override solution would still work if we end up going that direction, though.

from videojs-contrib-hls.

ryan-clancy avatar ryan-clancy commented on July 22, 2024

Thank you for the information, that should be what I need.

I'm assuming the loadedmetadata event has information associated with it such as the target duration of the chunks?

from videojs-contrib-hls.

dmlap avatar dmlap commented on July 22, 2024

Glad to hear that worked!

The loadedmetadata event itself doesn't carry much information but you can look on the HLS tech when it fires to see how the playlist was parsed. The media() method on the playlists object always contains the most up-to-date info on the active playlist, including the target and segment durations.

from videojs-contrib-hls.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.