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

Vimeo video doesn't autoplay #1564

Open
bjarnef opened this issue Jan 20, 2025 · 1 comment
Open

Vimeo video doesn't autoplay #1564

bjarnef opened this issue Jan 20, 2025 · 1 comment
Labels
bug Something isn't working

Comments

@bjarnef
Copy link

bjarnef commented Jan 20, 2025

Current Behavior:

I have something similar to this to autoplay a Vimeo video.

<script lang="ts" setup>
...

const onProviderChange = (event: MediaProviderChangeEvent) => {
  const provider = event.detail;
  // We can configure provider's here.
  if (isHLSProvider(provider)) {
    provider.config = {};
  }
};

// We can listen for the `can-play` event to be notified when the player is ready, but not used at the moment
const onCanPlay = (event: MediaCanPlayEvent) => {
};

const src = computed(() => embed.value.src ?? '');
const autoplay = computed(() => settings.value.config?.autoplay ?? false);
const muted = computed(() => autoplay.value ?? settings.value.config?.muted ?? false);
</script>

<template>
<media-player
    class="player"
    :src="src"
    :autoplay="autoplay"
    :muted="muted"
    crossorigin
    playsinline
    @provider-change="onProviderChange"
    @can-play="onCanPlay">
    <media-provider>
      <media-poster
        class="vds-poster"
        alt="" />
    </media-provider>
    <!-- Layouts -->
    <media-audio-layout />
    <media-video-layout :translations="translations" />
  </media-player>
</template>

Previously it only showed the poster image, but after added muted property it now load the video, but it doesn't start playing the video.

Looking at the embed iframe it doesn't seem to include &autoplay=1&muted=1 in Vimeo request.

In console I get errors like these:

Image

Expected Behavior:

Steps To Reproduce:

Add player using Vimeo and autoplay.

Reproduction Link: How to create a repro?

Environment:

Anything Else?

@bjarnef bjarnef added the bug Something isn't working label Jan 20, 2025
@bjarnef
Copy link
Author

bjarnef commented Jan 20, 2025

I had a look at this: #1416

I workaround was to use this:

// We can listen for the `can-play` event to be notified when the player is ready, but not used at the moment
const onCanPlay = (event: MediaCanPlayEvent) => {
  // Workaround to start muted autoplay as e.g. Chrome doesn't allow autoplay with sound: https://developer.chrome.com/blog/autoplay/
  if (autoplay.value === true) {
    setTimeout(() => {
      $player.value!.muted = true;
    }, 0);
  }
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant