kmoskwiak / videojs-resolution-switcher

Resolution switcher adds the ability to select the video quality in video.js player.
https://kmoskwiak.github.io/videojs-resolution-switcher/
Other
402 stars 244 forks source link

How to set default play 480p? #103

Open ghost opened 6 years ago

ghost commented 6 years ago

my code:

ghost commented 6 years ago

`

****`

willyelns commented 6 years ago

Just define it on options:


var player = videojs('player');

player.videoJsResolutionSwitcher({
  default: 480,
  dynamicLabel: true
});

player.updateSrc([{
    src: 'https://vjs.zencdn.net/v/oceans.mp4',
    type: 'video/mp4',
    label: '1080p',
    res: 1080
  },
  {
    src: 'https://vjs.zencdn.net/v/oceans.mp4',
    type: 'video/mp4',
    label: '720p',
    res: 720
  },
  {
    src: 'https://vjs.zencdn.net/v/oceans.mp4',
    type: 'video/mp4',
    label: '480p',
    res: 480
  }
]);
ghost commented 6 years ago

@willyelns Default resolution in using tags method。 Hi, how can I setup default resolution by using this method? ----For example I want to choose 720p as default resolution----

<video id="video" class="video-js vjs-default-skin" width="1000" controls data-setup='{}'>
   <source src="http://example.com/360p.mp4" type='video/mp4' label='360p' res='360' />
   <source src="http://example.com/480p.mp4" type='video/mp4' label='480p' res='480' />
   <source src="http://example.com/720p.mp4" type='video/mp4' label='720P' res='720' />
</video>
<script>
  videojs('video').videoJsResolutionSwitcher()
</script>
selimatmaca commented 5 years ago

You can change res value like below to change the sorting of the resolutions. This modification will not effect you labels and everything will look nicely nd 720p will be the default one. res='720' to res='1' res='480' to res='2' res='360' to res='3'