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

PlayerVars option "start" must be integer number #5

Open
suterma opened this issue Dec 30, 2023 · 3 comments
Open

PlayerVars option "start" must be integer number #5

suterma opened this issue Dec 30, 2023 · 3 comments
Assignees

Comments

@suterma
Copy link

suterma commented Dec 30, 2023

This is maybe more a documentation issue, because the limitation might be stemming from the underlying IFrame player.

When using the usePlayer constructor with the composition API, as documented here: https://vue-youtube.github.io/docs/usage/composable#configuration, the start value MUST be an integer (whole) number.

If fractions are used (e.g. value 500.1), the value is not applied and the video starts from the beginning.

The solution for this issue might be to document this limitation in the appropriate place, maybe with some simplified example code.

A working example:

const {
    onReady,
    onStateChange,
    onError,
    // togglePlay,
    // toggleMute,
    // toggleLoop,
    instance,
} = usePlayer(videoId, youtubePlayerElement, {
    /** See https://developers.google.com/youtube/player_parameters#Parameters */
    playerVars: {
        autoplay: 0,
        disablekb: 1 /* replayer handles keyboard events on it's own*/,
        enablejsapi: 1,
        color: 'white',
        controls: 1,
        // Setting the playlist to the one video enables looping the single video itself
        // See https://stackoverflow.com/a/25781957/79485
        playlist: videoId.value,
        start: 500, // startPosition, MUST be an integer number,
        rel: 0,
    },
    cookie: true,
});
@Techassi
Copy link
Member

Techassi commented Jan 2, 2024

The playerVars.start field is typed via TS as number. This is sadly a short-coming in TS/JS. It doesn't allow specifying which kind of number, like int or float.

I will move this issue to the https://github.com/vue-youtube/docs repo add will add more documentation for this.

@Techassi Techassi transferred this issue from vue-youtube/vue-youtube Jan 2, 2024
@Techassi Techassi self-assigned this Jan 2, 2024
@Techassi
Copy link
Member

Techassi commented Jan 4, 2024

I added a temporary note to the docs, see #8. Any feedback can be provided in the PR.

@Techassi
Copy link
Member

Techassi commented Jan 9, 2024

I merged the PR. I will keep this issue open to track the progress for the TS/JSDoc integration.

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

2 participants