All Projects → kmoskwiak → Videojs Resolution Switcher

kmoskwiak / Videojs Resolution Switcher

Licence: other
Resolution switcher adds the ability to select the video quality in video.js player.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Videojs Resolution Switcher

Qier Player
🎬 A lightweight and sophisticated React-based H5 video player / 简单易用的h5播放器
Stars: ✭ 360 (-4%)
Mutual labels:  player, video-player
deplayer
Decentralized mediaplayer which runs entirely in the browser.
Stars: ✭ 14 (-96.27%)
Mutual labels:  player, video-player
react-native-vlc-media-player
React native media player for video streaming and playing. Supports RTSP, RTMP and other protocols supported by VLC player
Stars: ✭ 221 (-41.07%)
Mutual labels:  player, video-player
Dkvideoplayer
Android Video Player. 安卓视频播放器,封装MediaPlayer、ExoPlayer、IjkPlayer。模仿抖音并实现预加载,列表播放,悬浮播放,广告播放,弹幕
Stars: ✭ 3,796 (+912.27%)
Mutual labels:  player, video-player
X1Player
iOS端封装的视频播放器.支持直播,录播视频的播放,支持常用的播放界面控制,类似于ijkplayer 优点是体积更小,使用快捷
Stars: ✭ 21 (-94.4%)
Mutual labels:  player, video-player
shaka-player-react
A simple React component wrapper for shaka-player
Stars: ✭ 79 (-78.93%)
Mutual labels:  player, video-player
angular-youtube-player
Simple youtube player created with angular and typescript. See demo.
Stars: ✭ 35 (-90.67%)
Mutual labels:  player, video-player
files videoplayer
📼 Old video viewer for Nextcloud
Stars: ✭ 92 (-75.47%)
Mutual labels:  player, video-player
kaltura-player-js
Kaltura Player JS Platform - Cloud TV and OVP Media Players
Stars: ✭ 83 (-77.87%)
Mutual labels:  player, video-player
clappr-core
Core components of the Clappr player architecture
Stars: ✭ 41 (-89.07%)
Mutual labels:  player, video-player
Giraffeplayer2
out of the box android video player(support lazy load, ListView/RecyclerView and hight performance)
Stars: ✭ 344 (-8.27%)
Mutual labels:  player, video-player
Mobileplayer Ios
📱 🎥 A powerful and completely customizable media player for iOS
Stars: ✭ 2,931 (+681.6%)
Mutual labels:  player, video-player
aos-Video
NOVA opeN sOurce Video plAyer: player frontend main UI
Stars: ✭ 35 (-90.67%)
Mutual labels:  player, video-player
nplayer
🚀 支持移动端、支持 SSR、支持直播,可以接入任何流媒体。高性能的弹幕系统。高度可定制,所有图标、主题色等都可以替换,并且提供了内置组件方便二次开发。无第三方运行时依赖。
Stars: ✭ 897 (+139.2%)
Mutual labels:  player, video-player
api.video-player-sdk
SDK to control and interact with the api.video HTML5 Player
Stars: ✭ 31 (-91.73%)
Mutual labels:  player, video-player
danmaku-player
An HTML5 danmaku video player for real-time image processing using WebGl and Web Components.融合了webgl和web components的实时图像处理弹幕播放器
Stars: ✭ 40 (-89.33%)
Mutual labels:  player, video-player
Rtsp.player.android
RTSP player for Android / IP camera viewer
Stars: ✭ 199 (-46.93%)
Mutual labels:  player, video-player
Eplayer
🔮 A web-component html5 video player facing future
Stars: ✭ 253 (-32.53%)
Mutual labels:  player, video-player
niki
Media Player, DLNA, Music, Video and Streaming
Stars: ✭ 14 (-96.27%)
Mutual labels:  player, video-player
KingPlayer
🎬 一个专注于 Android 视频播放器的基础库,无缝切换内核。(IjkPlayer、ExoPlayer、VlcPlayer、MediaPlayer)
Stars: ✭ 35 (-90.67%)
Mutual labels:  player, video-player

Video.js Resolution Switcher Build Status

Resolution switcher for video.js v5

Example

Working examples of the plugin you can check out if you're having trouble. Or check out this demo.

Getting Started

Install plugin with

npm

npm i videojs-resolution-switcher

or bower

bower install videojs-resolution-switcher

Setup sources dynamically:

<video id='video' class="video-js vjs-default-skin"></video>
<script src="video.js"></script>
<script src="videojs-resolution-switcher.js"></script>
<script>
  videojs('video', {
    controls: true,
    plugins: {
        videoJsResolutionSwitcher: {
          default: 'high',
          dynamicLabel: true
        }
      }
  }, function(){
  
    // Add dynamically sources via updateSrc method
    player.updateSrc([
        {
          src: 'http://media.xiph.org/mango/tears_of_steel_1080p.webm',
          type: 'video/webm',
          label: '360'
        },
        {
          src: 'http://mirrorblender.top-ix.org/movies/sintel-1024-surround.mp4',
          type: 'video/mp4',
          label: '720'
        }
      ])

      player.on('resolutionchange', function(){
        console.info('Source changed to %s', player.src())
      })
      
  })
