VideoJS Resolution Switcher reports “this.updateSrc is not a function”
Clash Royale CLAN TAG#URR8PPP
VideoJS Resolution Switcher reports “this.updateSrc is not a function”
I am randomly facing this error. Sometimes video loads fine but mostly it shows "updateSrc is not a function". Video usually loads on page refresh. I have tried everything but couldn't fix this.
HTML
<video id="<?php echo $id; ?>" class="video-js vjs-16-9 vjs-big-play-centered" controls preload="auto" width="100%" height="100%" poster="<?php echo (isset($mPoster))?$mPoster:'';?>" data-setup="">
<p class="vjs-no-js">
To view this video please enable JavaScript, and consider upgrading to a web browser that
<a href="http://videojs.com/html5-video-support/" target="_blank">supports HTML5 video</a>
</p>
</video>
JavaScript
var videoplayer = videojs('<?php echo $id; ?>',
plugins:
videoJsResolutionSwitcher:
default: 480,
dynamicLabel: true
, function()
this.updateSrc(<?php echo (isset($code))?$code:'';?>)
this.preload(false)
this.on('resolutionchange', function()
console.info('Source changed to %s', this.src())
)
this.autoplay(true)
);
Error
2 Answers
2
Found a fix by dynamically generating the video tag.
Here is the code:
var videotaghtml= "<video id='<?php echo $id; ?>' class='video-js vjs-16-9 vjs-big-play-centered'"+ " controls preload='auto' width='100%' height='100%' poster='<?php echo (isset($mPoster))?$mPoster:'';?>'"+ "data-setup="">"+
"<p class="vjs-no-js">"+
"To view this video please enable JavaScript, and consider upgrading to a web browser that"+
"<a href="http://videojs.com/html5-video-support/" target="_blank">supports HTML5 video</a>"+
"</p>"+
+"</video>";
$( "#videotag" ).append(videotaghtml);
I was facing this issue before.
I believe it is because of data-setup=
in your code. Due to this, the plugins in javascript is not initialized as videojs considers only either data-setup or plugins.
data-setup=
Sometimes it considers data-setup=
. Thus, the videojs resolution switcher which contains the updateSrc method is not called. Hence the error. Just remove data-setup=
and it should be fine.
data-setup=
data-setup=
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.