Comments (8)
something like this in vue 3 SFC:
VuePlyr.vue
:
<script lang="ts">
import { defineComponent, PropType } from 'vue';
import Plyr from 'plyr';
import 'plyr/dist/plyr.css';
export default defineComponent({
name: 'VuePlyr',
props: {
/** Options object for plyr config. **/
options: {
type: Object as PropType<Plyr.Options>,
required: false
}
},
data() {
return {
player: {} as Plyr
};
},
computed: {
opts(): any {
const options = this.options;
if (
options &&
!Object.prototype.hasOwnProperty.call(
this.options,
'hideYouTubeDOMError'
)
) {
(options as any).hideYouTubeDOMError = true;
}
return options;
}
},
mounted() {
this.player = new Plyr(this.$el, this.opts);
},
beforeUnmount() {
try {
this.player.destroy();
} catch (e) {
if (
!(
this.opts.hideYouTubeDOMError &&
e.message === 'The YouTube player is not attached to the DOM.'
)
) {
// eslint-disable-next-line no-console
console.error(e);
}
}
},
render() {
const slots = this.$slots.default;
return typeof slots === 'function' ? slots()[0] : slots;
}
});
</script>
from vue-plyr.
I'm going to close this for now. Feel free to re open it again if you want, but the best way to get this implemented would be to just make a PR to add the support and either explain in code comments what you're doing or explain in the PR description with what the code added does. If it works and you don't throw in any weird stuff that I don't understand (if this happens I'll just ask you about it) then I will have no problem merging a PR to add TS support.
from vue-plyr.
I have never used typescript. What would I have to do to make this a possibility?
If you want to make a PR just explain what you're doing so that I can maintain it in the future and I will accept it.
from vue-plyr.
Fair enough. I was gonna do a PR but I abandoned my project now, I don't know if I'll pick it up again. If so, I'll just open a PR.
from vue-plyr.
Sounds good.
from vue-plyr.
something like this in vue 3 SFC:
VuePlyr.vue
:<script lang="ts"> import { defineComponent, PropType } from 'vue'; import Plyr from 'plyr'; import 'plyr/dist/plyr.css'; export default defineComponent({ name: 'VuePlyr', props: { /** Options object for plyr config. **/ options: { type: Object as PropType<Plyr.Options>, required: false } }, data() { return { player: {} as Plyr }; }, computed: { opts(): any { const options = this.options; if ( options && !Object.prototype.hasOwnProperty.call( this.options, 'hideYouTubeDOMError' ) ) { (options as any).hideYouTubeDOMError = true; } return options; } }, mounted() { this.player = new Plyr(this.$el, this.opts); }, beforeUnmount() { try { this.player.destroy(); } catch (e) { if ( !( this.opts.hideYouTubeDOMError && e.message === 'The YouTube player is not attached to the DOM.' ) ) { // eslint-disable-next-line no-console console.error(e); } } }, render() { const slots = this.$slots.default; return typeof slots === 'function' ? slots()[0] : slots; } }); </script>
Can you please explain what's going on in render fn?
How to convert this to <script setup
?
from vue-plyr.
I actually have something in the works for this right no, not sure how long it will take though since I am employed full time. I'll look into it soon though.
from vue-plyr.
@apuatcfbd sorry, i'm also too busy at the moment to convert this component. but you can mix and match different types of vue components in one webapp btw.
from vue-plyr.
Related Issues (20)
- Help me
- 'npm install vue-plyr' error? HOT 3
- sampotts/plyr.git develop Permission denied HOT 3
- Not working with HLS mp4s
- Add subtitles to a Youtube iframe
- default controls shown in the demo page its not coming
- Vue Plyr 7.0.0 causes npm ci in Docker fail with error 401 HOT 3
- Any maintenance status update for this (lovely) package? HOT 3
- Installation of dependency sampotts/plyr extremely slow
- Quality settings closes
- Cannot change vimeo source dynamically - error: Unknown player. Probably unloaded
- reload componentn when language changed
- `v-if` not working with plyr.
- Controls disappears in full screen HOT 1
- Fails to compile if importing css as in the example
- How can I use it Nuxt3 app HOT 3
- Customizing player
- Nuxt 3 SSR HOT 2
- Cannot load videos using Hls.js on Vite
- Vue3 update starting time
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vue-plyr.