2.2.0 • Published 2 days ago

@blendvision/player v2.2.0

Weekly downloads
-
License
-
Repository
-
Last release
2 days ago

BlendVision Player SDK

How to Install?

There are 2 methods to install BlendVision Player SDK as described below. You can install BlendVision Player SDK through npm:

npm install @blendvision/player

Alternatively, you can refer to an up‐to‐date version on our CDN:

<script src="https://unpkg.com/@blendvision/player"></script>

Polyfills

Note that this project includes no polyfills by default.

If you use any other ES6+ features that need runtime support (such as Array.at()), make sure you are including the appropriate polyfills manually, or that the browsers you are targeting already support them.

How to Create a Player?

Create an instance of this player class.

<!-- the element where you would like to display the player -->
<div id='my-player'></div>

<script src='https://unpkg.com/@blendvision/player' defer></script>
<script>
  var config = {
    title: 'Title',
    source: '...',
  }
  var Player = BlendVision.default
  var player = Player("my-player", config)
</script>

Source

An object or an array of objects contains {type, src}.

  • Type: type of manifests
  • Src: manifest URL of video
[
  {
    type: 'application/dash+xml',
    src: 'https://storage.googleapis.com/shaka-demo-assets/bbb-dark-truths/dash.mpd',
  },
  {
    type: 'application/x-mpegurl',
    src: 'https://storage.googleapis.com/shaka-demo-assets/bbb-dark-truths-hls/hls.m3u8',
  }
]

In iOS browsers and macOS Safari, the player chooses the first HLS manifest and plays with built-in player provided by Apple.

In other browsers, the player looks for the first DASH manifest and plays with MediaSource Extensions.

DRM

To play videos with content protection, you should specify license server URLs and options in drm:

[
  {
    type: 'application/dash+xml',
    src: 'https://storage.googleapis.com/shaka-demo-assets/bbb-dark-truths/dash.mpd',
    drm: {
      widevine: 'https://drm.ex.com/portal',
      playready: 'https://drm.ex.com/portal',
    }
  },
  {
    type: 'application/x-mpegurl',
    src: 'https://storage.googleapis.com/shaka-demo-assets/bbb-dark-truths-hls/hls.m3u8',
    drm: {
      fairplay: {
        licenseUri: 'https://drm.ex.com/portal',
        certificateUri: 'https://drm.ex.com/portal/certificate'
      }
    }
  }
]

Generally, the license server controls access.

The common authorization method is through the HTTP header: Authorization.

In this case, you need to specify headers.

[
  {
    type: 'application/dash+xml',
    src: 'https://storage.googleapis.com/shaka-demo-assets/bbb-dark-truths/dash.mpd',
    drm: {
      widevine: {
        licenseUri: 'https://drm.ex.com/portal',
        headers: {
          Authorization: `Bearer ${token}`
        }
      }
    }
  },
  {
    type: 'application/x-mpegurl',
    src: 'https://storage.googleapis.com/shaka-demo-assets/bbb-dark-truths-hls/hls.m3u8',
    drm: {
      fairplay: {
        licenseUri: 'https://drm.ex.com/portal',
        certificateUri: 'https://drm.ex.com/portal/certificate'
        headers: {
          Authorization: `Bearer ${token}`
        },
        certificateHeaders: {
         Authorization: `Bearer ${token2}`
        }
      }
    }
  }
]

Features & Definition

Play

This method plays a video.

player.play()

It returns a Promise:

// Playing may be not allowed if we violate the autoplicy policy
player.play().catch(error => {
  console.error(error)
})

The more infomation about autoplay policy is here.

Pause

This method pauses the playback of a video.

player.pause()

Current time

This method gets the current playback position of a video.

var current = player.currentTime()

Seek

This method sets the current playback position in seconds.

player.seek(50) // Set the current playback position to 50 seconds

Forward

This method seeks forward the current playback position in seconds.

player.forward() // Forward 10 seconds
player.forward(100) // Forward 100 seconds

Rewind

This method rewinds the current playback position in seconds.

player.rewind() // Rewind 10 seconds
player.rewind(100) // Rewind 100 seconds

getVolume

This method gets the volume level.

var current = player.getVolume() // `current` is the current volume

setVolume

