Giter Site home page Giter Site logo

Support for hls,like m3u8? about vue-plyr HOT 7 CLOSED

redxtech avatar redxtech commented on July 19, 2024 1
Support for hls,like m3u8?

from vue-plyr.

Comments (7)

mostafaznv avatar mostafaznv commented on July 19, 2024 7

just install hls and use this workaround.

<template>
    <vue-plyr ref="plyr" :options="playerOptions">
        <video :poster="post.media.cover" :id="'video-' + post.id" data-plyr-config="{'autoplay': false}">
        </video>
    </vue-plyr>
</template>

<script>
import VuePlyr from 'vue-plyr';
import Hls from 'hls.js';

export default {
    name: 'ComponentName',
    components: {
        VuePlyr
    },
    data() {
        return {
            playerOptions: {
                controls: ['play-large', 'play', 'progress', 'current-time', 'mute', 'volume', 'settings', 'fullscreen'],
                settings: ['quality', 'speed', 'loop'],
            }
        }
    },
    computed: {
        player() {
            console.log(this.$refs.plyr.player);
            return this.$refs.plyr.player;
        },
    },
    mounted() {
        if (Hls.isSupported()) {
            const hls = new Hls();
            hls.loadSource('https://domain.com/path/to/stream.m3u8');
            hls.attachMedia(this.player.media);

            window.hls = hls;
        }
    },
    
}
</script>

from vue-plyr.

simonhrogers avatar simonhrogers commented on July 19, 2024 1

@mostafaznv this is a lifesaver, thank you! I’m getting a slight issue at the moment – the first time I visit a page with this component, it seems to render the two elements separately – the plyr elements end up in an ugly mess above, and the full video below.

After that it always works fine – or works fine if I refresh the page. Have you experienced the same?

EDIT: this problem occurs if I load a route which DOES NOT have hls / plyr imported – and then navigate to one which does.

from vue-plyr.

simonhrogers avatar simonhrogers commented on July 19, 2024 1

Hi @mostafaznv – thanks so much for your response!
I’m an idiot and was really struggling to get a live demo together with codesandbox (I gave up).

I have found a workaround, and thanks to your pointer above figured out one possible issue with what I was doing. Describing here incase useful for others:

firstly, previously I was importing the SSR–friendly version of vue-plyr like described in the docs:
import VuePlyr from 'vue-plyr/dist/vue-plyr.ssr.js'

this was being rendered on the server ahead of hjs being available.

If instead I add the instruction to transpile it in my nuxt.config.js file’s build section, and render the relevant component only on the client-side, we avoid such issues! Is this cheating?

    transpile: [
      'vue-plyr'
    ],
    <client-only>
      <ProjectVideo v-if="project.fullVideo" :video="project.fullVideo" />
    </client-only>

In case you are interested, a development version of the app is here!

https://onlysecondsaway.ubikproductions.com/

from vue-plyr.

redxtech avatar redxtech commented on July 19, 2024

This is already supported. Simply add the source as you would with a normal html5 video player (or however you would do it with plyr) and then wrap it with the plyr element.

from vue-plyr.

russ avatar russ commented on July 19, 2024

@snowdream Did you ever get this working?

from vue-plyr.

opnchaudhary avatar opnchaudhary commented on July 19, 2024

Anyone who got this working?

from vue-plyr.

mostafaznv avatar mostafaznv commented on July 19, 2024

@mostafaznv this is a lifesaver, thank you! I’m getting a slight issue at the moment – the first time I visit a page with this component, it seems to render the two elements separately – the plyr elements end up in an ugly mess above, and the full video below.

After that it always works fine – or works fine if I refresh the page. Have you experienced the same?

You're welcome @simonhrogers
No, I didn't see this before.
Just check hls and plyr with a console.log
I think you have a problem with initiating things.

If you have any live demo and code, I can check it.

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.