muxinc / videojs-mux-kit

MIT License
33 stars 11 forks source link

Setting the thumbnail does not update the poster #91

Closed michaelburtonray closed 2 years ago

michaelburtonray commented 2 years ago

When I update the thumbnail image in Sanity backend, the poster is not updated to reflect it. It just shows the center timestamp.

I'm using Vue:

<template>
      <video
        :id="`player_${id}`"
        class="video-js vjs-16-9"
        controls
        preload="auto"
        playsinline
        width="100%"
        :poster="`https://image.mux.com/${video.asset.playbackId}/thumbnail.jpg`"
        ref="videoToObserve"
      >
      </video>
</template>

export default {
  methods: {
    initPlayer() {
      this.player = videojs(`player_${this.id}`, {
        timelineHoverPreviews: true,
        plugins: {
          mux: {
            debug: false,
            data: {
              env_key: 'ENV_KEY',
              video_title: this.title,
            },
          },
        },
      })

      this.player.src({
        // this is the public playback ID without the 'https://stream.mux.com/' prefix
        src: this.video.asset.playbackId,
        type: 'video/mux',
      })
    },
  }
}
mmcc commented 2 years ago

Hi there, the Sanity backend is just saving the timestamp for the poster, but you still need to include that in the URL for the poster image. For example:

:poster="`https://image.mux.com/${video.asset.playbackId}/thumbnail.jpg?time=${video.asset.thumbTime}`"

Hope that helps!

michaelburtonray commented 2 years ago

Thank you so much! Worked like a charm.