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

feat: typed vue component #380

Merged
merged 1 commit into from
Oct 5, 2023

Conversation

miaulightouch
Copy link
Contributor

well-typed component for vue

for typescript usage, you need @types/ovenplayer@^0.10.8 installed.

usage:

<template>
  <OvenPlayer ref="player" :config="config" @state-changed="OnStateChanged" />
</template>

<script setup lang="ts">
import { ref } from 'vue';
import OvenPlayer from 'ovenplayer-vue3';
import type { OvenPlayerEvents, OvenPlayerConfig } from 'ovenplayer';

// OvenPlayer component instance
const ovenplayer = ref<InstanceType<typeof OvenPlayer>>();

// set config
const config = ref<OvenPlayerConfig>({
  autoStart: true,
  autoFallback: true,
  controls: false,
  disableSeekUI: true,
  mute: true
});

// state changed event handler
const OnStateChanged = (data: OvenPlayerEvents['stateChanged']) => {
  if (!ovenplayer.value?.playerInstance) return;
  if (!data.newstate) return;
  console.log('quality', ovenplayer.value.playerInstance.getQualityLevels());
};
</script>

well-typed component for vue

for typescript usage, you need `@types/ovenplayer@^0.10.8` installed.

usage:
```vue
<template>
  <OvenPlayer ref="player" :config="config" @state-changed="OnStateChanged" />
</template>

<script setup lang="ts">
import { ref } from 'vue';
import OvenPlayer from 'ovenplayer-vue3';
import type { OvenPlayerEvents, OvenPlayerConfig } from 'ovenplayer';

// OvenPlayer component instance
const ovenplayer = ref<InstanceType<typeof OvenPlayer>>();

// set config
const config = ref<OvenPlayerConfig>({
  autoStart: true,
  autoFallback: true,
  controls: false,
  disableSeekUI: true,
  mute: true
});

// state changed event handler
const OnStateChanged = (data: OvenPlayerEvents['stateChanged']) => {
  if (!ovenplayer.value?.playerInstance) return;
  if (!data.newstate) return;
  console.log('quality', ovenplayer.value.playerInstance.getQualityLevels());
};
</script>
```
@SangwonOh SangwonOh self-requested a review October 5, 2023 13:38
Copy link
Member

@SangwonOh SangwonOh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wonderful job! Many thanks to you 👍

@SangwonOh SangwonOh merged commit 1d86437 into AirenSoft:master Oct 5, 2023
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

Successfully merging this pull request may close these issues.

2 participants