Giter Site home page Giter Site logo

Comments (8)

spencercap avatar spencercap commented on July 19, 2024 4

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.

redxtech avatar redxtech commented on July 19, 2024 1

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.

redxtech avatar redxtech commented on July 19, 2024

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.

LukasBombach avatar LukasBombach commented on July 19, 2024

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.

redxtech avatar redxtech commented on July 19, 2024

Sounds good.

from vue-plyr.

apuatcfbd avatar apuatcfbd commented on July 19, 2024

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.

redxtech avatar redxtech commented on July 19, 2024

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.

spencercap avatar spencercap commented on July 19, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.