</script>

Or use <source> tags:

<video id="video" class="video-js vjs-default-skin" width="1000" controls data-setup='{}'>
   <source src="http://mirrorblender.top-ix.org/movies/sintel-1024-surround.mp4" type='video/mp4' label='SD' />
   <source src="http://media.xiph.org/mango/tears_of_steel_1080p.webm" type='video/webm' label='HD'/>
</video>
<script>
  videojs('video').videoJsResolutionSwitcher()
</script>

YouTube tech

YouTube tech form https://github.com/eXon/videojs-youtube

<video id='video' class="video-js vjs-default-skin"></video>
<script src="../lib/videojs-resolution-switcher.js"></script>
<script>
	videojs('video', {
		controls: true,
		techOrder:  ["youtube"],
		sources: [{ "type": "video/youtube", "src": "https://www.youtube.com/watch?v=iD_MyDbP_ZE"}],
		plugins: {
			videoJsResolutionSwitcher: {
				default: 'low',
				dynamicLabel: true
			}
		}
	}, function(){
		var player = this;
		player.on('resolutionchange', function(){
			console.info('Source changed')
		})
	});

</script>

Flash tech

When using flash tech preload="auto" is required.

Source options

Sources can passed to player using updateSrc method or <source> tag as shown above. Avalible options for each source are:

  • label - String (required) is shown in menu (ex. 'SD' or '360p')
  • res - Number is resolution of video used for sorting (ex. 360 or 1080)

Plugin options

You can pass options to plugin like this:

videojs('video', {
      controls: true,
      muted: true,
      width: 1000,
      plugins: {
        videoJsResolutionSwitcher: {
          default: 'low'
        }
      }
    }, function(){
      // this is player
    })

Avalible options:

  • default - {Number}|'low'|'high' - default resolution. If any Number is passed plugin will try to choose source based on res parameter. If low or high is passed, plugin will choose respectively worse or best resolution (if res parameter is specified). If res parameter is not specified plugin assumes that sources array is sorted from best to worse.
  • dynamicLabel - {Boolean} - if true current label will be displayed in control bar. By default gear icon is displayed.
  • customSourcePicker - {Function} - custom function for selecting source.
  • ui - {Boolean} - If set to false button will not be displayed in control bar. Default is true.

Methods

updateSrc([source])

Returns video.js player object if used as setter. If source is not passed it acts like player.src()

// Update video sources
player.updateSrc([
  { type: "video/mp4", src: "http://www.example.com/path/to/video.mp4", label: 'SD' },
  { type: "video/mp4", src: "http://www.example.com/path/to/video.mp4", label: 'HD' },
  { type: "video/mp4", src: "http://www.example.com/path/to/video.mp4", label: '4k' }
])

PARAMETERS:

name type required description
source array no array of sources

currentResolution([label], [customSourcePicker])

If used as getter returns current resolution object:

  {
    label: 'SD', // current label
    sources: [
      { type: "video/webm", src: "http://www.example.com/path/to/video.webm", label: 'SD' },
      { type: "video/mp4", src: "http://www.example.com/path/to/video.mp4", label: 'SD' }
    ] // array of sources with current label
  }

If used as setter returns video.js player object.

// Get current resolution
player.currentResolution(); // returns object {label '', sources: []}

// Set resolution
player.currentResolution('SD'); // returns videojs player object

PARAMETERS:

name type required description
label string no label name
customSourcePicker function no cutom function to choose source

customSourcePicker

If there is more than one source with the same label, player will choose source automatically. This behavior can be changed if customSourcePicker is passed.

customSourcePicker must return player object.

player.currentResolution('SD', function(_player, _sources, _label){
  return _player.src(_sources[0]); \\ Always select first source in array
});

customSourcePicker accepst 3 arguments.

name type required description
player Object yes videojs player object
sources Array no array of sources
label String no name of label

customSourcePicker may be passed in options when player is initialized:

var myCustomSrcPicker = function(_p, _s, _l){
  // select any source you want
  return _p.src(selectedSource);
}

videojs('video', {
      controls: true,
      muted: true,
      width: 1000,
      plugins: {
        videoJsResolutionSwitcher: {
          default: 'low',
          customSourcePicker: myCustomSrcPicker
        }
      }
    }, function(){
      // this is player
    })

getGroupedSrc()

Returns sources grouped by label, resolution and type.

Events

resolutionchange EVENT

Fired when resolution is changed

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].