Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@byteark/byteark-player-vue

Package Overview
Dependencies
Maintainers
4
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@byteark/byteark-player-vue

ByteArk Player Container for Vue.js

  • 1.0.0-beta16
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
26
decreased by-87.13%
Maintainers
4
Weekly downloads
 
Created
Source

ByteArk Player Container for Vue.js

NPM JavaScript Style Guide

Table of Contents

Demo

You can try on the demo page.

Features

  • Remote player updates. No need to update your code for minor improvements.
  • Show placeholder while waiting the player to be ready.
  • Controls basic behaviours via props.
  • Custom advanced callbacks to access ByteArk Player/VideoJS instance directly.

Installation

This library is distributed via NPM. You may install from NPM or Yarn.

# For NPM
npm install --save @byteark/byteark-player-vue
# For Yarn
yarn add @byteark/byteark-player-vue

Usage

Include and register ByteArkPlayerContainer in your project.

<template>
  <ByteArkPlayerContainer
    :options="playerOptions" />
</template>

<script>
import ByteArkPlayerContainer from '@byteark/byteark-player-vue';

export default {
  components: {
    ByteArkPlayerContainer,
  },
  data() {
    return {
      playerOptions: {
        autoplay: true,
        fluid: true,
        aspectRatio: '16:9',
        poster: 'https://qoder.byteark.com/images/video-frames/1/GU/cg/1GUcgd3XwsmD-large.jpg',
        sources: {
          src: 'https://video.example.com/path/to/video/playlist.m3u8',
          type: 'application/x-mpegURL',
          // Optional
          title: 'Video Title',
          videoId: 'RI2PimuHxDXw',
          poster: 'https://qoder.byteark.com/images/video-frames/1/GU/cg/1GUcgd3XwsmD-large.jpg',
        },
      },
    };
  },
};
</script>

Include stylesheet in your project

// Inside your main SCSS file
@import '~@byteark/byteark-player-vue/dist/@byteark/byteark-player-vue.css';

// Or inside the component
<style lang="scss" scoped>
@import '~@byteark/byteark-player-vue/dist/@byteark/byteark-player-vue.css';
</style>

Use fill mode if you want the video to be displayed on a fixed-size container.

<template>
  <ByteArkPlayerContainer
    :options="playerOptions" />
</template>

<script>
import ByteArkPlayerContainer from '@byteark/byteark-player-vue';

export default {
  components: {
    ByteArkPlayerContainer,
  },
  data() {
    return {
      playerOptions: {
        autoplay: true,
        fill: true,
        aspectRatio: '16:9',
        poster: 'https://qoder.byteark.com/images/video-frames/1/GU/cg/1GUcgd3XwsmD-large.jpg',
        sources: {
          src: 'https://video.example.com/path/to/video/playlist.m3u8',
          type: 'application/x-mpegURL',
          // Optional
          title: 'Video Title',
          videoId: 'RI2PimuHxDXw',
          poster: 'https://qoder.byteark.com/images/video-frames/1/GU/cg/1GUcgd3XwsmD-large.jpg',
        },
      },
    };
  },
};
</script>

Options prop

You have to pass options into ByteArkPlayerContainer

Additional properties will be passed to the player.

NameTypeDefaultDescription
autoplayBooleantrueAutoplay the video after the player is created.
aspectRatioString'16:9'Use with fluid layout mode, to inform expected video's aspect ratio
controlsBooleantrueShow the controls bar.
customClassString-Custom class name to be applied to the video container.
fillBooleanfalseUse fill layout mode.
fluidBooleantrueUse fluid layout mode.
loopBoolean-Replay the video after ending
mutedBoolean-Play the video without sounds.
playbackRateNumber1.0Playback speed. 1.0 means original speed.
playsinlineBooleantrueShould be true so custom controls available on all platforms, including iOS.
posterString-Image to show before playing the video.
preloadString-Preload the video before playing. (none / metadata / auto)
responsiveBoolean-Auto show/hide controls depending on the screen size.
sourcesObject/Array-Source of videos (See Source Object)
volumeNumber-Video's volume between 0 and 1.