This method sets the volume level of player on a scale from 0 to 1.

player.setVolume(0.5) // Set volume to 50%

Mute

This method mutes the player.

player.mute() // Mute the player

Unmute

This method unmutes the player.

player.unmute() // Unmute the player

getCurrentQuality

This method gets the current quality which player uses.

player.getCurrentQuality()

getQualities

This method gets the all qualities.

player.getQualities()

setQuality

This method sets the quality to player.

player.setQuality({maxHeight: 1080, minHeight: 1080}) // 1080p
player.setQuality({maxHeight: 360, minHeight: 360}) // 360p
player.setQuality(null) // auto

getSubtitles

This method gets all subtitle(s) of a video.

player.getSubtitles() // [{language: 'en'}, {language, 'ja'}]

getCurrentSubtitle

This method gets the current playback subtitle.

Return off if no any subtitle is active.

player.getCurrentSubtitle() // {language: 'en'} | 'off'

setSubtitle

This method sets the playback subtitle.

player.setSubtitle('en') // Open `en` subtitle
player.setSubtitle('off') // Close the subtitle

Release

This method removes the player.

player.release() // Release the player

Documentation

The complete API documentation is here.

If you want to integrate BlendVision One Platform quickly, you can refer to here.

2.15.0-canary.2

2 days ago

2.14.1-canary.1

11 days ago

2.14.1-canary.0

13 days ago

2.14.0

19 days ago

2.14.0-canary.10

20 days ago

2.14.0-canary.7

24 days ago

2.13.2

27 days ago

2.14.0-canary.3

27 days ago

2.14.0-canary.5

26 days ago

2.14.0-canary.4

27 days ago

2.14.0-canary.6

26 days ago

2.14.0-canary.0

1 month ago

2.13.1

1 month ago

2.13.1-canary.3

1 month ago

2.13.1-canary.1

2 months ago

2.13.1-canary.2

2 months ago

2.13.1-canary.0

2 months ago

2.13.0

2 months ago

2.13.0-canary.11

2 months ago

2.13.0-canary.10

2 months ago

2.13.0-canary.9

2 months ago

2.13.0-canary.8

2 months ago

2.13.0-canary.7

2 months ago

2.13.0-canary.6

2 months ago

2.13.0-canary.5

2 months ago

2.9.0-canary.60

2 months ago

2.13.0-canary.4

2 months ago

2.13.0-canary.3

3 months ago

2.13.0-canary.2

3 months ago

2.13.0-canary.1

3 months ago

2.13.0-canary.0

3 months ago

2.9.0-canary.59

3 months ago

2.9.0-canary.58

3 months ago

2.12.0

3 months ago

2.9.0-canary.57

3 months ago

2.11.0

4 months ago

2.9.0-canary.56

4 months ago

2.9.2

4 months ago

2.9.3

4 months ago

2.9.2-canary.2

4 months ago

2.11.0-canary.0

4 months ago

2.9.0-canary.55

4 months ago

2.9.0-canary.54

4 months ago

2.9.2-canary.1

4 months ago

2.9.0-canary.53

4 months ago

2.9.2-canary.0

4 months ago

2.9.0-canary.52

4 months ago

2.9.0-canary.51

4 months ago

2.9.0-canary.50

4 months ago

2.9.0-canary.49

4 months ago

2.9.0-canary.48

4 months ago

2.9.0-canary.47

4 months ago

2.9.0-canary.46

5 months ago

2.9.0-canary.45

5 months ago

2.9.0-canary.44

5 months ago

2.9.0-canary.41

5 months ago

2.9.0-canary.43

5 months ago

2.9.0-canary.42

5 months ago

2.9.0-canary.38

5 months ago

2.9.0-canary.37

5 months ago

2.9.0-canary.39

5 months ago

2.9.0-canary.40

5 months ago

2.10.0

5 months ago

2.9.0-canary.34

5 months ago

2.9.0-canary.35

5 months ago

2.10.0-canary.2

5 months ago

2.9.0-canary.33

5 months ago

2.9.0-canary.32

5 months ago

2.10.0-canary.1

5 months ago

2.9.0-canary.31

5 months ago

2.9.0-canary.30

5 months ago

2.9.0-canary.27

5 months ago

2.9.0-canary.26

5 months ago

2.9.0-canary.29

5 months ago

2.9.0-canary.28

5 months ago

2.9.0-canary.25

5 months ago

2.9.0-canary.24

5 months ago

2.10.0-canary.0

5 months ago

2.9.0-canary.23

5 months ago

2.9.1

5 months ago

2.9.1-canary.0

5 months ago

2.9.1-canary.1

5 months ago

2.9.1-canary.2

5 months ago

2.9.1-canary.3

5 months ago

2.9.0-canary.22

5 months ago

2.9.0-canary.21

5 months ago

2.4.0-canary.9

10 months ago

2.4.0-canary.7

10 months ago

2.4.0-canary.8

10 months ago

2.4.0-canary.6

10 months ago

2.5.0-canary.0

10 months ago

2.5.0-canary.1

9 months ago

2.5.0-canary.2

9 months ago

2.7.0-alpha.0

8 months ago

2.5.0-canary.3

9 months ago

2.4.1

10 months ago

2.4.0

10 months ago

2.6.1

8 months ago

2.5.0-canary.4

9 months ago

2.6.0

8 months ago

2.8.1

6 months ago

2.6.3

7 months ago

2.8.0

7 months ago

2.6.2

8 months ago

2.7.0-test.0

8 months ago

2.7.0-canary.1

8 months ago

2.9.0-canary.20

6 months ago

2.7.0-canary.0

8 months ago

2.8.1-canary.2

6 months ago

2.8.1-canary.3

6 months ago

2.7.0-canary.2

7 months ago

2.8.1-canary.0

7 months ago

2.8.1-canary.1

6 months ago

2.8.1-hotfix.0

6 months ago

2.9.0-canary.16

6 months ago

2.9.0-canary.18

6 months ago

2.9.0-canary.17

6 months ago

2.9.0-canary.12

7 months ago

2.9.0-canary.11

7 months ago

2.9.0-canary.14

6 months ago

2.9.0-canary.13

6 months ago

2.9.0-canary.10

7 months ago

2.5.0

9 months ago

2.7.0

7 months ago

2.5.2

8 months ago

2.5.1

9 months ago

2.9.0

6 months ago

2.5.3

8 months ago

2.8.0-canary.0

7 months ago

2.8.0-canary.1

7 months ago

2.9.0-canary.19

6 months ago

2.4.0-canary.10

10 months ago

2.6.0-canary.8

8 months ago

2.6.0-canary.7

8 months ago

2.6.0-canary.6

8 months ago

2.8.0-alpha.3

7 months ago

2.6.0-canary.5

8 months ago

2.8.0-alpha.2

7 months ago

2.8.0-alpha.1

7 months ago

2.8.0-alpha.0

7 months ago

2.6.0-canary.9

8 months ago

2.8.3

6 months ago

2.8.2

6 months ago

2.9.0-canary.8

7 months ago

2.9.0-canary.9

7 months ago

2.9.0-canary.6

7 months ago

2.9.0-canary.7

7 months ago

2.9.0-canary.4

7 months ago

2.9.0-canary.5

7 months ago

2.9.0-canary.2

7 months ago

2.9.0-canary.3

7 months ago

2.9.0-canary.0

7 months ago

2.9.0-canary.1

7 months ago

2.6.0-canary.0

9 months ago

2.6.0-canary.4

8 months ago

2.6.0-canary.3

9 months ago

2.6.0-canary.2

9 months ago

2.6.0-canary.1

9 months ago

2.4.0-canary.5

11 months ago

2.4.0-canary.3

11 months ago

2.4.0-canary.4

11 months ago

2.3.1-canary.5

11 months ago

2.3.1-canary.3

11 months ago

2.3.1-canary.4

11 months ago

2.3.1

11 months ago

2.4.0-canary.2

11 months ago

2.3.1-canary.1

12 months ago

2.3.0

12 months ago

2.3.1-canary.2

12 months ago

2.3.1-canary.0

12 months ago

2.4.0-canary.1

11 months ago

2.3.0-canary.2

12 months ago

2.4.0-canary.0

11 months ago

2.3.0-beta.0

1 year ago

2.2.0

1 year ago

2.1.0

1 year ago