upvote
Hey there, I'm on the Video.js team! Sounds like your context provider approach is already in the right ballpark!

Some background: our store[1] which was inspired by Zustand[2] is created and passed down via context too. This is the central state management piece of our library and where we imagine most devs will build on for extending and customizing to their needs.

Updates are handled via simple store actions like `store.play()`, `store.setVolume(10)`, etc. Those actions are generally called in response to DOM events.

On the events side of things, rather than registering event listeners directly, in v10 you'd subscribe to the store instead. Something like `store.subscribe(callback)`, or in React you'd use our `usePlayer`[3] hook. The store is the single source of truth, so rather than listening to the underlying media element directly, you're observing state changes.

---

So far with v10 we haven't been thinking about "plugins" in the traditional sense either. If I had to guess at what it would look like, it'd be three things:

1. Custom store slices[4] so plugins can extend the store with their own state and actions

2. A middleware layer that plugs into the store's action pipeline so a plugin could intercept or react to actions before or after they're applied, similiar to Zustand middleware, or even in some ways like Video.js v8 middleware[5]

3. UI components that plugins can ship which use our core primitives for accessing the store, subscribing to state, etc.

I believe that'd cover the vast majority of what plugins needed in v8. We haven't nailed down the exact API yet but that's the direction we're leaning towards. We're still actively working on both the library and our docs so I don't have somewhere I can link to for these just yet (sadly)! We're likely targeting sooner, but GA (end of June) is the deadline.

I should also add... one thing we prototyped early on that may return: tracking end-to-end requests through the store. A DOM event triggers a store action like play, which calls `video.play()`, which then waits for the media event response (play, error, etc.). It worked really well and lines up nicely with the middleware direction.

[1]: https://github.com/videojs/v10/tree/main/packages/store

[2]: https://github.com/pmndrs/zustand

[3]: https://videojs.org/docs/framework/react/reference/use-playe...

[4]: https://zustand.docs.pmnd.rs/learn/guides/slices-pattern#sli...

[5]: https://legacy.videojs.org/guides/middleware/

reply