[Vuejs]-How to render variable stored DOM Nodes on VueJS?

0๐Ÿ‘

I believe you could use $refs, something like

<video ref="tokboxVideo" />

then

mounted() {
    this.$refs.tokboxVideo.srcObject = this.tokboxVideoElementCreated;
}

0๐Ÿ‘

You might have better success with the streamCreated event on the session. Create a Subscriber component like below:

<template>
  <div>
  </div>
</template>

<script>
import OT from '@opentok/client';
export default {
  name: 'subscriber',
  props: {
    stream: {
      type: OT.Stream,
      required: true
    },
    session: {
      type: OT.Session,
      required: true
    },
    opts: {
      type: Object,
      required: false
    }
  },
  mounted: function() {

    const subscriber = this.session.subscribe(
      this.stream,
      this.$el,
      this.opts,
      err => {
        if (err) {
          this.$emit('error', err);
        } else {
          this.$emit('subscriberConnected', subscriber);
        }
      }
    );
    this.$emit('subscriberCreated', subscriber);
  }
};
</script>

This will insert the video element inside the component. Then you can control how the component is displayed in your app.

Check out the basic vue sample in our repos.

Leave a comment