Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typescript support #34

Open
spenweb opened this issue Jun 28, 2021 · 4 comments
Open

Typescript support #34

spenweb opened this issue Jun 28, 2021 · 4 comments

Comments

@spenweb
Copy link

spenweb commented Jun 28, 2021

Are there plans to have this package have Typescript support?

@mmcc
Copy link
Collaborator

mmcc commented Jun 28, 2021

That's a tough one. The bad news is that the Video.js types are pretty broken, so we'd need to fix those first before anything else. The good news is that that gets us a vast majority of the way to support here!

So yes, there are plans, but there's currently no timeline.

@spenweb
Copy link
Author

spenweb commented Jun 29, 2021

@mmcc I am assuming that video.js is Mux's preferred open source video player since there is this package created by Mux. Is this correct? I am starting a TypeScript project using Mux and would like to avoid untyped projects, but if this is Mux's preferred open source video player package, then I am willing to be more tolerant of adding my own manual types for now.

@james-mux
Copy link
Contributor

james-mux commented Jul 1, 2021

Hey @spenweb - thanks for the question!

Videojs-mux-kit is our preferred option, but a current shortcoming is the lack of TS support unfortunately. We're pretty agnostic when it comes to the player technology, anything which can play HLS is also fine by us.

Having said that, we find that hls.js generally works really well, which is why we made this project as we have the convenience of video.js combined with the playback power of hls.js. You could take a look at plyr.io which uses hls.js, and also has types available, as an alternative option?

@AdrianMrn
Copy link

@spenweb I managed to get some rudimentary TypeScript support by extending the videojs types to my needs. I don't yet extensively use this library or videojs, so I'll probably run into bits where I'll need some extra types.

// mux-videojs-kit.d.ts
declare module '@mux/videojs-kit' {
    interface VideoJsPlayerOptions extends videojs.VideoJsPlayerOptions {
        timelineHoverPreviews?: boolean;
        userActions?: videojs.VideoJsPlayerOptions['userActions'] & {
            fullscreenKey?: () => any;
            playPauseKey?: () => boolean;
        };
    }

    function videojs(
        id: string | Element,
        options?: VideoJsPlayerOptions,
        ready?: (this: videojs.VideoJsPlayer) => void
    ): videojs.VideoJsPlayer & { el_: HTMLVideoElement };

    export default videojs;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants