sanity-io / sanity-mux-player

Play videos in the frontend uploaded with the MUX Sanity plugin
https://github.com/sanity-io/sanity-plugin-mux-input
21 stars 5 forks source link

Property passing. Merged click handler. Poster management. Children option. #4

Closed tomsseisums closed 5 years ago

tomsseisums commented 5 years ago

Property passing Basically, with this, one can pass arbitrary props down to <video>, including event handlers.

Merged click handler Also merged onClick handler with default behaviour, though, I wonder if we should provide for a way to go around default altogether?

Poster management

Children option Could provide useful to implement, for instance, custom controls, though, as of writing this, it could have been brought up the tree... matter of preference, I guess. But I'm starting to shift more towards it being an overkill here, the component becomes too knowledgable. But hey, it's a PR for a reason!

Fixes #3.

Sorry for so much changes in one PR, didn't want to juggle around, testing locally is a little painful for now.

skogsmaskin commented 5 years ago

Thank you @joltmode, just one issue as reviewed.

tomsseisums commented 5 years ago

I reworked the prop filtering to use omit utility instead.

Improves code readability and predictabilty by a lot. Also cleans up scope of unused variables.

Now there is an open question, do we use the lodash one (simple way) or write a smaller footprint custom one?

skogsmaskin commented 5 years ago

Hmm.. I'm not sure about the mixing of props here. Could it be a better idea to have a prop videoProps which is exactly that, props for the video element? Then all other props are for the SanityMuxPlayer API and clearly defined via PropTypes.

tomsseisums commented 5 years ago

Thought of that option also.

Yes, could go with it.

I didn't go with it initially, because I kind of disliked the idea that most of the props you can pass to SanityMuxPlayer are actually the ones you'd pass to video (assetDocument being the sole exception?), therefore the extra prop to pass props of same family to the same component doesn't mesh well. Basically, I am not a fan of the public API in videoProps scenario.

On Sat, Dec 8, 2018, 20:15 Per-Kristian Nordnes <notifications@github.com wrote:

Hmm.. I'm not sure about the mixing of props here. Could it be a better idea to have a prop videoProps which is exactly that, props for the video element? Then all other props are for the SanityMuxPlayer and clearly defined via PropTypes.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/sanity-io/sanity-mux-player/pull/4#issuecomment-445478818, or mute the thread https://github.com/notifications/unsubscribe-auth/AA-3wHXio7hbC0a3IvVSQeOe0lOpYMxNks5u3AGsgaJpZM4ZJRSJ .

tomsseisums commented 5 years ago

@skogsmaskin so - extra prop videoProps or keep it the current way? Your call, chief! 😄

skogsmaskin commented 5 years ago

@joltmode, I've begun refactoring what first begun as abstracting and move the error handling outside the player. That kind of escalated a bit, and I've begun working on a custom control interface as well that should be easy to style.

The way I see it, there should be two "modes" to use this module. One mode being just plug and play where you get error handling and some easy way to style the player to fit your webpage (drop in video player). The other mode would be to just facilitate the loading of the video (src, poster and any future Sanity-specific stuff). In this mode the developer should be able to take total control of how to present and play the video.

Here is a suggestion for relevant props, to see if they can facilitate this:

Player spesific

Video spesific

What do you think?

skogsmaskin commented 5 years ago

OK! After discussing on Slack, let's release this for now allowing for some more control in the current API, and aim for a version 0.1.0 soon, which will have a new and much better API.

skogsmaskin commented 5 years ago

Thanks @joltmode! Released as sanity-mux-player@0.0.26