diff --git a/.gitignore b/.gitignore
index a533273a60..def61f8e96 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,6 +1,7 @@
.DS_Store
dist/*
build/files/*
+docs/api/*
dev.html
projects
.zenflow-log
diff --git a/Gruntfile.js b/Gruntfile.js
index 2984d7dc03..3869487cd3 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -20,6 +20,13 @@ module.exports = function(grunt) {
};
version.majorMinor = version.major + '.' + version.minor;
+ // loading predefined source order from source-loader.js
+ // trust me, this is the easist way to do it so far
+ /*jshint undef:false, evil:true */
+ var blockSourceLoading = true;
+ var sourceFiles; // Needed to satisfy jshint
+ eval(grunt.file.read('./build/source-loader.js'));
+
// Project configuration.
grunt.initConfig({
pkg: pkg,
@@ -131,6 +138,15 @@ module.exports = function(grunt) {
configFile: 'test/karma.conf.js',
autoWatch: false
}
+ },
+ vjsdocs: {
+ all: {
+ src: sourceFiles,
+ dest: 'docs/api',
+ options: {
+ baseURL: 'https://github.com/videojs/video.js/blob/master/'
+ }
+ }
}
});
@@ -144,6 +160,10 @@ module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-s3');
grunt.loadNpmTasks('contribflow');
grunt.loadNpmTasks('grunt-karma');
+ grunt.loadNpmTasks('videojs-doc-generator');
+
+ // grunt.loadTasks('./docs/tasks/');
+ // grunt.loadTasks('../videojs-doc-generator/tasks/');
// Default task.
grunt.registerTask('default', ['jshint', 'less', 'build', 'minify', 'dist']);
@@ -155,14 +175,6 @@ module.exports = function(grunt) {
gzip = require('zlib').gzip;
grunt.registerMultiTask('build', 'Building Source', function(){
- /*jshint undef:false, evil:true */
-
- // Loading predefined source order from source-loader.js
- // Trust me, this is the easist way to do it so far.
- var blockSourceLoading = true;
- var sourceFiles; // Needed to satisfy jshint
- eval(grunt.file.read('./build/source-loader.js'));
-
// Fix windows file path delimiter issue
var i = sourceFiles.length;
while (i--) {
@@ -307,4 +319,5 @@ module.exports = function(grunt) {
done();
});
});
+
};
diff --git a/docs/api.md b/docs/api.md
deleted file mode 100644
index dc4bec0823..0000000000
--- a/docs/api.md
+++ /dev/null
@@ -1,234 +0,0 @@
-API
-===
-The Video.js API allows you to interact with the video through Javascript, whether the browser is playing the video through HTML5 video, Flash, or any other supported playback technologies.
-
-Referencing the Player
-----------------------
-To use the API functions, you need access to the player object. Luckily this is easy to get. You just need to make sure your video tag has an ID. The example embed code has an ID of "example\_video_1". If you have multiple videos on one page, make sure every video tag has a unique ID.
-```js
-var myPlayer = videojs("example_video_1");
-```
-
-(If the player hasn't been initialized yet via the data-setup attribute or another method, this will also initialize the player.)
-
-Wait Until the Player is Ready
-------------------------------
-The time it takes Video.js to set up the video and API will vary depending on the playback technology being used (HTML5 will often be much faster to load than Flash). For that reason we want to use the player's 'ready' function to trigger any code that requires the player's API.
-```javascript
-videojs("example_video_1").ready(function(){
-
- var myPlayer = this;
-
- // EXAMPLE: Start playing the video.
- myPlayer.play();
-
-});
-```
-
-API Methods
------------
-Now that you have access to a ready player, you can control the video, get values, or respond to video events using the following functions. The Video.js API function names follow the [HTML5 media API](http://www.w3.org/TR/html5/video.html). The main difference is that attributes which you would get or set on a video element using the equals sign ( `myVideoElement.currentTime = "120";` ), you would use a function argument syntax for Video.js ( `myPlayer.currentTime(120);` )
-
-### play() ###
-Start video playback. Returns the player object.
-```js
-myPlayer.play();
-```
-
-
-### pause() ###
-Pause the video playback. Returns the player object
-```js
-myPlayer.pause();
-```
-
-
-### paused() ###
-Returns false if the video is currently playing, or true otherwise. ()
-```js
-var isPaused = myPlayer.paused();
-var isPlaying = !myPlayer.paused();
-```
-
-
-### src(newSource) ###
-The source function updates the video source. There are three types of variables you can pass as the argument.
-
-**URL String**: A URL to the the video file. Use this method if you're sure the current playback technology (HTML5/Flash) can support the source you provide. Currently only MP4 files can be used in both HTML5 and Flash.
-```js
-myPlayer.src("http://www.example.com/path/to/video.mp4");
-```
-
-**Source Object (or element):** A javascript object containing information about the source file. Use this method if you want the player to determine if it can support the file using the type information.
-```js
-myPlayer.src({ type: "video/mp4", src: "http://www.example.com/path/to/video.mp4" });
-```
-
-**Array of Source Objects:** To provide multiple versions of the source so that it can be played using HTML5 across browsers you can use an array of source objects. Video.js will detect which version is supported and load that file.
-```js
-myPlayer.src([
- { type: "video/mp4", src: "http://www.example.com/path/to/video.mp4" },
- { type: "video/webm", src: "http://www.example.com/path/to/video.webm" },
- { type: "video/ogg", src: "http://www.example.com/path/to/video.ogv" }
-]);
-```
-
-Returns the player object.
-
-
-### currentTime() ###
-Returns the current time of the video in seconds.
-```js
-var whereYouAt = myPlayer.currentTime();
-```
-
-
-### currentTime(seconds) // Type: Integer or Float ###
-Seek to the supplied time (seconds). Returns the player object.
-```js
-myPlayer.currentTime(120); // 2 minutes into the video
-```
-
-
-### duration() ###
-Returns the length in time of the video in seconds. NOTE: The video must have started loading before the duration can be known, and in the case of Flash, may not be known until the video starts playing.
-```js
-var howLongIsThis = myPlayer.duration();
-```
-
-
-### buffered() ###
-Returns a [TimeRange](glossary.md#timerange) object with sections of the video that have been downloaded. If you just want the percent of the video that's been downloaded, use bufferedPercent.
-```js
-var bufferedTimeRange = myPlayer.buffered(),
-
-// Number of different ranges of time have been buffered. Usually 1.
-numberOfRanges = bufferedTimeRange.length,
-
-// Time in seconds when the first range starts. Usually 0.
-firstRangeStart = bufferedTimeRange.start(0),
-
-// Time in seconds when the first range ends
-firstRangeEnd = bufferedTimeRange.end(0),
-
-// Length in seconds of the first time range
-firstRangeLength = firstRangeEnd - firstRangeStart;
-```
-
-
-### bufferedPercent() ###
-Returns the percent (as a decimal) of the video that's been downloaded. 0 means none, 1 means all.
-```js
-var howMuchIsDownloaded = myPlayer.bufferedPercent();
-```
-
-
-### volume() ###
-Returns the current volume of the video as a percent in decimal form. 0 is off (muted), 1.0 is all the way up, 0.5 is half way.
-```js
-var howLoudIsIt = myPlayer.volume();
-```
-
-
-### volume(percentAsDecimal) ###
-Set the volume to the supplied percent (as a decimal between 0 and 1).
-```js
-myPlayer.volume(0.5); // Set volume to half
-```
-
-
-### width() ###
-Returns the current width of the video in pixels.
-```js
-var howWideIsIt = myPlayer.width();
-```
-
-
-### width(pixels) ###
-Change the width of the video to the supplied width in pixels. Returns the player object
-```js
-myPlayer.width(640);
-```
-
-
-### height() ###
-Returns the current height of the video in pixels.
-```js
-var howTallIsIt = myPlayer.height();
-```
-
-
-### height(pixels) ###
-Change the height of the video to the supplied height in pixels. Returns the player object
-```js
-myPlayer.height(480);
-```
-
-
-### dimensions(width, height) ###
-Changes the width and height of the video to the supplied width and height. This is more efficient if you're changing both width and height (only triggers the player's resize event once). Returns the player object.
-```js
-myPlayer.dimensions(640,480);
-```
-
-
-### requestFullScreen() ###
-Increase the size of the video to full screen. In some browsers, full screen is not supported natively, so it enters full window mode, where the video fills the browser window. In browsers and devices that support native full screen, sometimes the browser's default controls will be shown, and not the Video.js custom skin. This includes most mobile devices (iOS, Android) and older versions of Safari. Returns the player object.
-```js
-myPlayer.requestFullScreen();
-```
-
-
-### cancelFullScreen() ###
-Return the video to its normal size after having been in full screen mode. Returns the player object.
-```js
-myPlayer.cancelFullScreen();
-```
-
-
-### dispose() ###
-Destroys the video player and does any necessary cleanup. This is especially helpful if you are dynamically adding and removing videos to/from the DOM. Use after removing videos from the DOM.
-```js
-myPlayer.dispose();
-```
-
-
-
-Events
-------
-You can attach event listeners to the player similarly to how you would for a video element.
-
-```js
-var myFunc = function(){
- var myPlayer = this;
- // Do something when the event is fired
-};
-myPlayer.on("eventName", myFunc);
-```
-
-You can also remove the listeners later.
-```js
-myPlayer.off("eventName", myFunc);
-```
-
-
-### Event Types
-List of player events you can add listeners for.
-
-
-
Name
Description
-
loadstart
Fired when the user agent begins looking for media data.
-
loadedmetadata
Fired when the player has initial duration and dimension information.
-
loadeddata
Fired when the player has downloaded data at the current playback position.
-
loadedalldata
Fired when the player has finished downloading the source data.
-
play
Fired whenever the media begins or resumes playback.
-
pause
Fired whenever the media has been paused.
-
timeupdate
Fired when the current playback position has changed. During playback this is fired every 15-250 milliseconds, depnding on the playback technology in use.
-
ended
Fired when the end of the media resource is reached. currentTime == duration
-
durationchange
Fired when the duration of the media resource is changed, or known for the first time.
-
progress
Fired while the user agent is downloading media data.
-
resize
Fired when the width and/or height of the video window changes.
-
volumechange
Fired when the volume changes.
-
error
Fired when there is an error in playback.
-
fullscreenchange
Fired when the player switches in or out of fullscreen mode.
-
diff --git a/docs/guides/api.md b/docs/guides/api.md
new file mode 100644
index 0000000000..944b387461
--- /dev/null
+++ b/docs/guides/api.md
@@ -0,0 +1,44 @@
+API
+===
+
+The Video.js API allows you to interact with the video through JavaScript, whether the browser is playing the video through HTML5 video, Flash, or any other supported playback technologies.
+
+Referencing the Player
+----------------------
+To use the API functions, you need access to the player object. Luckily this is easy to get. You just need to make sure your video tag has an ID. The example embed code has an ID of "example\_video_1". If you have multiple videos on one page, make sure every video tag has a unique ID.
+
+```js
+var myPlayer = videojs('example_video_1');
+```
+
+(If the player hasn't been initialized yet via the data-setup attribute or another method, this will also initialize the player.)
+
+Wait Until the Player is Ready
+------------------------------
+The time it takes Video.js to set up the video and API will vary depending on the playback technology being used (HTML5 will often be much faster to load than Flash). For that reason we want to use the player's 'ready' function to trigger any code that requires the player's API.
+
+```javascript
+videojs("example_video_1").ready(function(){
+ var myPlayer = this;
+
+ // EXAMPLE: Start playing the video.
+ myPlayer.play();
+
+});
+```
+
+API Methods
+-----------
+Now that you have access to a ready player, you can control the video, get values, or respond to video events. The Video.js API function names follow the [HTML5 media API](http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html). The main difference is that getter/setter functions are used for video properties.
+
+```js
+
+// setting a property on a bare HTML5 video element
+myVideoElement.currentTime = "120";
+
+// setting a property on a Video.js player
+myPlayer.currentTime(120);
+
+```
+
+The full list of player API methods and events can be found in the [player API docs](../api/player.md).
diff --git a/docs/components.md b/docs/guides/components.md
similarity index 62%
rename from docs/components.md
rename to docs/guides/components.md
index 248850c89c..130e6c9ccf 100644
--- a/docs/components.md
+++ b/docs/guides/components.md
@@ -3,13 +3,11 @@ Components
The Video.js player is built on top of a simple, custom UI components architecture. The player class and all control classes inherit from the Component class, or a subclass of Component.
```js
-videojs.Control = videojs.Component.extend({});
-videojs.Button = videojs.Control.extend({});
-videojs.PlayToggle = videojs.Button.extend({});
+videojs.Control = videojs.Component.extend();
+videojs.Button = videojs.Control.extend();
+videojs.PlayToggle = videojs.Button.extend();
```
-(The Class interface itself is provided using John Resig's [simple class inheritance](http://ejohn.org/blog/simple-javascript-inheritance/) also found in [JSNinja](http://jsninja.com).
-
The UI component architecture makes it easier to add child components to a parent component and build up an entire user interface, like the controls for the Video.js player.
```js
@@ -59,33 +57,3 @@ Player
VolumeHandle
MuteToggle
```
-
-Component Methods
------------------
-
-### addChild() ###
-Add a child component to myComponent. This will also insert the child component's DOM element into myComponent's element.
-
-
-
-```js
-myComponent.addChild('');
-```
-
-
-myPlayer.addChild('BigPlayButton');
-myPlayer.removeChild('BigPlayButton');
-myPlayer.getChild('BiPlayButton');
-myPlayer.children();
-
-
-myPlayer.getChildById('biPlayButton');
-myPlayer.removeChildById('my-player-big-play-button');
-
-el();
-getContentEl();
-getChildren();
-
-getParent();
-
-#home_player_big-play-button
diff --git a/docs/glossary.md b/docs/guides/glossary.md
similarity index 100%
rename from docs/glossary.md
rename to docs/guides/glossary.md
diff --git a/docs/options.md b/docs/guides/options.md
similarity index 100%
rename from docs/options.md
rename to docs/guides/options.md
diff --git a/docs/plugins.md b/docs/guides/plugins.md
similarity index 100%
rename from docs/plugins.md
rename to docs/guides/plugins.md
diff --git a/docs/setup.md b/docs/guides/setup.md
similarity index 97%
rename from docs/setup.md
rename to docs/guides/setup.md
index 979740a867..0f738d4761 100644
--- a/docs/setup.md
+++ b/docs/guides/setup.md
@@ -20,8 +20,8 @@ You can download the Video.js source and host it on your own servers, or use the
### CDN Version ###
```html
-
-
+
+
```
### Self Hosted. ###
diff --git a/docs/skins.md b/docs/guides/skins.md
similarity index 100%
rename from docs/skins.md
rename to docs/guides/skins.md
diff --git a/docs/tech.md b/docs/guides/tech.md
similarity index 77%
rename from docs/tech.md
rename to docs/guides/tech.md
index 90901cd1ca..763ce4c058 100644
--- a/docs/tech.md
+++ b/docs/guides/tech.md
@@ -66,35 +66,3 @@ You may optionally use the last `/` as the separator between connection and stre