The following 4 properties can also be added to options for an advanced usage.

NameTypeDescription
playerVersionStringCustom version of the player. (default: 'v1')
playerEndpointStringEndpoint to the video player (without version part and ending slash).
playerJsFileNameStringFile name of player's JS. (default: 'byteark-player.min.js')
playerCssFileNameStringFile name of player's CSS. (default: 'byteark-player.min.css')

You can also use other props not listed here, but appear as VideoJS's options. However, changing props will not effective after the player is created.

Source Object

The sources object has 2 required fields.

NameTypeRequiredDescription
srcStringtrueURL to the video.
typeStringtrueVideo content type.
titleStringfalseVideo title to display on the player.
videoIdStringfalseVideo's ID, usually used by analytical applications.
posterStringfalseImage to show before playing the video.

To provide multiple version of sources, you can use array of source objects.

Callback Props

You can inject some behaviour directly to the ByteArk Player, and the VideoJS's instance.

NameTypeCallback ParametersDescription
onPlayerCreatedFunction(player)Callback function to be called when a player instance is created.
onPlayerLoadingErrorFunction({ code, message })Callback function to be called when there're an error about loading player.
onReadyFunction(player)Callback function to be called when a player instance is ready.

Advanced Props

We also provide some ways to custom the appearance of the video placeholder, and some advanced behaviours.

NameTypeDescription
createPlayerFunctionFunctionCustom video instance. This function should return a VideoJS's player instance.

Advance Usages

Controlling Players

You may access the player directly via getPlayer() method, or using the player instance that sent from onReady callback.

<template>
  <ByteArkPlayerContainer
    :onReady="onReady"
    :options="playerOptions" />
  <button @click.stop="playerInstance.play()">Play</button>
  <button @click.stop="playerInstance.pause()">Pause</button>
</template>

<script>
import ByteArkPlayerContainer from '@byteark/byteark-player-vue';

export default {
  components: {
    ByteArkPlayerContainer,
  },
  data() {
    return {
      playerInstance: null,
      playerOptions: {
        autoplay: true,
        fluid: true,
        sources: {
          src: 'https://video.example.com/path/to/video/playlist.m3u8',
          type: 'application/x-mpegURL',
          // Optional
          title: 'Video Title'
        },
      },
    };
  },
  methods: {
    onReady(newPlayerInstance) {
      this.playerInstance = newPlayerInstance;
    },
  },
};
</script>

Using VideoJS Plugins

<template>
  <ByteArkPlayerContainer
    :onReady="onReady"
    :options="playerOptions" />
</template>

<script>
import ByteArkPlayerContainer from '@byteark/byteark-player-vue';

export default {
  components: {
    ByteArkPlayerContainer,
  },
  data() {
    return {
      playerInstance: null,
      playerOptions: {
        autoplay: true,
        fluid: true,
        sources: {
          src: 'https://video.example.com/path/to/video/playlist.m3u8',
          type: 'application/x-mpegURL',
          // Optional
          title: 'Video Title'
        },
      },
    };
  },
  methods: {
    onReady(newPlayerInstance) {
      // The player is ready! Initialize plugins here.
    },
  },
};
</script>

Request Media/Encryption with credentials

<template>
  <ByteArkPlayerContainer
    :onReady="onReady"
    :options="playerOptions" />
</template>

<script>
import ByteArkPlayerContainer from '@byteark/byteark-player-vue';

export default {
  components: {
    ByteArkPlayerContainer,
  },
  data() {
    return {
      playerInstance: null,
      playerOptions: {
        autoplay: true,
        fluid: true,
        sources: {
          src: 'https://video.example.com/path/to/video/playlist.m3u8',
          type: 'application/x-mpegURL',
          // Optional
          title: 'Video Title',
        },
        html5: {
          hlsjs: {
            xhrSetup: function(xhr, url) {
              xhr.withCredentials = true;
            },
          },
        },
      },
    };
  },
  methods: {
    onReady(newPlayerInstance) {
      // The player is ready! Initialize plugins here.
    },
  },
};
</script>

License

MIT © ByteArk Co. Ltd.

FAQs

Package last updated on 25 Aug 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc