0.3.0 • Published 5 months ago

@mindedge/vuetify-player v0.3.0

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

Vuetify-Player

An accessible, localized, full featured media player with Vuetifyjs

Table of Contents


Supported File Types:

VideoAudioPoster Image
mp4mp3png
webmwavjpg
oggogggif (+ animated)
YouTube URL

Quick Start

1. Install

npm install @mindedge/vuetify-player

2. Import

import VuetifyPlayer from '@mindedge/vuetify-player'

3. Insert tag

<VuetifyPlayer :src="src" />

4. Define your src

src: {
	sources: [
	  {
	    src: "https://cdn.example.com/some-video.mp4",
	    type: "video/mp4",
	  },
	],
},

4. Enjoy~

Full media src structure

{
  name: "", // The video name. Used on playlists
  poster: "", // A video specific poster. Overrides poster attribute
  ads: [
    {
      play_at_percent: 0,
      sources: [
        {
          src: "https://domain.test/ad_example.mp4",
          type: "video/mp4",
        },
        // You can define additional fallback sources here
      ],
      tracks: [
        {
          src: "https://domain.test/ad_example_en-US.vtt",
          kind: "captions",
          srclang: "en-US",
          default: true,
        },
        // You can define additional language tracks here
      ],
    },
  ],
  sources: [
    {
      src: "https://domain.test/example.mp4",
      type: "video/mp4",
    },
    // You can define additional fallback sources here
  ],
  tracks: [
    {
      src: "https://domain.test/example_en-US.vtt",
      kind: "captions",
      srclang: "en-US",
      default: true,
    },
    // You can define additional language tracks here
  ],
}

The src attribute

The bare minimum,

src: {
  sources: [
    {
      src: "https://cdn3-d.mindedgeonline.com/videos/how-we-help-video.mp4",
      type: "video/mp4",
    },
  ],
}
<VuetifyPlayer :src="src" />

See Full media src structure

The playlist attribute

This accepts an array of media sources to play in a playlist format. Eg:

playlist: [
  { sources: [{ src: "first.mp4", type: "..."}], tracks: [...] },
  { name: "", sources: [{ src: "second.mp4", type: "..."}], tracks: [...] },
  { poster: "", sources: [{ src: "third.mp4", type: "..."}], tracks: [...] },
  // Additional media source objects
]
<VuetifyPlayer :playlist="playlist" />

When passing this attribute a playlist menu will appear and media will auto-advance from one source to the next on completion. Both of these can be adjusted with playlistmenu and playlistautoadvance. See Supported <VuetifyPlayer> Attributes for more information

For more informationm about media sources see Full media src structure

The ads array

The <VuetifyPlayer> supports video injection via the ads array. This can be used to inject any other media source at any time during playback.

For example:

  • For preroll set play_at_percent to 0
  • For midroll set play_at_percent to 50
  • For postroll set play_at_percent to 100

For multiple ads simply define multiple objects in the ads array.

ads: [
    {
        play_at_percent: 0,
        sources: [
            {
                src: 'https://domain.test/ad1_example.mp4',
                type: 'video/mp4',
            },
            // You can define additional fallback sources here
        ],
        tracks: [
            {
                src: 'https://domain.test/ad1_example_en-US.vtt',
                kind: 'captions',
                srclang: 'en-US',
                default: true,
            },
            // You can define additional language tracks here
        ],
    },
    // You add additional ad objects here
]

See Full media src structure for where the ads array is placed

Supported <VuetifyPlayer> Attributes

Attribute NameDatatypeAllowed ValuesDefaultDescription
languageStringen-US | See BCP 47 Spec"en-US"Defines which locale the video player controls will load in
srcObjectSee src attribute{}A single media source
playlistArraySee playlist attribute[]A collection of media source(s)
typeStringvideo | audio | image"video"In audio mode the player has a max-height of 40px
autoplayBooleantrue | falsefalseAutoplay on load. It's in the spec but DON'T USE THIS
autopictureinpictureBooleantrue | falsefalseStart with picture in picture mode
controlsBooleantrue | falsetrueShow video controls. When false only play/pause allowed but clicking on the video itself
controlslistStringnodownload nofullscreen noremoteplayback"nodownload noremoteplayback"Space separated string per . Allowed 'nodownload nofullscreen noremoteplayback'
crossoriginStringanonymous | use-credentials"anonymous"Indicates whether to use CORS to fetch the related video
disablepictureinpictureBooleantrue | falsetrueShows the picture in picture button
disableremoteplaybackBooleantrue | falsetrueShows the remote playback button but functionality does not exist when clicked
heightStringcss pixel value"auto"The players height
widthStringcss pixel value"100%"The players width
rewindBooleantrue | falsetrueEnabled the rewind 10s button
loopBooleantrue | falsefalseLoop the video on completion
mutedBooleantrue | falsefalseStart the video muted
playsinlineBooleantrue | falsefalseForce inline & disable fullscreen
posterStringimage url""Overridden with the playlist.poster if one is set there
preloadString"none" | "metadata" | "auto" | _empty string_""Empty string = auto Provide a hint to the browser about what the author thinks will lead to the best user experience with regards to what content is loaded before the video is played.
captionsmenuBooleantrue | falsetrueShow the captions below the video
playlistmenuBooleantrue | falsetrueShow the playlist menu if there's multiple videos
playlistautoadvanceBooleantrue | falsetruePlay the next source group
playbackratesArrayarray of numbers0.5, 1, 1.5, 2Default playback speeds. Anything below 0.25 and above 4 will make cause audio distortion

Supported <VuetifyPlayer> Events

Event nameReturnsWhen it's triggered
abortEventDownload interrupted
canplayEventPlayback can start
canplaythroughEventPlayback can continue and should not be interrupted. Readstate is 3
emptiedEventThe network connection is down
endedEventWhen playback has stopped because the end of the media was reached
errorEventA network error occurred during the download
loadeddataEventWhen the frame at the current playback position of the media has finished loading; often the first frame
loadedmetadataEventWhen the metadata has been loaded
playEventThe media has received a request to start playing
pauseEventPlayback has been suspended
progressEventThe progress event is fired periodically as the browser loads a resource.
seekingEventPlayback has moved to a new location
timeupdateObjectThe current time was changed. Object contains { event: Event, current_percent: Number }
ratechangeNumberThe playback speed multiplier
stalledEventThe browser tried to download but has not received data yet
volumechangeNumberThe volume or muted button changed. Value from 0.0 to 1
waitingEventPause playback to download more data
click:fullscreentrue | falseWhen the fullscreen button is clicked. true on fullscreen, false on exiting fullscreen
click:pictureinpicturetrue | falseWhen the picture-in-picture button is clicked. true on enabled, false on disabled
click:captions-expandtrue | falseWhen the expand captions button is clicked. true on expanded, false on collapsed
click:captions-paragraphtrue | falseWhen the view as paragraph button is clicked. true when viewing as a paragraph, false when viewing as timed captions
mouseoverMouseEventMouse over the media
mouseoutMouseEventMouse left the media

Captions

The player supports .vtt captions as defined in the tracks array explained above.

Additionally we support the tag <c.transcript> ... </c> inline with your captions text. This tag will omit the enclosed text from the video player captions overlay but show the text in the separate interactive captions panel. This allows you to include additional information that you want to appear in the transcript that might not be appropriate to display in the video player itself.

Below is a sample.vtt on how to use the <c.transcript> tag.

WEBVTT

00:00:00.000 --> 00:00:03.999
This text will show. <c.transcript>This text is hidden from the player.</c> This is some more text to show.
This text will show up on a new line in the player.

00:00:03.000 --> 00:00:5.999
sentence here to break it up

License

MIT License

Copyright 2022 MindEdge, Inc

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.