Skip to content

Video Destroy with Vue #129

@packytagliaferro

Description

@packytagliaferro

I have been reading the docs and still confused on how to destroy the video. Right now if I go to a detail page and navigate back I can still hear the video playing. Here is what I have that doesnt work (causes crash)

In main.js

Vue.registerElement('VideoPlayer', () => require('nativescript-videoplayer').Video)

In my VideoDetail.vue page:

<template>

    <Page backgroundColor="#242C3B" >
    
        <ActionBar>
            <StackLayout class="actionbar">
                <Label :text="title" class="actionbar-title"/>
                <Label :text="date"  class="actionbar-date"/>
            </StackLayout>
        </ActionBar>

        <StackLayout  v-if="video">

                <VideoPlayer
                    :src="video"
                    autoplay="true"
                    height="300"
                    loop="false"
                    muted="false"
                    ref="lessonVideo"
                    >
                </VideoPlayer>

     </StackLayout>
  
    </Page>

</template>

<script>

    export default {

        data() {
            return {
                video: 'https://myvideolink.mp4'
            }
        }
        
        beforeDestroy(){

            this.$refs.lessonVideo.destroy();

        }
        

    }
</script>



Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions