Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ReferenceError: videojs is not defined

Tags:

video.js

I am using video.js (in CDN-Mode) and everything seems to work fine (with Firefox 26.0). The video is embedded and works fine. But when I want to access the video-Object, I'm getting the console-error: ReferenceError: videojs is not defined on the code-line where I want to access the object:

var myPlayer = videojs('example_video_1');

Googling arround could not solve my problem. I saw implementations where users used: V as constructor instead of videojs but this did not solve my problem).

This is my script, where I want to access the object:

<script type="text/javascript">
    $("#button1").on("click", function(){
        console.log( "You clicked a paragraph!" );
        var myPlayer = videojs('example_video_1');
    });
</script>

This is my header

<link href="http://vjs.zencdn.net/4.5/video-js.css" rel="stylesheet">
<script src="http://vjs.zencdn.net/4.5/video.js"></script>
<script language="javascript" type="text/javascript" src="js/jquery.js"></script>

And this is my video-declaration

<video id="example_video_1" class="video-js vjs-default-skin" controls
preload="auto" width="1270" height="720" poster="videos/search.png"
data-setup="{}">
    <source src="videos/search.webm" type='video/webm'>
    <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>

I would be happy for any kind of support.

like image 376
Stefan Wegener Avatar asked May 19 '14 11:05

Stefan Wegener


People also ask

What is Videojs?

Video.js is a web video player built from the ground up for an HTML5 world. It supports HTML5 video and modern streaming formats, as well as YouTube, Vimeo, and even Flash (through plugins, more on that later). It supports video playback on desktop and mobile devices.


2 Answers

You must install or use from @videojs/http-streaming. I had same problem and solved by it.

like image 81
soroush Avatar answered Nov 13 '22 00:11

soroush


I just made sure that the video.js file was the last attached script tag in the HTML. It worked for me.

like image 45
Yashash Gaurav Avatar answered Nov 12 '22 22:11

Yashash Gaurav