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

It is possible to update the video with the new options? #78

Closed
lemonadia opened this issue Aug 31, 2021 · 2 comments
Closed

It is possible to update the video with the new options? #78

lemonadia opened this issue Aug 31, 2021 · 2 comments

Comments

@lemonadia
Copy link

I am working on custom vimeo player, and I need the functionality to make subtitles visible on custom button click.

Here is my code with the player included and I want to enable subtitles on enableFullScreen method.


<template>
  <div class="person-video">
    <div
      class="person-video__wrapper"
      :class="{ 'person-video__wrapper--full': fullScreenView }"
    >
      <div class="person-video__controls">
        <img
          src="~/assets/svg/play.svg"
          alt=""
          @click="playTheVideo"
          v-if="!stop"
        />
        <span @click="stopTheVideo" v-if="stop">STOP </span>
        <img
          src="~/assets/svg/subtitles.svg"
          alt=""
          @click="enableFullScreen"
        />
        <img src="~/assets/svg/sound.svg" alt="" @click="unMuteVideo" />
      </div>
      <client-only>
        <vimeo-player
          ref="player"
          :video-id="videoId"
          :options="options"
          @ready="onReady"
          :autoplay="true"
        />
      </client-only>
    </div>
  </div>
</template>

<script>
export default {
  name: "PersonVideo",
  props: {
    data: {
      type: Object,
      default: () => {},
      required: true,
    },
  },
  data() {
    return {
      stop: false,
      mute: false,
      height: 700,
      options: {
        controls: false,
        muted: true,
        texttrack: false,
      },
      playerReady: false,
      fullScreenView: false,
      language: "",
    };
  },
  computed: {
    videoId() {
      return this.data.vimeoLink.split("/")[3];
    },
  },
  methods: {
    onReady() {
      this.playerReady = true;
    },
    playTheVideo() {
      this.$refs.player.play();
      this.stop = true;
    },
    stopTheVideo() {
      this.$refs.player.pause();
      this.stop = false;
    },
    unMuteVideo() {
      this.$refs.player.unmute();
    },

    enableFullScreen(e) {
      if (process.client) {
        const videoWrapper = document.querySelector(".person-video__wrapper");
        this.fullScreenView = true;
        this.language =
          window.navigator.userLanguage || window.navigator.language;
        if (document.fullscreenElement) {
          if (document.exitFullscreen) {
            document.exitFullscreen();
            this.fullScreenView = false;
          }
        } else {
          if (videoWrapper.requestFullscreen) {
            videoWrapper.requestFullscreen();
            this.$refs.player.update();
          }
        }
      }
    },
  },
};
</script>

@lemonadia
Copy link
Author

Ok, I have manage to solve it!

@dobromir-hristov
Copy link
Owner

Please share your findings for future developers having your problems :)

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