Comparar commits
98 Commits
| Autor | SHA1 | Data | |
|---|---|---|---|
| ff2d59fcf8 | |||
| 855f513d5f | |||
| 62bb873ddd | |||
| 55ac829fb1 | |||
| 6def502496 | |||
| dff355dda9 | |||
| 1d65860227 | |||
| ee740c619f | |||
| a1a0e351c1 | |||
| 44b02529ba | |||
| a83433f655 | |||
| d80e3e328a | |||
| 166bd0b44f | |||
| 7b7c8a497f | |||
| 42c9e43736 | |||
| 90956059f6 | |||
| ab07612c05 | |||
| 7ef5b15ae2 | |||
| 9678c7717f | |||
| 8dd38fc747 | |||
| 242ff4c68b | |||
| 38cc63c530 | |||
| 41b93513a2 | |||
| 359cde31c2 | |||
| 1fba4f4b88 | |||
| 16f6c229f3 | |||
| accdfcb02c | |||
| ee1a7dae99 | |||
| b31eba988b | |||
| 20b36faf11 | |||
| 82142e2f54 | |||
| 1c18578466 | |||
| 0e81c6b059 | |||
| 99fa329bc5 | |||
| f13a2bf733 | |||
| 6945be3d6e | |||
| d1fb95ecbf | |||
| 176eb1f559 | |||
| 8babbb412c | |||
| f4e68d1a47 | |||
| e0516a4c83 | |||
| 1972528df7 | |||
| 39f7bead50 | |||
| e4f6bbb0b2 | |||
| afc9369849 | |||
| 325084c6a1 | |||
| 2f99215f8d | |||
| d90cee588a | |||
| 00a38f76a7 | |||
| b329dfd107 | |||
| 11286190fa | |||
| 05d7a81885 | |||
| 1dd70d1c77 | |||
| 437566740f | |||
| 7e747e95ab | |||
| de6230644e | |||
| 08aa73ccf6 | |||
| 2607e82aaf | |||
| ec145f6d4d | |||
| 78a3b16e9c | |||
| 58cf933091 | |||
| f8fc9a8d7b | |||
| 5f4369e188 | |||
| 4593421adb | |||
| f0154eeab7 | |||
| 1e284827d7 | |||
| 3e99e630ea | |||
| 0c7334c861 | |||
| 82d55c45e7 | |||
| 7538241008 | |||
| 6193e01004 | |||
| ef321a8072 | |||
| e5a44eef58 | |||
| 5488570745 | |||
| a314c0a242 | |||
| 53e1d0eb65 | |||
| 193172498c | |||
| 7da9bdd073 | |||
| df3718cd55 | |||
| c5a22081b4 | |||
| 3fc71d098d | |||
| 34c187cd9a | |||
| 3243b01e6c | |||
| cc27d630c6 | |||
| db0033ebe5 | |||
| c2b43903ab | |||
| 2ea9c99f34 | |||
| 449c7014fb | |||
| 6d59836b76 | |||
| e703e1591e | |||
| c4f87649e4 | |||
| 6cccf594ad | |||
| df41661f47 | |||
| 3daa81f87e | |||
| 4f60eb896c | |||
| ee7318f6ae | |||
| d7aa9f9558 | |||
| 442696cfc2 |
@@ -0,0 +1,5 @@
|
||||
.DS_Store
|
||||
dist/*
|
||||
dev.html
|
||||
projects
|
||||
.zenflow-log
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
---
|
||||
confirm_review: true
|
||||
backup_remote: false
|
||||
release_branch: stable
|
||||
project: videojs
|
||||
qa_branch: false
|
||||
staging_branch: false
|
||||
development_branch: master
|
||||
remote: origin
|
||||
confirm_staging: false
|
||||
@@ -0,0 +1,12 @@
|
||||
--------------------------------------------------------------------------------
|
||||
^ ADD NEW CHANGES ABOVE ^
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
CHANGELOG
|
||||
=========
|
||||
|
||||
---- 3.0.3 / 2012-01-12 / doc-change -------------------------------------------
|
||||
* Added line to docs to test zenflow
|
||||
|
||||
---- 3.0.4 / 2012-01-12 / undefined-source-fix ---------------------------------
|
||||
* Fixing an undefined source when no sources exist on load
|
||||
@@ -1,215 +0,0 @@
|
||||
VideoJS - [HTML5 Video Player](http://videojs.com)
|
||||
==================================================
|
||||
Version 2.0.2
|
||||
|
||||
View [VideoJS.com](http://videojs.com) for a demo and overview.
|
||||
|
||||
VideoJS is an HTML5 video player that uses the HTML5 video tag built into modern browsers, and uses javascript to add custom controls, new functionality, and to fix cross browser bugs.
|
||||
|
||||
The base of VideoJS is Kroc Camen's [Video for Everybody](http://camendesign.com/code/video_for_everybody), which is a video embed code that falls back to a Flash video player or download links for browsers and devices that don't support HTML5 video.
|
||||
|
||||
View demo.html for an example of how to use it.
|
||||
|
||||
Originally based on [this tutorial](http://blog.steveheffernan.com/2010/04/how-to-build-an-html5-video-player/).
|
||||
|
||||
Contributors (Github Username)
|
||||
------------------------------
|
||||
heff, dz0ny, sentientbit, tvdeyen, brandonarbini, gordonbrander, Shraymonks, albertogasparin, sandaru1, nicholasbs, majornista, Fredust85, @wonderboymusic, ellis-, emirpprime, eirikb, mbrubeck
|
||||
|
||||
|
||||
Getting Started
|
||||
---------------
|
||||
|
||||
### Step 1: Include VideoJS Javascript and CSS files in your page.
|
||||
Change the src/href to the appropriate location on your server.
|
||||
|
||||
<script src="video.js" type="text/javascript" charset="utf-8"></script>
|
||||
<link rel="stylesheet" href="video-js.css" type="text/css" media="screen" title="Video JS" charset="utf-8">
|
||||
|
||||
|
||||
### Step 2: Add the VideoJS setup code to your page or another script.
|
||||
Must run after the VideoJS javascript file has been included
|
||||
|
||||
<script type="text/javascript" charset="utf-8">
|
||||
|
||||
// Add VideoJS to all video tags on the page when the DOM is ready
|
||||
VideoJS.setupAllWhenReady();
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
### Step 3: Add the VideoJS embed code to your page (grab the latest version for demo.html).
|
||||
Change the video and image files to your own. You can even swap out the Flash Fallback for your own, just maintain the "vjs-flash-fallback" class on the object. I know, seems like a lot of HTML, but it's super compatible. [Check it](http://camendesign.com/code/video_for_everybody/test.html).
|
||||
|
||||
<!-- Begin VideoJS -->
|
||||
<div class="video-js-box">
|
||||
<!-- Using the Video for Everybody Embed Code http://camendesign.com/code/video_for_everybody -->
|
||||
<video id="example_video_1" class="video-js" width="640" height="264" poster="http://video-js.zencoder.com/oceans-clip.png" controls preload>
|
||||
<source src="http://video-js.zencoder.com/oceans-clip.mp4" type='video/mp4; codecs="avc1.42E01E, mp4a.40.2"' />
|
||||
<source src="http://video-js.zencoder.com/oceans-clip.webm" type='video/webm; codecs="vp8, vorbis"' />
|
||||
<source src="http://video-js.zencoder.com/oceans-clip.ogv" type='video/ogg; codecs="theora, vorbis"' />
|
||||
<!-- Flash Fallback. Use any flash video player here. Make sure to keep the vjs-flash-fallback class. -->
|
||||
<object id="flash_fallback_1" class="vjs-flash-fallback" width="640" height="264" type="application/x-shockwave-flash"
|
||||
data="http://releases.flowplayer.org/swf/flowplayer-3.2.1.swf">
|
||||
<param name="movie" value="http://releases.flowplayer.org/swf/flowplayer-3.2.1.swf" />
|
||||
<param name="wmode" value="opaque" />
|
||||
<param name="allowfullscreen" value="true" />
|
||||
<param name="flashvars" value='config={"playlist":["http://video-js.zencoder.com/oceans-clip.png", {"url": "http://video-js.zencoder.com/oceans-clip.mp4","autoPlay":false,"autoBuffering":true}]}' />
|
||||
<!-- Image Fallback. Typically the same as the poster image. -->
|
||||
<img src="http://video-js.zencoder.com/oceans-clip.png" width="640" height="264" alt="Poster Image"
|
||||
title="No video playback capabilities." />
|
||||
</object>
|
||||
</video>
|
||||
<!-- Download links provided for devices that can't play video in the browser. -->
|
||||
<p class="vjs-no-video"><strong>Download Video:</strong>
|
||||
<a href="http://video-js.zencoder.com/oceans-clip.mp4">MP4</a>,
|
||||
<a href="http://video-js.zencoder.com/oceans-clip.webm">WebM</a>,
|
||||
<a href="http://video-js.zencoder.com/oceans-clip.ogv">Ogg</a><br>
|
||||
<!-- Support VideoJS by keeping this link. -->
|
||||
<a href="http://videojs.com">HTML5 Video Player</a> by VideoJS
|
||||
</p>
|
||||
</div>
|
||||
<!-- End VideoJS -->
|
||||
|
||||
|
||||
Storing a Reference to the Player(s)
|
||||
------------------------------------
|
||||
You can set up the player(s) in a way that allows you to access it later, and control things like the video playback. In this case, the setup has to happen after the DOM has been loaded. You can use any library's DOM Ready method, or the one built into VideoJS.
|
||||
|
||||
### Using a Video's ID or Element
|
||||
|
||||
VideoJS.DOMReady(function(){
|
||||
var myPlayer = VideoJS.setup("example_video_1");
|
||||
});
|
||||
|
||||
|
||||
### Using an array of video elements/IDs
|
||||
Note: It returns an array of players
|
||||
|
||||
VideoJS.DOMReady(function(){
|
||||
var myManyPlayers = VideoJS.setup(["example_video_1", "example_video_2", video3Element]);
|
||||
});
|
||||
|
||||
|
||||
### All videos on the page with the "video-js" class
|
||||
|
||||
VideoJS.DOMReady(function(){
|
||||
var myManyPlayers = VideoJS.setup("All");
|
||||
});
|
||||
|
||||
|
||||
### After you have references to your players you can...(example)
|
||||
|
||||
VideoJS.DOMReady(function(){
|
||||
var myPlayer = VideoJS.setup("example_video_1");
|
||||
myPlayer.play(); // Starts playing the video for this player.
|
||||
});
|
||||
|
||||
|
||||
Setting Options
|
||||
---------------
|
||||
Set options when setting up the videos. The defaults are shown here.
|
||||
|
||||
VideoJS.setupAllWhenReady({
|
||||
controlsBelow: false, // Display control bar below video instead of in front of
|
||||
controlsHiding: true, // Hide controls when mouse is not over the video
|
||||
defaultVolume: 0.85, // Will be overridden by user's last volume if available
|
||||
flashPlayerVersion: 9, // Required flash version for fallback
|
||||
});
|
||||
|
||||
### Or as the second option of VideoJS.setup
|
||||
|
||||
VideoJS.DOMReady(function(){
|
||||
var myPlayer = VideoJS.setup("example_video_1", {
|
||||
// Same options
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Coming Next
|
||||
-----------
|
||||
- API to Flash fallback
|
||||
|
||||
Changelog
|
||||
---------
|
||||
2.0.3
|
||||
|
||||
- Feature: Made returning to the start at the end of the movie an option ("returnToStart").
|
||||
- Feature: Added loop option to loop movie ("loop").
|
||||
- Feature: Reorganized player API and listeners.
|
||||
- Feature: Added option to disable controls. controlsEnabled: false
|
||||
- Feature: Setup method now has a callback, so you can more easily work with the player after setup
|
||||
- Feature: Added listeners for enter/exit full screen/window.
|
||||
- Feature: Added a VideoJS.player(id) function for getting the player for a video ID
|
||||
- Changes: setupAllWhenReady is now just setupAll (backward compatible)
|
||||
- Fix: Check for Android browser now excludes firefox and opera
|
||||
|
||||
2.0.2 (2010-12-10)
|
||||
|
||||
- Feature: Rewrote and optimized subtitle code.
|
||||
- Feature: Protecting against volume ranges outside of 1 and 0.
|
||||
- Fix: Bug in Safari for Mac OS 10.5 (Leopard) that was breaking fullscreen.
|
||||
|
||||
2.0.1 (2010-11-22)
|
||||
|
||||
- Fix: Issue with big play button when multiple videos are on the page.
|
||||
- Fix: Optimized play progress tracking.
|
||||
- Fix: Optimized buffer progress checking.
|
||||
- Fix: Firefox not showing Flash fallback object.
|
||||
|
||||
2.0.0 (2010-11-21)
|
||||
|
||||
- Feature: Created "behaviors" concept for adding behaviors to elements
|
||||
- Feature: Switched back to divs for controls, for more portable styles
|
||||
- Feature: Created playerFallbackOrder array option. ["html5", "flash", "links"]
|
||||
- Feature: Created playerType concept, for initializing different platforms
|
||||
- Feature: Added play button for Android
|
||||
- Feature: Added spinner for iPad (non-fullscreen)
|
||||
- Feature: Split into multiple files for easier development
|
||||
- Feature: Combined VideoJS & _V_ into the same variable to reduce confusion
|
||||
- Fix: Checking for m3u8 files (Apple HTTP Streaming)
|
||||
- Fix: Catching error on localStorage full that safari seems to randomly throw
|
||||
- Fix: Scrubbing to end doesn't trigger onEnded
|
||||
|
||||
1.1.5 (2010-11-09)
|
||||
|
||||
- Feature: Switched to track method for setting subtitles. Now works like spec.
|
||||
- Feature: Created "players" concept for defining fallbacks and fallback order
|
||||
- Fix: Android playback bug.
|
||||
- Fix: Massive reorganization of code to make easier to navigate
|
||||
|
||||
1.1.4 (2010-11-06)
|
||||
|
||||
- Feature: Added loading spinner.
|
||||
- Feature: Improved styles loaded checking.
|
||||
- Feature: Added volume() function to get and set volume through the player.
|
||||
- Fix: Fix issue where FF would loop video in background when ended.
|
||||
- Fix: Bug in Chrome that shows poster & plays audio if you set currentTime too quickly.
|
||||
- Fix: Bug in Safari where waiting is triggered and shows spinner when not needed
|
||||
- Fix: Updated to show links if only unplayable sources and no Flash.
|
||||
- Fix: Issue where if play button was loaded after play, it wouldn't hide.
|
||||
|
||||
1.1.3 (2010-10-19)
|
||||
|
||||
- Feature: Width/Height functions for resizing the player
|
||||
- Feature: Made initial click & hold trigger new value on progress and volume
|
||||
- Feature: Made controls not hide when hovering over them
|
||||
- Feature: Added big play button as default starting control.
|
||||
- Fix: Removed trailing comma that was breaking IE7
|
||||
- Fix: Removed some vars from global scope
|
||||
- Fix: Changed a document.onmousemove to an eventListener to prevent conflicts
|
||||
- Fix: Added a unique ID to FlowPlayer demo object to fix a FlowPlayer bug. Thanks @emirpprime.
|
||||
- Fix: Safari error on unloaded video
|
||||
|
||||
1.1.2 (2010-09-20)
|
||||
|
||||
- Added a fix for the poster bug in iPad/iPhone
|
||||
- Added more specificity to styles
|
||||
|
||||
1.1.1 (2010-09-14)
|
||||
|
||||
- First Formally Versioned Release
|
||||
|
||||
1.0.0 (2010-05-18)
|
||||
|
||||
- First released
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
VideoJS - [HTML5 Video Player](http://videojs.com)
|
||||
==================================================
|
||||
Version 3.0 BETA
|
||||
|
||||
Visit the main site at [videojs.com](http://videojs.com) for download options and instructions.
|
||||
|
||||
To build video-js from the latest version of the source, clone the source repository and run:
|
||||
sh build.sh
|
||||
in the video-js directory using the commnand-line/terminal of a unix-based system.
|
||||
|
||||
Contributing
|
||||
------------
|
||||
If you'd like to help out on VideoJS, you are awesome. Updates should be made to the source files and then make a pull request.
|
||||
|
||||
When working on VideoJS code, you can use dev.html as your test page. It doesn't exist in the repo and changes to it won't be tracked. To get your own copy simply clone the repo and copy dev.html.example.
|
||||
cp dev.html.example dev.html
|
||||
|
||||
You can use dev.html to test new code. It's simple HTML doc that includes all the source files. Send a pull request for any updates.
|
||||
|
||||
---
|
||||
BETA NOTES
|
||||
Version 3 is almost a complete rewrite of the previous versions of VideoJS. New features includes:
|
||||
|
||||
- HTML/CSS Controls and API now work for both the HTML5 and Flash versions.
|
||||
- Custom Super-lightweight Flash Fallback
|
||||
- Embed Code is much simpler.
|
||||
- No more "vjs-box" div required, just use the video tag.
|
||||
- No more embedding of Flash fallback within the video tag HTML.
|
||||
|
||||
---
|
||||
@@ -0,0 +1,4 @@
|
||||
---
|
||||
major: 3
|
||||
patch: 4
|
||||
minor: 0
|
||||
Arquivo executável
+48
@@ -0,0 +1,48 @@
|
||||
#! /bin/csh
|
||||
# Combines Source Files. In terminal, sh build.sh
|
||||
# It will put a new video.js file under dist/
|
||||
|
||||
# Create dist directory if it doesn't already exist
|
||||
mkdir -p dist
|
||||
|
||||
# FILES=../src/*
|
||||
# for f in $FILES
|
||||
# do
|
||||
# echo "Processing $f file..."
|
||||
# # take action on each file. $f store current file name
|
||||
# cat $f
|
||||
# done
|
||||
|
||||
cat src/_begin.js > dist/video.js
|
||||
|
||||
cat src/core.js >> dist/video.js
|
||||
cat src/lib.js >> dist/video.js
|
||||
cat src/ecma.js >> dist/video.js
|
||||
cat src/json.js >> dist/video.js
|
||||
cat src/events.js >> dist/video.js
|
||||
|
||||
cat src/component.js >> dist/video.js
|
||||
cat src/player.js >> dist/video.js
|
||||
cat src/tech.js >> dist/video.js
|
||||
cat src/controls.js >> dist/video.js
|
||||
|
||||
cat src/tracks.js >> dist/video.js
|
||||
|
||||
# h5swf temporarily requires swfobject
|
||||
cat flash/swfobject.js >> dist/video.js
|
||||
|
||||
cat src/setup.js >> dist/video.js
|
||||
cat src/_end.js >> dist/video.js
|
||||
|
||||
|
||||
# Copy Files
|
||||
cp design/video-js.css dist/video-js.css
|
||||
cp design/video-js.png dist/video-js.png
|
||||
cp flash/video-js.swf dist/video-js.swf
|
||||
|
||||
cp build/release-files/README.md dist/README.md
|
||||
cp build/release-files/demo.html dist/demo.html
|
||||
cp LGPLv3-LICENSE.txt dist/LGPLv3-LICENSE.txt
|
||||
|
||||
java -jar build/lib/yuicompressor-2.4.7.jar dist/video.js -o dist/video.min.js
|
||||
java -jar build/lib/yuicompressor-2.4.7.jar dist/video-js.css -o dist/video-js.min.css
|
||||
@@ -0,0 +1,28 @@
|
||||
Deploying Version
|
||||
-----------------
|
||||
- Update SWF location for CDN
|
||||
|
||||
Version Numbers
|
||||
---------------
|
||||
http://en.wikipedia.org/wiki/Software_versioning#Sequence-based_identifiers
|
||||
|
||||
### Major Version (Integer, e.g 3.0)
|
||||
- Any features where we expect it could break plugins, skins, or any major API integration.
|
||||
|
||||
### Minor Version (3.1)
|
||||
- Additional non-breaking features
|
||||
|
||||
### Revision Versions
|
||||
|
||||
- Beta (3.1b1)
|
||||
- Release Candidate (3.1rc1)
|
||||
- Release with revisions (3.1r1)
|
||||
|
||||
Notes:
|
||||
The last level of one revision type (beta/release candidate) should match the first level of the next revision type. 4.0-b10 should match 4.0-rc1, assuming b10 is the last beta version.
|
||||
|
||||
Release revisions means bug fixes. The CDN url should not reflect the revision number. 4.0-r2 would still be /4.0/.
|
||||
|
||||
Tagging a Release
|
||||
-----------------
|
||||
git tag -a [version number] [commit]
|
||||
Arquivo binário não exibido.
@@ -0,0 +1,153 @@
|
||||
Video.js - [HTML5 Video Player](http://videojs.com)
|
||||
==================================================
|
||||
Version 3.0
|
||||
|
||||
---
|
||||
Version 3 is almost a complete rewrite of the previous versions of Video.js. New features includes:
|
||||
|
||||
- HTML/CSS Controls and API now work for both the HTML5 and Flash versions.
|
||||
- Custom Super-lightweight Flash Fallback
|
||||
- Embed Code is much simpler.
|
||||
- No more "vjs-box" div required, just use the video tag.
|
||||
- No more embedding of Flash fallback within the video tag HTML.
|
||||
|
||||
---
|
||||
|
||||
View [videojs.com](http://videojs.com) for a demo and overview.
|
||||
|
||||
Video.js is an HTML5 video player that uses the HTML5 video tag built into modern browsers, and uses javascript to add custom controls, new functionality, and to fix cross browser bugs. For browsers that don't support HTML5, it will fallback to a Flash player.
|
||||
|
||||
View demo.html for an example of how to use it.
|
||||
|
||||
Originally based on [this tutorial](http://blog.steveheffernan.com/2010/04/how-to-build-an-html5-video-player/).
|
||||
|
||||
Contributors (Github Username)
|
||||
------------------------------
|
||||
heff, dz0ny, sentientbit, tvdeyen, brandonarbini, gordonbrander, Shraymonks, albertogasparin, sandaru1, nicholasbs, majornista, Fredust85, @wonderboymusic, ellis-, emirpprime, eirikb, mbrubeck
|
||||
|
||||
|
||||
Getting Started
|
||||
---------------
|
||||
|
||||
### Step 1: Include the Video.js Javascript and CSS files in the head of your page.
|
||||
Change the file urls to point to the files on your server.
|
||||
|
||||
<script src="video.js"></script>
|
||||
<link href="video-js.css" rel="stylesheet">
|
||||
|
||||
|
||||
### Step 2: Add an HTML5 video tag to your page.
|
||||
Use the video tag as normal, with a few extra pieces for Video.js:
|
||||
|
||||
1. The 'data-setup' attribute tells Video.js to automatically set up the video when the page is ready, and read any options (in JSON format) from the attribute.
|
||||
2. The 'id' Attribute: Should be used and unique for every video on the same page.
|
||||
3. The 'class' attribute contains two classes:
|
||||
- 'video-js' applies styles that are required for Video.js functionality, like fullscreen and subtitles.
|
||||
- 'vjs-default-skin' applies the default skin to the HTML controls, and can be removed or overridden to create your own controls design.
|
||||
|
||||
Otherwise include/exclude attributes, settings, sources, and tracks exactly as you would for HTML5 video.
|
||||
|
||||
<video id="example_video_1" class="video-js vjs-default-skin" controls preload="auto" width="640" height="264"
|
||||
poster="http://video-js.zencoder.com/oceans-clip.png"
|
||||
data-setup='{"example_option":true}'>
|
||||
<source src="http://video-js.zencoder.com/oceans-clip.mp4" type='video/mp4' />
|
||||
<source src="http://video-js.zencoder.com/oceans-clip.webm" type='video/webm' />
|
||||
</video>
|
||||
|
||||
|
||||
### Step 3: Nada!
|
||||
That's all it take to get started. See the [docs](http://videojs.com/docs/) for more advanced uses.
|
||||
|
||||
|
||||
Changelog
|
||||
---------
|
||||
3.0
|
||||
|
||||
- Complete rewrite
|
||||
- HTML/CSS Controls and API now work for both the HTML5 and Flash versions
|
||||
- Custom Super-lightweight Flash Fallback
|
||||
- Embed Code is much simpler.
|
||||
- No more "vjs-box" div required, just use the video tag.
|
||||
- No more embedding of Flash fallback within the video tag HTML.
|
||||
|
||||
2.0.3
|
||||
|
||||
- Feature: Made returning to the start at the end of the movie an option ("returnToStart").
|
||||
- Feature: Added loop option to loop movie ("loop").
|
||||
- Feature: Reorganized player API and listeners.
|
||||
- Feature: Added option to disable controls. controlsEnabled: false
|
||||
- Feature: Setup method now has a callback, so you can more easily work with the player after setup
|
||||
- Feature: Added listeners for enter/exit full screen/window.
|
||||
- Feature: Added a VideoJS.player(id) function for getting the player for a video ID
|
||||
- Changes: setupAllWhenReady is now just setupAll (backward compatible)
|
||||
- Fix: Check for Android browser now excludes firefox and opera
|
||||
|
||||
2.0.2 (2010-12-10)
|
||||
|
||||
- Feature: Rewrote and optimized subtitle code.
|
||||
- Feature: Protecting against volume ranges outside of 1 and 0.
|
||||
- Fix: Bug in Safari for Mac OS 10.5 (Leopard) that was breaking fullscreen.
|
||||
|
||||
2.0.1 (2010-11-22)
|
||||
|
||||
- Fix: Issue with big play button when multiple videos are on the page.
|
||||
- Fix: Optimized play progress tracking.
|
||||
- Fix: Optimized buffer progress checking.
|
||||
- Fix: Firefox not showing Flash fallback object.
|
||||
|
||||
2.0.0 (2010-11-21)
|
||||
|
||||
- Feature: Created "behaviors" concept for adding behaviors to elements
|
||||
- Feature: Switched back to divs for controls, for more portable styles
|
||||
- Feature: Created playerFallbackOrder array option. ["html5", "flash", "links"]
|
||||
- Feature: Created playerType concept, for initializing different platforms
|
||||
- Feature: Added play button for Android
|
||||
- Feature: Added spinner for iPad (non-fullscreen)
|
||||
- Feature: Split into multiple files for easier development
|
||||
- Feature: Combined VideoJS & _V_ into the same variable to reduce confusion
|
||||
- Fix: Checking for m3u8 files (Apple HTTP Streaming)
|
||||
- Fix: Catching error on localStorage full that safari seems to randomly throw
|
||||
- Fix: Scrubbing to end doesn't trigger onEnded
|
||||
|
||||
1.1.5 (2010-11-09)
|
||||
|
||||
- Feature: Switched to track method for setting subtitles. Now works like spec.
|
||||
- Feature: Created "players" concept for defining fallbacks and fallback order
|
||||
- Fix: Android playback bug.
|
||||
- Fix: Massive reorganization of code to make easier to navigate
|
||||
|
||||
1.1.4 (2010-11-06)
|
||||
|
||||
- Feature: Added loading spinner.
|
||||
- Feature: Improved styles loaded checking.
|
||||
- Feature: Added volume() function to get and set volume through the player.
|
||||
- Fix: Fix issue where FF would loop video in background when ended.
|
||||
- Fix: Bug in Chrome that shows poster & plays audio if you set currentTime too quickly.
|
||||
- Fix: Bug in Safari where waiting is triggered and shows spinner when not needed
|
||||
- Fix: Updated to show links if only unplayable sources and no Flash.
|
||||
- Fix: Issue where if play button was loaded after play, it wouldn't hide.
|
||||
|
||||
1.1.3 (2010-10-19)
|
||||
|
||||
- Feature: Width/Height functions for resizing the player
|
||||
- Feature: Made initial click & hold trigger new value on progress and volume
|
||||
- Feature: Made controls not hide when hovering over them
|
||||
- Feature: Added big play button as default starting control.
|
||||
- Fix: Removed trailing comma that was breaking IE7
|
||||
- Fix: Removed some vars from global scope
|
||||
- Fix: Changed a document.onmousemove to an eventListener to prevent conflicts
|
||||
- Fix: Added a unique ID to FlowPlayer demo object to fix a FlowPlayer bug. Thanks @emirpprime.
|
||||
- Fix: Safari error on unloaded video
|
||||
|
||||
1.1.2 (2010-09-20)
|
||||
|
||||
- Added a fix for the poster bug in iPad/iPhone
|
||||
- Added more specificity to styles
|
||||
|
||||
1.1.1 (2010-09-14)
|
||||
|
||||
- First Formally Versioned Release
|
||||
|
||||
1.0.0 (2010-05-18)
|
||||
|
||||
- First released
|
||||
@@ -0,0 +1,23 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Video.js | HTML5 Video Player</title>
|
||||
|
||||
<link href="video-js.css" rel="stylesheet" type="text/css">
|
||||
|
||||
<!-- video.js must be in the <head> for older IEs to work. -->
|
||||
<script src="video.js"></script>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<video id="example_video_1" class="video-js vjs-default-skin" controls preload="none" width="640" height="264"
|
||||
poster="http://video-js.zencoder.com/oceans-clip.png"
|
||||
data-setup="{}">
|
||||
<source src="http://video-js.zencoder.com/oceans-clip.mp4" type='video/mp4' />
|
||||
<source src="http://video-js.zencoder.com/oceans-clip.webm" type='video/webm' />
|
||||
<source src="http://video-js.zencoder.com/oceans-clip.ogv" type='video/ogg' />
|
||||
</video>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,7 @@
|
||||
body { background-color: #ccc; font-size: 11px; font-family: 'Helvetica Neue', helvetica, arial; }
|
||||
#main { width: 1000px; margin: 10px auto 0; }
|
||||
td, th { text-align: left; vertical-align: top; }
|
||||
td.info-col { width: 240px; }
|
||||
td.data { text-align: right; }
|
||||
span.na { color: red; }
|
||||
span.undefined { color: #999; }
|
||||
@@ -0,0 +1,75 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>HTML5 Video Player</title>
|
||||
|
||||
<link rel="stylesheet" href="../design/video-js.css" type="text/css">
|
||||
<!--[if lt IE 9]>
|
||||
<script>
|
||||
document.createElement("video"); // HTML5 Shiv. Must be in <head>.
|
||||
</script>
|
||||
<![endif]-->
|
||||
|
||||
<!--[if IE]>
|
||||
<script src="https://getfirebug.com/firebug-lite.js" type="text/javascript" charset="utf-8"></script>
|
||||
<![endif]-->
|
||||
|
||||
|
||||
<script src="../src/core.js"></script>
|
||||
<script src="../src/lib.js"></script>
|
||||
<script src="../src/ecma.js"></script>
|
||||
<script src="../src/json.js"></script>
|
||||
|
||||
<script src="../src/component.js"></script>
|
||||
<script src="../src/player.js"></script>
|
||||
<script src="../src/tech.js"></script>
|
||||
<script src="../src/controls.js"></script>
|
||||
<script src="../src/events.js"></script>
|
||||
<script src="../src/tracks.js"></script>
|
||||
|
||||
<script src="../flash/swfobject.js"></script>
|
||||
|
||||
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
|
||||
|
||||
<link rel="stylesheet" href="compare.css" type="text/css">
|
||||
<script type="text/javascript" src="compare.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="main">
|
||||
<table border="0" cellspacing="5" cellpadding="5">
|
||||
<tr><th colspan="2">HTML5</th><th colspan="2">Flash</th></tr>
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<video id="vid1" class="video-js vjs-default-skin" controls preload="auto" width="480" height="198"
|
||||
poster="http://video-js.zencoder.com/oceans-clip.png">
|
||||
<source src="http://video-js.zencoder.com/oceans-clip.mp4" type='video/mp4'>
|
||||
<source src="http://video-js.zencoder.com/oceans-clip.webm" type='video/webm'>
|
||||
</video>
|
||||
</td>
|
||||
<td colspan="2">
|
||||
<video id="vid2" class="video-js vjs-default-skin" controls preload="auto" width="480" height="198"
|
||||
poster="http://video-js.zencoder.com/oceans-clip.png">
|
||||
<source src="http://video-js.zencoder.com/oceans-clip.mp4" type='video/mp4'>
|
||||
<!-- <source src="http://video-js.zencoder.com/oceans-clip.webm" type='video/webm'> -->
|
||||
</video>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="info-col">
|
||||
<table id="html5_props" border="0" cellspacing="0" cellpadding="0"></table>
|
||||
</td>
|
||||
<td class="info-col">
|
||||
<div id="html5_events"></div>
|
||||
</td>
|
||||
<td class="info-col">
|
||||
<table id="flash_props" border="0" cellspacing="0" cellpadding="0"></table>
|
||||
</td>
|
||||
<td class="info-col">
|
||||
<div id="flash_events"></div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,70 @@
|
||||
_V_.options.flash.swf = "../flash/video-js.swf";
|
||||
_V_.options.flash.swf = "http://andylemay.com/dev/videojs/VideoJS.swf";
|
||||
|
||||
$(function(){
|
||||
var tech, i, tname, player,
|
||||
techList = ["html5","flash"],
|
||||
props = "error,currentSrc,networkState,buffered,readyState,seeking,initialTime,duration,startOffsetTime,paused,played,seekable,ended,videoWidth,videoHeight,textTracks,preload,currentTime,defaultPlaybackRate,playbackRate,autoplay,loop,controls,volume,muted,defaultMuted,poster".split(","),
|
||||
methods = "play,pause,src,load,canPlayType,addTextTrack",
|
||||
notUsed = "mediaGroup,controller,videoTracks,audioTracks,defaultPlaybackRate";
|
||||
|
||||
for (i=0; i < techList.length; i++) {
|
||||
tech = techList[i];
|
||||
tname = tech.toLowerCase();
|
||||
|
||||
player = _V_("vid"+(i+1), { "techOrder":[tech] });
|
||||
|
||||
_V_.each(_V_.html5.events, function(evt){
|
||||
|
||||
player.addEvent(evt, _V_.proxy(tname, function(evt){
|
||||
var eventsId = "#"+this+"_events",
|
||||
type = evt.type,
|
||||
prev = $(eventsId+" div").first();
|
||||
|
||||
if (prev && prev.html() && prev.html().indexOf(type + " ") === 0) {
|
||||
var countSpan = prev.children(".count");
|
||||
countSpan.html(parseInt(countSpan.html() || 1) + 1);
|
||||
} else {
|
||||
$("#"+this+"_events").prepend("<div>" + evt.type + " <span class='count'></span></div>");
|
||||
}
|
||||
}));
|
||||
});
|
||||
|
||||
var propTable = $("#"+tname+"_props");
|
||||
_V_.each(props, function(prop){
|
||||
propTable.append("<tr><th>"+prop+"</th><td id='"+tname+prop+"' class='data'></td></tr>")
|
||||
});
|
||||
|
||||
setInterval(_V_.proxy(player, function(){
|
||||
_V_.each(props, _V_.proxy(this, function(prop){
|
||||
var result = ""
|
||||
try {
|
||||
result = this[prop]();
|
||||
if (result === false) result = "false";
|
||||
if (result === true) result = "true";
|
||||
if (result === "") result = "''";
|
||||
if (result === null) result = "<span class='undefined'>null</span>";
|
||||
if (result === undefined) result = "<span class='undefined'>undefined</span>";
|
||||
if (typeof result.start == "function") {
|
||||
var newResult = "", i;
|
||||
if (result.length > 0) {
|
||||
|
||||
for (i=0;i<result.length;i++) {
|
||||
newResult += "l:"+result.length+" s:"+result.start(i)+" e:"+result.end(i);
|
||||
}
|
||||
} else {
|
||||
newResult = "-";
|
||||
}
|
||||
result = newResult;
|
||||
// result = result.toString();
|
||||
// result = (result.length > 0) ? "s:"+result.start(0)+" e:"+result.end(0) : "-";
|
||||
}
|
||||
} catch(e) {
|
||||
result = "<span class='na'>N/A</span>";
|
||||
}
|
||||
$("#"+this.techName+prop).html(result);
|
||||
}));
|
||||
}), 500);
|
||||
|
||||
};
|
||||
});
|
||||
@@ -0,0 +1,8 @@
|
||||
Tracking/Polling CurrentTime Manually
|
||||
-------------------------------------
|
||||
- Necessary for most flash players and browsers that don't trigger timeupdate events.
|
||||
- In VJS 1-2, we always tracked time because timeupdate was rare.
|
||||
- Now most browsers support it well. There is a delay bug in the current Chrome.
|
||||
http://code.google.com/p/chromium/issues/detail?id=92251
|
||||
Andrew from Chrome told me it would be fix in an upcoming release.
|
||||
Going to rely on browsers timeupdates when available now.
|
||||
Arquivo executável → Arquivo normal
+5
-5
@@ -1,13 +1,13 @@
|
||||
1
|
||||
00:00:02,400 --> 00:00:05,200
|
||||
00:00:00,000 --> 00:00:07,200
|
||||
[Background Music Playing]
|
||||
|
||||
2
|
||||
00:00:15,712 --> 00:00:17,399
|
||||
Heay!!
|
||||
00:00:16,000 --> 00:00:17,200
|
||||
Welcome to this week's episode
|
||||
|
||||
3
|
||||
00:00:25,712 --> 00:00:30,399
|
||||
[Bird noises]
|
||||
00:00:17,400 --> 00:00:19,000
|
||||
of explore California
|
||||
|
||||
|
||||
|
||||
-102
@@ -1,102 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>HTML5 Video Player</title>
|
||||
|
||||
<!-- Include the VideoJS Library -->
|
||||
<script src="video.js" type="text/javascript" charset="utf-8"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
// Must come after the video.js library
|
||||
|
||||
// Add VideoJS to all video tags on the page when the DOM is ready
|
||||
VideoJS.setupAllWhenReady();
|
||||
|
||||
/* ============= OR ============ */
|
||||
|
||||
// Setup and store a reference to the player(s).
|
||||
// Must happen after the DOM is loaded
|
||||
// You can use any library's DOM Ready method instead of VideoJS.DOMReady
|
||||
|
||||
/*
|
||||
VideoJS.DOMReady(function(){
|
||||
|
||||
// Using the video's ID or element
|
||||
var myPlayer = VideoJS.setup("example_video_1");
|
||||
|
||||
// OR using an array of video elements/IDs
|
||||
// Note: It returns an array of players
|
||||
var myManyPlayers = VideoJS.setup(["example_video_1", "example_video_2", video3Element]);
|
||||
|
||||
// OR all videos on the page
|
||||
var myManyPlayers = VideoJS.setup("All");
|
||||
|
||||
// After you have references to your players you can...(example)
|
||||
myPlayer.play(); // Starts playing the video for this player.
|
||||
});
|
||||
*/
|
||||
|
||||
/* ========= SETTING OPTIONS ========= */
|
||||
|
||||
// Set options when setting up the videos. The defaults are shown here.
|
||||
|
||||
/*
|
||||
VideoJS.setupAllWhenReady({
|
||||
controlsBelow: false, // Display control bar below video instead of in front of
|
||||
controlsHiding: true, // Hide controls when mouse is not over the video
|
||||
defaultVolume: 0.85, // Will be overridden by user's last volume if available
|
||||
flashVersion: 9, // Required flash version for fallback
|
||||
linksHiding: true // Hide download links when video is supported
|
||||
});
|
||||
*/
|
||||
|
||||
// Or as the second option of VideoJS.setup
|
||||
|
||||
/*
|
||||
VideoJS.DOMReady(function(){
|
||||
var myPlayer = VideoJS.setup("example_video_1", {
|
||||
// Same options
|
||||
});
|
||||
});
|
||||
*/
|
||||
|
||||
</script>
|
||||
|
||||
<!-- Include the VideoJS Stylesheet -->
|
||||
<link rel="stylesheet" href="video-js.css" type="text/css" media="screen" title="Video JS">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<!-- Begin VideoJS -->
|
||||
<div class="video-js-box">
|
||||
<!-- Using the Video for Everybody Embed Code http://camendesign.com/code/video_for_everybody -->
|
||||
<video id="example_video_1" class="video-js" width="640" height="264" controls="controls" preload="auto" poster="http://video-js.zencoder.com/oceans-clip.png">
|
||||
<source src="http://video-js.zencoder.com/oceans-clip.mp4" type='video/mp4; codecs="avc1.42E01E, mp4a.40.2"' />
|
||||
<source src="http://video-js.zencoder.com/oceans-clip.webm" type='video/webm; codecs="vp8, vorbis"' />
|
||||
<source src="http://video-js.zencoder.com/oceans-clip.ogv" type='video/ogg; codecs="theora, vorbis"' />
|
||||
<!-- Flash Fallback. Use any flash video player here. Make sure to keep the vjs-flash-fallback class. -->
|
||||
<object id="flash_fallback_1" class="vjs-flash-fallback" width="640" height="264" type="application/x-shockwave-flash"
|
||||
data="http://releases.flowplayer.org/swf/flowplayer-3.2.1.swf">
|
||||
<param name="movie" value="http://releases.flowplayer.org/swf/flowplayer-3.2.1.swf" />
|
||||
<param name="wmode" value="opaque" />
|
||||
<param name="allowfullscreen" value="true" />
|
||||
<param name="flashvars" value='config={"playlist":["http://video-js.zencoder.com/oceans-clip.png", {"url": "http://video-js.zencoder.com/oceans-clip.mp4","autoPlay":false,"autoBuffering":true}]}' />
|
||||
<!-- Image Fallback. Typically the same as the poster image. -->
|
||||
<img src="http://video-js.zencoder.com/oceans-clip.png" width="640" height="264" alt="Poster Image"
|
||||
title="No video playback capabilities." />
|
||||
</object>
|
||||
</video>
|
||||
<!-- Download links provided for devices that can't play video in the browser. -->
|
||||
<p class="vjs-no-video"><strong>Download Video:</strong>
|
||||
<a href="http://video-js.zencoder.com/oceans-clip.mp4">MP4</a>,
|
||||
<a href="http://video-js.zencoder.com/oceans-clip.webm">WebM</a>,
|
||||
<a href="http://video-js.zencoder.com/oceans-clip.ogv">Ogg</a><br>
|
||||
<!-- Support VideoJS by keeping this link. -->
|
||||
<a href="http://videojs.com">HTML5 Video Player</a> by VideoJS
|
||||
</p>
|
||||
</div>
|
||||
<!-- End VideoJS -->
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Arquivo binário não exibido.
|
Depois Largura: | Altura: | Tamanho: 85 KiB |
Arquivo binário não exibido.
|
Depois Largura: | Altura: | Tamanho: 3.5 KiB |
@@ -0,0 +1,190 @@
|
||||
/* DEFAULT SKIN (override in another file)
|
||||
================================================================================
|
||||
Using all CSS to draw the controls. Images could be used if desired.
|
||||
Instead of editing this file, I recommend creating your own skin CSS file to be included after this file,
|
||||
so you can upgrade to newer versions easier. */
|
||||
|
||||
.vjs-original-skin .vjs-controls {
|
||||
position: absolute; margin: 0; opacity: 0.85; color: #fff;
|
||||
display: block; /* Start hidden */
|
||||
left: 0; right: 0; /* 100% width of video-js-box */
|
||||
width: 100%;
|
||||
bottom: 0px; /* Distance from the bottom of the box/video. Keep 0. Use height to add more bottom margin. */
|
||||
height: 35px; /* Including any margin you want above or below control items */
|
||||
padding: 0; /* Controls are absolutely position, so no padding necessary */
|
||||
-webkit-transition: opacity 0.5s linear;
|
||||
-moz-transition: opacity 0.5s linear;
|
||||
-o-transition: opacity 0.5s linear;
|
||||
-ms-transition: opacity 0.5s linear;
|
||||
transition: opacity 0.5s linear;
|
||||
}
|
||||
|
||||
.vjs-original-skin .vjs-control {
|
||||
position: absolute; /* Use top, bottom, left, and right to specifically position the control. */
|
||||
text-align: center; margin: 0; padding: 0;
|
||||
height: 25px; /* Default height of individual controls */
|
||||
top: 5px; /* Top margin to put space between video and controls when controls are below */
|
||||
|
||||
/* CSS Background Gradients
|
||||
Using to give the aqua-ish look. */
|
||||
/* Default */ background-color: #0B151A;
|
||||
/* Webkit */ background: #1F3744 -webkit-gradient(linear, left top, left bottom, from(#0B151A), to(#1F3744)) left 12px;
|
||||
/* Firefox */ background: #1F3744 -moz-linear-gradient(top, #0B151A, #1F3744) left 12px;
|
||||
|
||||
/* CSS Curved Corners */
|
||||
-webkit-border-radius: 5px; -moz-border-radius: 5px; border-radius: 5px;
|
||||
|
||||
/* CSS Shadows */
|
||||
-webkit-box-shadow: 1px 1px 2px #000; -moz-box-shadow: 1px 1px 2px #000; box-shadow: 1px 1px 2px #000;
|
||||
}
|
||||
|
||||
/* Placement of Control Items
|
||||
- Left side of pogress bar, use left & width
|
||||
- Rigth side of progress bar, use right & width
|
||||
- Expand with the video (like progress bar) use left & right
|
||||
(using div.x to make more specific than vjs-control style)
|
||||
*/
|
||||
.vjs-original-skin div.vjs-play-control { left: 5px; width: 25px; }
|
||||
.vjs-original-skin div.vjs-progress-control { left: 35px; right: 165px; } /* Using left & right so it expands with the width of the video */
|
||||
.vjs-original-skin div.vjs-time-control { width: 75px; right: 90px; } /* Time control and progress bar are combined to look like one */
|
||||
.vjs-original-skin div.vjs-volume-control { width: 50px; right: 35px; }
|
||||
.vjs-original-skin div.vjs-fullscreen-control { width: 25px; right: 5px; }
|
||||
|
||||
/* Removing curved corners on progress control and time control to join them. */
|
||||
.vjs-original-skin div.vjs-progress-control {
|
||||
-webkit-border-top-right-radius: 0; -moz-border-radius-topright: 0; border-top-right-radius: 0;
|
||||
-webkit-border-bottom-right-radius: 0; -moz-border-radius-bottomright: 0; border-bottom-right-radius: 0;
|
||||
}
|
||||
.vjs-original-skin div.vjs-time-control {
|
||||
-webkit-border-top-left-radius: 0; -moz-border-radius-topleft: 0; border-top-left-radius: 0;
|
||||
-webkit-border-bottom-left-radius: 0; -moz-border-radius-bottomleft: 0; border-bottom-left-radius: 0;
|
||||
}
|
||||
|
||||
/* Play/Pause
|
||||
-------------------------------------------------------------------------------- */
|
||||
.vjs-original-skin .vjs-play-control { cursor: pointer !important; }
|
||||
/* Play Icon */
|
||||
.vjs-original-skin .vjs-play-control span { display: block; font-size: 0; line-height: 0; }
|
||||
.vjs-original-skin.vjs-paused .vjs-play-control span {
|
||||
width: 0; height: 0; margin: 8px 0 0 8px;
|
||||
/* Drawing the play triangle with borders - http://www.infimum.dk/HTML/slantinfo.html */
|
||||
border-left: 10px solid #fff; /* Width & Color of play icon */
|
||||
/* Height of play icon is total top & bottom border widths. Color is transparent. */
|
||||
border-top: 5px solid rgba(0,0,0,0); border-bottom: 5px solid rgba(0,0,0,0);
|
||||
}
|
||||
.vjs-original-skin.vjs-playing .vjs-play-control span {
|
||||
width: 3px; height: 10px; margin: 8px auto 0;
|
||||
/* Drawing the pause bars with borders */
|
||||
border-top: 0px; border-left: 3px solid #fff; border-bottom: 0px; border-right: 3px solid #fff;
|
||||
}
|
||||
|
||||
/* Progress
|
||||
-------------------------------------------------------------------------------- */
|
||||
.vjs-original-skin .vjs-progress-holder { /* Box containing play and load progresses */
|
||||
position: relative; padding: 0; overflow:hidden; cursor: pointer !important;
|
||||
height: 9px; border: 1px solid #777;
|
||||
margin: 7px 1px 0 5px; /* Placement within the progress control item */
|
||||
-webkit-border-radius: 5px; -moz-border-radius: 5px; border-radius: 5px;
|
||||
}
|
||||
.vjs-original-skin .vjs-progress-holder div { /* Progress Bars */
|
||||
position: absolute; display: block; width: 0; height: 9px; margin: 0; padding: 0;
|
||||
left: 0; top: 0; /*Needed for IE6*/
|
||||
-webkit-border-radius: 5px; -moz-border-radius: 5px; border-radius: 5px;
|
||||
}
|
||||
.vjs-original-skin .vjs-play-progress {
|
||||
/* CSS Gradient */
|
||||
/* Default */ background: #fff;
|
||||
/* Webkit */ background: -webkit-gradient(linear, left top, left bottom, from(#fff), to(#777));
|
||||
/* Firefox */ background: -moz-linear-gradient(top, #fff, #777);
|
||||
}
|
||||
.vjs-original-skin .vjs-load-progress {
|
||||
opacity: 0.8;
|
||||
/* CSS Gradient */
|
||||
/* Default */ background-color: #555;
|
||||
/* Webkit */ background: -webkit-gradient(linear, left top, left bottom, from(#555), to(#aaa));
|
||||
/* Firefox */ background: -moz-linear-gradient(top, #555, #aaa);
|
||||
}
|
||||
|
||||
/* Time Display
|
||||
-------------------------------------------------------------------------------- */
|
||||
.vjs-original-skin .vjs-time-control { font-size: 10px; line-height: 1; font-weight: normal; font-family: Helvetica, Arial, sans-serif; }
|
||||
.vjs-original-skin .vjs-time-control span { line-height: 25px; /* Centering vertically */ }
|
||||
|
||||
/* Volume
|
||||
-------------------------------------------------------------------------------- */
|
||||
.vjs-original-skin .vjs-volume-control { cursor: pointer !important; }
|
||||
.vjs-original-skin .vjs-volume-control div { display: block; margin: 0 5px 0 5px; padding: 4px 0 0 0; }
|
||||
/* Drawing the volume icon using 6 span elements */
|
||||
.vjs-original-skin .vjs-volume-control div span { /* Individual volume bars */
|
||||
float: left; padding: 0; font-size: 0; line-height: 0;
|
||||
margin: 0 2px 0 0; /* Space between */
|
||||
width: 5px; height: 0px; /* Total height is height + bottom border */
|
||||
border-bottom: 18px solid #555; /* Default (off) color and height of visible portion */
|
||||
}
|
||||
.vjs-original-skin .vjs-volume-control div span.vjs-volume-level-on { border-color: #fff; /* Volume on bar color */ }
|
||||
/* Creating differnt bar heights through height (transparent) and bottom border (visible). */
|
||||
.vjs-original-skin .vjs-volume-control div span.vjs-vc-1 { border-bottom-width: 2px; height: 16px; }
|
||||
.vjs-original-skin .vjs-volume-control div span.vjs-vc-2 { border-bottom-width: 4px; height: 14px; }
|
||||
.vjs-original-skin .vjs-volume-control div span.vjs-vc-3 { border-bottom-width: 7px; height: 11px; }
|
||||
.vjs-original-skin .vjs-volume-control div span.vjs-vc-4 { border-bottom-width: 10px; height: 8px; }
|
||||
.vjs-original-skin .vjs-volume-control div span.vjs-vc-5 { border-bottom-width: 14px; height: 4px; }
|
||||
.vjs-original-skin .vjs-volume-control div span.vjs-vc-6 { margin-right: 0; }
|
||||
|
||||
/* Fullscreen
|
||||
-------------------------------------------------------------------------------- */
|
||||
.vjs-original-skin .vjs-fullscreen-control { cursor: pointer !important; }
|
||||
.vjs-original-skin .vjs-fullscreen-control div {
|
||||
padding: 0; text-align: left; vertical-align: top; cursor: pointer !important;
|
||||
margin: 5px 0 0 5px; /* Placement within the fullscreen control item */
|
||||
width: 20px; height: 20px;
|
||||
}
|
||||
/* Drawing the fullscreen icon using 4 span elements */
|
||||
.vjs-original-skin .vjs-fullscreen-control div span { float: left; margin: 0; padding: 0; font-size: 0; line-height: 0; width: 0; text-align: left; vertical-align: top; }
|
||||
.vjs-original-skin .vjs-fullscreen-control div span.vjs-fc-1 { /* Top-left triangle */
|
||||
margin-right: 3px; /* Space between top-left and top-right */
|
||||
margin-bottom: 3px; /* Space between top-left and bottom-left */
|
||||
border-top: 6px solid #fff; /* Height and color */
|
||||
border-right: 6px solid rgba(0,0,0,0); /* Width */
|
||||
}
|
||||
.vjs-original-skin .vjs-fullscreen-control div span.vjs-fc-2 { border-top: 6px solid #fff; border-left: 6px solid rgba(0,0,0,0); }
|
||||
.vjs-original-skin .vjs-fullscreen-control div span.vjs-fc-3 { clear: both; margin: 0 3px 0 0; border-bottom: 6px solid #fff; border-right: 6px solid rgba(0,0,0,0); }
|
||||
.vjs-original-skin .vjs-fullscreen-control div span.vjs-fc-4 { border-bottom: 6px solid #fff; border-left: 6px solid rgba(0,0,0,0); }
|
||||
/* Icon when video is in fullscreen mode */
|
||||
.vjs-original-skin.vjs-fullscreen .vjs-fullscreen-control div span.vjs-fc-1 { border: none; border-bottom: 6px solid #fff; border-left: 6px solid rgba(0,0,0,0); }
|
||||
.vjs-original-skin.vjs-fullscreen .vjs-fullscreen-control div span.vjs-fc-2 { border: none; border-bottom: 6px solid #fff; border-right: 6px solid rgba(0,0,0,0); }
|
||||
.vjs-original-skin.vjs-fullscreen .vjs-fullscreen-control div span.vjs-fc-3 { border: none; border-top: 6px solid #fff; border-left: 6px solid rgba(0,0,0,0); }
|
||||
.vjs-original-skin.vjs-fullscreen .vjs-fullscreen-control div span.vjs-fc-4 { border: none; border-top: 6px solid #fff; border-right: 6px solid rgba(0,0,0,0); }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* Big Play Button (at start)
|
||||
---------------------------------------------------------*/
|
||||
.vjs-original-skin .vjs-big-play-button {
|
||||
display: block; /* Start hidden */ z-index: 2;
|
||||
position: absolute; top: 50%; left: 50%; width: 80px; height: 80px; margin: -43px 0 0 -43px; text-align: center; vertical-align: center; cursor: pointer !important;
|
||||
border: 3px solid #fff; opacity: 0.9;
|
||||
-webkit-border-radius: 20px; -moz-border-radius: 20px; border-radius: 20px;
|
||||
|
||||
/* CSS Background Gradients */
|
||||
/* Default */ background-color: #0B151A;
|
||||
/* Webkit */ background: #1F3744 -webkit-gradient(linear, left top, left bottom, from(#0B151A), to(#1F3744)) left 40px;
|
||||
/* Firefox */ background: #1F3744 -moz-linear-gradient(top, #0B151A, #1F3744) left 40px;
|
||||
|
||||
/* CSS Shadows */
|
||||
-webkit-box-shadow: 4px 4px 8px #000; -moz-box-shadow: 4px 4px 8px #000; box-shadow: 4px 4px 8px #000;
|
||||
}
|
||||
|
||||
.vjs-original-skin div.vjs-big-play-button:hover {
|
||||
-webkit-box-shadow: 0px 0px 80px #fff; -moz-box-shadow: 0px 0px 80px #fff; box-shadow: 0px 0px 80px #fff;
|
||||
}
|
||||
|
||||
.vjs-original-skin div.vjs-big-play-button span {
|
||||
display: block; font-size: 0; line-height: 0;
|
||||
width: 0; height: 0; margin: 20px 0 0 23px;
|
||||
/* Drawing the play triangle with borders - http://www.infimum.dk/HTML/slantinfo.html */
|
||||
border-left: 40px solid #fff; /* Width & Color of play icon */
|
||||
/* Height of play icon is total top & bottom border widths. Color is transparent. */
|
||||
border-top: 20px solid rgba(0,0,0,0); border-bottom: 20px solid rgba(0,0,0,0);
|
||||
}
|
||||
@@ -0,0 +1,405 @@
|
||||
/*
|
||||
VideoJS Default Styles (http://videojs.com)
|
||||
Version 3.0
|
||||
|
||||
REQUIRED STYLES (be careful overriding)
|
||||
================================================================================ */
|
||||
/* When loading the player, the video tag is replaced with a DIV,
|
||||
that will hold the video tag or object tag for other playback methods.
|
||||
The div contains the video playback element (Flash or HTML5) and controls, and sets the width and height of the video.
|
||||
|
||||
** If you want to add some kind of border/padding (e.g. a frame), or special positioning, use another containing element.
|
||||
Otherwise you risk messing up control positioning and full window mode. **
|
||||
*/
|
||||
.video-js {
|
||||
background-color: #000; position: relative; padding: 0;
|
||||
|
||||
/* Start with 10px for base font size so other dimensions can be em based and easily calculable. */
|
||||
font-size: 10px;
|
||||
|
||||
/* Allow poster to be vertially aligned. */
|
||||
vertical-align: middle;
|
||||
/* display: table-cell; */ /*This works in Safari but not Firefox.*/
|
||||
}
|
||||
|
||||
/* Playback technology elements expand to the width/height of the containing div. <video> or <object> */
|
||||
.video-js .vjs-tech { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }
|
||||
|
||||
/* Fullscreen Styles */
|
||||
body.vjs-full-window {
|
||||
padding: 0; margin: 0;
|
||||
height: 100%; overflow-y: auto; /* Fix for IE6 full-window. http://www.cssplay.co.uk/layouts/fixed.html */
|
||||
}
|
||||
.video-js.vjs-fullscreen {
|
||||
position: fixed; overflow: hidden; z-index: 1000; left: 0; top: 0; bottom: 0; right: 0; width: 100% !important; height: 100% !important;
|
||||
_position: absolute; /* IE6 Full-window (underscore hack) */
|
||||
}
|
||||
.video-js:-webkit-full-screen {
|
||||
width: 100% !important; height: 100% !important;
|
||||
}
|
||||
|
||||
/* Poster Styles */
|
||||
.vjs-poster {
|
||||
margin: 0 auto; padding: 0; cursor: pointer;
|
||||
|
||||
/* Scale with the size of the player div. Works when poster is vertically shorter, but stretches when it's less wide. */
|
||||
position: relative; width: 100%; max-height: 100%;
|
||||
}
|
||||
|
||||
|
||||
/* Subtiles Styles */
|
||||
.video-js .vjs-subtitles { color: #fff; font-size: 20px; text-align: center; position: absolute; bottom: 40px; left: 0; right: 0; }
|
||||
|
||||
/* DEFAULT SKIN (override in another file to create new skins)
|
||||
================================================================================
|
||||
Instead of editing this file, I recommend creating your own skin CSS file to be included after this file,
|
||||
so you can upgrade to newer versions easier. You can remove all these styles by removing the 'vjs-default-skin' class from the tag. */
|
||||
|
||||
/* The default control bar. Created by bar.js */
|
||||
.vjs-default-skin .vjs-controls {
|
||||
position: absolute;
|
||||
bottom: 0; /* Distance from the bottom of the box/video. Keep 0. Use height to add more bottom margin. */
|
||||
left: 0; right: 0; /* 100% width of div */
|
||||
opacity: 0.85;
|
||||
display: none; /* Start hidden */
|
||||
margin: 0; padding: 0; /* Controls are absolutely position, so no padding necessary */
|
||||
height: 2.6em; /* Including any margin you want above or below control items */
|
||||
color: #fff; border-top: 1px solid #404040;
|
||||
|
||||
/* CSS Gradient */
|
||||
/* Can use the Ultimate CSS Gradient Generator: http://www.colorzilla.com/gradient-editor/ */
|
||||
background: #242424; /* Old browsers */
|
||||
background: -moz-linear-gradient(top, #242424 50%, #1f1f1f 50%, #171717 100%); /* FF3.6+ */
|
||||
background: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(50%,#242424), color-stop(50%,#1f1f1f), color-stop(100%,#171717)); /* Chrome,Safari4+ */
|
||||
background: -webkit-linear-gradient(top, #242424 50%,#1f1f1f 50%,#171717 100%); /* Chrome10+,Safari5.1+ */
|
||||
background: -o-linear-gradient(top, #242424 50%,#1f1f1f 50%,#171717 100%); /* Opera11.10+ */
|
||||
background: -ms-linear-gradient(top, #242424 50%,#1f1f1f 50%,#171717 100%); /* IE10+ */
|
||||
/* Filter was causing a lot of weird issues in IE. Elements would stop showing up, or other styles would break. */
|
||||
/*filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#242424', endColorstr='#171717',GradientType=0 );*/ /* IE6-9 */
|
||||
background: linear-gradient(top, #242424 50%,#1f1f1f 50%,#171717 100%); /* W3C */
|
||||
|
||||
/* Fade-in using CSS Transitions */
|
||||
-webkit-transition: opacity 0.3s linear;
|
||||
-moz-transition: opacity 0.3s linear;
|
||||
-o-transition: opacity 0.3s linear;
|
||||
-ms-transition: opacity 0.3s linear;
|
||||
transition: opacity 0.3s linear;
|
||||
}
|
||||
|
||||
/* General styles for individual controls. */
|
||||
.vjs-default-skin .vjs-control {
|
||||
position: relative; float: left;
|
||||
text-align: center; margin: 0; padding: 0;
|
||||
height: 2.6em; width: 2.6em;
|
||||
}
|
||||
|
||||
.vjs-default-skin .vjs-control:focus {
|
||||
outline: 0;
|
||||
}
|
||||
|
||||
/* Hide control text visually, but have it available for screenreaders: h5bp.com/v */
|
||||
.vjs-default-skin .vjs-control-text { border: 0; clip: rect(0 0 0 0); height: 1px; margin: -1px; overflow: hidden; padding: 0; position: absolute; width: 1px; }
|
||||
|
||||
|
||||
/* Play/Pause
|
||||
-------------------------------------------------------------------------------- */
|
||||
.vjs-default-skin .vjs-play-control { width: 5em; cursor: pointer !important; }
|
||||
/* Play Icon */
|
||||
.vjs-default-skin.vjs-paused .vjs-play-control div { width: 15px; height: 17px; background: url('video-js.png'); margin: 0.5em auto 0; }
|
||||
.vjs-default-skin.vjs-playing .vjs-play-control div { width: 15px; height: 17px; background: url('video-js.png') -25px 0; margin: 0.5em auto 0; }
|
||||
|
||||
/* Rewind
|
||||
-------------------------------------------------------------------------------- */
|
||||
.vjs-default-skin .vjs-rewind-control { width: 5em; cursor: pointer !important; }
|
||||
.vjs-default-skin .vjs-rewind-control div { width: 19px; height: 16px; background: url('video-js.png'); margin: 0.5em auto 0; }
|
||||
|
||||
/* Volume/Mute
|
||||
-------------------------------------------------------------------------------- */
|
||||
.vjs-default-skin .vjs-mute-control { width: 3.8em; cursor: pointer !important; float: right; }
|
||||
.vjs-default-skin .vjs-mute-control div { width: 22px; height: 16px; background: url('video-js.png') -75px -25px; margin: 0.5em auto 0; }
|
||||
.vjs-default-skin .vjs-mute-control.vjs-vol-0 div { background: url('video-js.png') 0 -25px; }
|
||||
.vjs-default-skin .vjs-mute-control.vjs-vol-1 div { background: url('video-js.png') -25px -25px; }
|
||||
.vjs-default-skin .vjs-mute-control.vjs-vol-2 div { background: url('video-js.png') -50px -25px; }
|
||||
|
||||
|
||||
.vjs-default-skin .vjs-volume-control { width: 5em; float: right; }
|
||||
.vjs-default-skin .vjs-volume-bar {
|
||||
position: relative; width: 5em; height: 0.6em; margin: 1em auto 0; cursor: pointer !important;
|
||||
|
||||
-moz-border-radius: 0.3em; -webkit-border-radius: 0.3em; border-radius: 0.3em;
|
||||
|
||||
background: #666;
|
||||
background: -moz-linear-gradient(top, #333, #666);
|
||||
background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#333), to(#666));
|
||||
background: -webkit-linear-gradient(top, #333, #666);
|
||||
background: -o-linear-gradient(top, #333, #666);
|
||||
background: -ms-linear-gradient(top, #333, #666);
|
||||
background: linear-gradient(top, #333, #666);
|
||||
}
|
||||
.vjs-default-skin .vjs-volume-level {
|
||||
position: absolute; top: 0; left: 0; height: 0.6em;
|
||||
|
||||
-moz-border-radius: 0.3em; -webkit-border-radius: 0.3em; border-radius: 0.3em;
|
||||
|
||||
background: #fff;
|
||||
background: -moz-linear-gradient(top, #fff, #ccc);
|
||||
background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#fff), to(#ccc));
|
||||
background: -webkit-linear-gradient(top, #fff, #ccc);
|
||||
background: -o-linear-gradient(top, #fff, #ccc);
|
||||
background: -ms-linear-gradient(top, #fff, #ccc);
|
||||
background: linear-gradient(top, #fff, #ccc);
|
||||
}
|
||||
.vjs-default-skin .vjs-volume-handle {
|
||||
position: absolute; top: -0.2em; width: 0.8em; height: 0.8em; background: #ccc; left: 0;
|
||||
border: 1px solid #fff;
|
||||
-moz-border-radius: 0.6em; -webkit-border-radius: 0.6em; border-radius: 0.6em;
|
||||
}
|
||||
|
||||
/* Progress
|
||||
-------------------------------------------------------------------------------- */
|
||||
.vjs-default-skin div.vjs-progress-control {
|
||||
position: absolute;
|
||||
left: 4.8em; right: 4.8em; /* Leave room for time displays. */
|
||||
height: 1.0em; width: auto;
|
||||
top: -1.3em; /* Set above the rest of the controls. And leave room for 2px of borders (progress bottom and controls top). */
|
||||
border-bottom: 1px solid #1F1F1F;
|
||||
border-top: 1px solid #222;
|
||||
|
||||
/* CSS Gradient */
|
||||
background: #333;
|
||||
background: -moz-linear-gradient(top, #222, #333);
|
||||
background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#222), to(#333));
|
||||
background: -webkit-linear-gradient(top, #222, #333);
|
||||
background: -o-linear-gradient(top, #333, #222);
|
||||
background: -ms-linear-gradient(top, #333, #222);
|
||||
background: linear-gradient(top, #333, #222);
|
||||
|
||||
|
||||
/* 1px top shadow */
|
||||
/* -webkit-box-shadow: 0px -1px 0px 0px rgba(0, 0, 0, 0.15); -moz-box-shadow: 0px -1px 0px 0px rgba(0, 0, 0, 0.15); box-shadow: 0px -1px 0px 0px rgba(0, 0, 0, 0.15);*/
|
||||
}
|
||||
|
||||
/* Box containing play and load progresses. Also acts as seek scrubber. */
|
||||
.vjs-default-skin .vjs-progress-holder {
|
||||
position: relative; cursor: pointer !important; /*overflow: hidden;*/
|
||||
padding: 0; margin: 0; /* Placement within the progress control item */
|
||||
height: 1.0em;
|
||||
-moz-border-radius: 0.6em; -webkit-border-radius: 0.6em; border-radius: 0.6em;
|
||||
|
||||
/* CSS Gradient */
|
||||
background: #111;
|
||||
background: -moz-linear-gradient(top, #111, #262626);
|
||||
background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#111), to(#262626));
|
||||
background: -webkit-linear-gradient(top, #111, #262626);
|
||||
background: -o-linear-gradient(top, #111, #262626);
|
||||
background: -ms-linear-gradient(top, #111, #262626);
|
||||
background: linear-gradient(top, #111, #262626);
|
||||
}
|
||||
.vjs-default-skin .vjs-progress-holder .vjs-play-progress,
|
||||
.vjs-default-skin .vjs-progress-holder .vjs-load-progress { /* Progress Bars */
|
||||
position: absolute; display: block; height: 1.0em; margin: 0; padding: 0;
|
||||
left: 0; top: 0; /*Needed for IE6*/
|
||||
-moz-border-radius: 0.6em; -webkit-border-radius: 0.6em; border-radius: 0.6em;
|
||||
|
||||
/*width: 0;*/
|
||||
}
|
||||
|
||||
.vjs-default-skin .vjs-play-progress {
|
||||
/* CSS Gradient. */
|
||||
background: #fff; /* Old browsers */
|
||||
background: -moz-linear-gradient(top, #fff 0%, #d6d6d6 50%, #fff 100%);
|
||||
background: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(0%,#fff), color-stop(50%,#d6d6d6), color-stop(100%,#fff));
|
||||
background: -webkit-linear-gradient(top, #fff 0%,#d6d6d6 50%,#fff 100%);
|
||||
background: -o-linear-gradient(top, #fff 0%,#d6d6d6 50%,#fff 100%);
|
||||
background: -ms-linear-gradient(top, #fff 0%,#d6d6d6 50%,#fff 100%);
|
||||
background: linear-gradient(top, #fff 0%,#d6d6d6 50%,#fff 100%);
|
||||
|
||||
background: #efefef;
|
||||
background: -moz-linear-gradient(top, #efefef 0%, #f5f5f5 50%, #dbdbdb 50%, #f1f1f1 100%);
|
||||
background: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(0%,#efefef), color-stop(50%,#f5f5f5), color-stop(50%,#dbdbdb), color-stop(100%,#f1f1f1));
|
||||
background: -webkit-linear-gradient(top, #efefef 0%,#f5f5f5 50%,#dbdbdb 50%,#f1f1f1 100%);
|
||||
background: -o-linear-gradient(top, #efefef 0%,#f5f5f5 50%,#dbdbdb 50%,#f1f1f1 100%);
|
||||
background: -ms-linear-gradient(top, #efefef 0%,#f5f5f5 50%,#dbdbdb 50%,#f1f1f1 100%);
|
||||
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#efefef', endColorstr='#f1f1f1',GradientType=0 );
|
||||
background: linear-gradient(top, #efefef 0%,#f5f5f5 50%,#dbdbdb 50%,#f1f1f1 100%);
|
||||
}
|
||||
.vjs-default-skin .vjs-load-progress {
|
||||
opacity: 0.8;
|
||||
|
||||
/* CSS Gradient */
|
||||
background: #666;
|
||||
background: -moz-linear-gradient(top, #666, #333);
|
||||
background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#666), to(#333));
|
||||
background: -webkit-linear-gradient(top, #666, #333);
|
||||
background: -o-linear-gradient(top, #666, #333);
|
||||
background: -ms-linear-gradient(top, #666, #333);
|
||||
background: linear-gradient(top, #666, #333);
|
||||
}
|
||||
|
||||
.vjs-default-skin div.vjs-seek-handle {
|
||||
position: absolute;
|
||||
width: 16px; height: 16px; /* Match img pixles */
|
||||
margin-top: -0.3em;
|
||||
left: 0; top: 0; /*Needed for IE6*/
|
||||
|
||||
background: url('video-js.png') 0 -50px;
|
||||
/* CSS Curved Corners. Needed to make shadows curved. */
|
||||
-moz-border-radius: 0.8em; -webkit-border-radius: 0.8em; border-radius: 0.8em;
|
||||
/* CSS Shadows */
|
||||
-webkit-box-shadow: 0 2px 4px 0 #000; -moz-box-shadow: 0 2px 4px 0 #000; box-shadow: 0 2px 4px 0 #000;
|
||||
}
|
||||
/* Time Display
|
||||
-------------------------------------------------------------------------------- */
|
||||
.vjs-default-skin .vjs-time-controls {
|
||||
position: absolute;
|
||||
right: 0;
|
||||
height: 1.0em; width: 4.8em;
|
||||
top: -1.3em;
|
||||
border-bottom: 1px solid #1F1F1F;
|
||||
border-top: 1px solid #222;
|
||||
background-color: #333;
|
||||
|
||||
font-size: 1em; line-height: 1.0em; font-weight: normal; font-family: Helvetica, Arial, sans-serif;
|
||||
|
||||
background: #333;
|
||||
background: -moz-linear-gradient(top, #222, #333);
|
||||
background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#222), to(#333));
|
||||
background: -webkit-linear-gradient(top, #222, #333);
|
||||
background: -o-linear-gradient(top, #333, #222);
|
||||
background: -ms-linear-gradient(top, #333, #222);
|
||||
background: linear-gradient(top, #333, #222);
|
||||
|
||||
/* 1px top shadow */
|
||||
/* -webkit-box-shadow: 0px -1px 0px 0px rgba(0, 0, 0, 0.15); -moz-box-shadow: 0px -1px 0px 0px rgba(0, 0, 0, 0.15); box-shadow: 0px -1px 0px 0px rgba(0, 0, 0, 0.15);*/
|
||||
}
|
||||
|
||||
.vjs-default-skin .vjs-current-time { left: 0; }
|
||||
|
||||
.vjs-default-skin .vjs-duration { right: 0; display: none; }
|
||||
.vjs-default-skin .vjs-remaining-time { right: 0; }
|
||||
|
||||
.vjs-time-divider { display:none; }
|
||||
|
||||
.vjs-default-skin .vjs-time-control { font-size: 1em; line-height: 1; font-weight: normal; font-family: Helvetica, Arial, sans-serif; }
|
||||
.vjs-default-skin .vjs-time-control span { line-height: 25px; /* Centering vertically */ }
|
||||
|
||||
/* Fullscreen
|
||||
-------------------------------------------------------------------------------- */
|
||||
.vjs-secondary-controls { float: right; }
|
||||
|
||||
.vjs-default-skin .vjs-fullscreen-control { width: 3.8em; cursor: pointer !important; float: right; }
|
||||
.vjs-default-skin .vjs-fullscreen-control div { width: 16px; height: 16px; background: url('video-js.png') -50px 0; margin: 0.5em auto 0; }
|
||||
|
||||
.vjs-default-skin.vjs-fullscreen .vjs-fullscreen-control div { background: url('video-js.png') -75px 0; }
|
||||
|
||||
|
||||
/* Big Play Button (at start)
|
||||
---------------------------------------------------------*/
|
||||
.vjs-default-skin .vjs-big-play-button {
|
||||
display: block; /* Start hidden */ z-index: 2;
|
||||
position: absolute; top: 50%; left: 50%; width: 8.0em; height: 8.0em; margin: -43px 0 0 -43px; text-align: center; vertical-align: center; cursor: pointer !important;
|
||||
border: 0.3em solid #fff; opacity: 0.95;
|
||||
-webkit-border-radius: 25px; -moz-border-radius: 25px; border-radius: 25px;
|
||||
|
||||
background: #454545;
|
||||
background: -moz-linear-gradient(top, #454545 0%, #232323 50%, #161616 50%, #3f3f3f 100%);
|
||||
background: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(0%,#454545), color-stop(50%,#232323), color-stop(50%,#161616), color-stop(100%,#3f3f3f));
|
||||
background: -webkit-linear-gradient(top, #454545 0%,#232323 50%,#161616 50%,#3f3f3f 100%);
|
||||
background: -o-linear-gradient(top, #454545 0%,#232323 50%,#161616 50%,#3f3f3f 100%);
|
||||
background: -ms-linear-gradient(top, #454545 0%,#232323 50%,#161616 50%,#3f3f3f 100%);
|
||||
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#454545', endColorstr='#3f3f3f',GradientType=0 );
|
||||
background: linear-gradient(top, #454545 0%,#232323 50%,#161616 50%,#3f3f3f 100%);
|
||||
|
||||
/* CSS Shadows */
|
||||
-webkit-box-shadow: 4px 4px 8px #000; -moz-box-shadow: 4px 4px 8px #000; box-shadow: 4px 4px 8px #000;
|
||||
}
|
||||
|
||||
.vjs-default-skin div.vjs-big-play-button:hover {
|
||||
-webkit-box-shadow: 0 0 80px #fff; -moz-box-shadow: 0 0 80px #fff; box-shadow: 0 0 80px #fff;
|
||||
}
|
||||
|
||||
.vjs-default-skin div.vjs-big-play-button span {
|
||||
position: absolute; top: 50%; left: 50%;
|
||||
display: block; width: 35px; height: 42px;
|
||||
margin: -20px 0 0 -15px; /* Using negative margin to center image. */
|
||||
background: url('video-js.png') -100px 0;
|
||||
}
|
||||
|
||||
/* Loading Spinner
|
||||
---------------------------------------------------------*/
|
||||
/* CSS Spinners by Kilian Valkhof - http://kilianvalkhof.com/2010/css-xhtml/css3-loading-spinners-without-images/ */
|
||||
.vjs-loading-spinner {
|
||||
display: none;
|
||||
position: absolute; top: 50%; left: 50%; width: 55px; height: 55px;
|
||||
margin: -28px 0 0 -28px;
|
||||
-webkit-animation-name: rotatethis;
|
||||
-webkit-animation-duration:1s;
|
||||
-webkit-animation-iteration-count:infinite;
|
||||
-webkit-animation-timing-function:linear;
|
||||
-moz-animation-name: rotatethis;
|
||||
-moz-animation-duration:1s;
|
||||
-moz-animation-iteration-count:infinite;
|
||||
-moz-animation-timing-function:linear;
|
||||
}
|
||||
|
||||
@-webkit-keyframes rotatethis {
|
||||
0% {-webkit-transform:scale(0.6) rotate(0deg); }
|
||||
12.5% {-webkit-transform:scale(0.6) rotate(0deg); }
|
||||
12.51% {-webkit-transform:scale(0.6) rotate(45deg); }
|
||||
25% {-webkit-transform:scale(0.6) rotate(45deg); }
|
||||
25.01% {-webkit-transform:scale(0.6) rotate(90deg);}
|
||||
37.5% {-webkit-transform:scale(0.6) rotate(90deg);}
|
||||
37.51% {-webkit-transform:scale(0.6) rotate(135deg);}
|
||||
50% {-webkit-transform:scale(0.6) rotate(135deg);}
|
||||
50.01% {-webkit-transform:scale(0.6) rotate(180deg);}
|
||||
62.5% {-webkit-transform:scale(0.6) rotate(180deg);}
|
||||
62.51% {-webkit-transform:scale(0.6) rotate(225deg);}
|
||||
75% {-webkit-transform:scale(0.6) rotate(225deg);}
|
||||
75.01% {-webkit-transform:scale(0.6) rotate(270deg);}
|
||||
87.5% {-webkit-transform:scale(0.6) rotate(270deg);}
|
||||
87.51% {-webkit-transform:scale(0.6) rotate(315deg);}
|
||||
100% {-webkit-transform:scale(0.6) rotate(315deg);}
|
||||
}
|
||||
|
||||
@-moz-keyframes rotatethis {
|
||||
0% {-moz-transform:scale(0.6) rotate(0deg);}
|
||||
12.5% {-moz-transform:scale(0.6) rotate(0deg);}
|
||||
12.51% {-moz-transform:scale(0.6) rotate(45deg);}
|
||||
25% {-moz-transform:scale(0.6) rotate(45deg);}
|
||||
25.01% {-moz-transform:scale(0.6) rotate(90deg);}
|
||||
37.5% {-moz-transform:scale(0.6) rotate(90deg);}
|
||||
37.51% {-moz-transform:scale(0.6) rotate(135deg);}
|
||||
50% {-moz-transform:scale(0.6) rotate(135deg);}
|
||||
50.01% {-moz-transform:scale(0.6) rotate(180deg);}
|
||||
62.5% {-moz-transform:scale(0.6) rotate(180deg);}
|
||||
62.51% {-moz-transform:scale(0.6) rotate(225deg);}
|
||||
75% {-moz-transform:scale(0.6) rotate(225deg);}
|
||||
75.01% {-moz-transform:scale(0.6) rotate(270deg);}
|
||||
87.5% {-moz-transform:scale(0.6) rotate(270deg);}
|
||||
87.51% {-moz-transform:scale(0.6) rotate(315deg);}
|
||||
100% {-moz-transform:scale(0.6) rotate(315deg);}
|
||||
}
|
||||
/* Each circle */
|
||||
div.vjs-loading-spinner .ball1 { opacity: 0.12; position:absolute; left: 20px; top: 0px; width: 13px; height: 13px; background: #fff;
|
||||
border-radius: 13px; -webkit-border-radius: 13px; -moz-border-radius: 13px; border: 1px solid #ccc; }
|
||||
|
||||
div.vjs-loading-spinner .ball2 { opacity: 0.25; position:absolute; left: 34px; top: 6px; width: 13px; height: 13px; background: #fff;
|
||||
border-radius: 13px; -webkit-border-radius: 13px; -moz-border-radius: 13px; border: 1px solid #ccc; }
|
||||
|
||||
div.vjs-loading-spinner .ball3 { opacity: 0.37; position:absolute; left: 40px; top: 20px; width: 13px; height: 13px; background: #fff;
|
||||
border-radius: 13px; -webkit-border-radius: 13px; -moz-border-radius: 13px; border: 1px solid #ccc; }
|
||||
|
||||
div.vjs-loading-spinner .ball4 { opacity: 0.50; position:absolute; left: 34px; top: 34px; width: 13px; height: 13px; background: #fff;
|
||||
border-radius: 10px; -webkit-border-radius: 10px; -moz-border-radius: 15px; border: 1px solid #ccc; }
|
||||
|
||||
div.vjs-loading-spinner .ball5 { opacity: 0.62; position:absolute; left: 20px; top: 40px; width: 13px; height: 13px; background: #fff;
|
||||
border-radius: 13px; -webkit-border-radius: 13px; -moz-border-radius: 13px; border: 1px solid #ccc; }
|
||||
|
||||
div.vjs-loading-spinner .ball6 { opacity: 0.75; position:absolute; left: 6px; top: 34px; width: 13px; height: 13px; background: #fff;
|
||||
border-radius: 13px; -webkit-border-radius: 13px; -moz-border-radius: 13px; border: 1px solid #ccc; }
|
||||
|
||||
div.vjs-loading-spinner .ball7 { opacity: 0.87; position:absolute; left: 0px; top: 20px; width: 13px; height: 13px; background: #fff;
|
||||
border-radius: 13px; -webkit-border-radius: 13px; -moz-border-radius: 13px; border: 1px solid #ccc; }
|
||||
|
||||
div.vjs-loading-spinner .ball8 { opacity: 1.00; position:absolute; left: 6px; top: 6px; width: 13px; height: 13px; background: #fff;
|
||||
border-radius: 13px; -webkit-border-radius: 13px; -moz-border-radius: 13px; border: 1px solid #ccc; }
|
||||
Arquivo binário não exibido.
|
Depois Largura: | Altura: | Tamanho: 7.3 KiB |
@@ -0,0 +1,53 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>HTML5 Video Player</title>
|
||||
|
||||
<link href="design/video-js.css" rel="stylesheet" type="text/css">
|
||||
|
||||
<!--[if IE]>
|
||||
<script src="https://getfirebug.com/releases/lite/1.3/firebug-lite.js"></script>
|
||||
<!--<![endif]-->
|
||||
|
||||
<script src="src/core.js"></script>
|
||||
<script src="src/lib.js"></script>
|
||||
<script src="src/ecma.js"></script>
|
||||
<script src="src/json.js"></script>
|
||||
|
||||
<script src="src/component.js"></script>
|
||||
<script src="src/player.js"></script>
|
||||
<script src="src/tech.js"></script>
|
||||
<script src="src/controls.js"></script>
|
||||
<script src="src/events.js"></script>
|
||||
<script src="src/tracks.js"></script>
|
||||
|
||||
<script src="flash/swfobject.js"></script>
|
||||
|
||||
<script src="src/setup.js"></script>
|
||||
|
||||
<script type="text/javascript" charset="utf-8">
|
||||
// Easy access to test Flash over HTML5. Add ?flash to URL
|
||||
if (window.location.href.indexOf("?flash") !== -1) {
|
||||
_V_.options.techOrder = ["H5swf"]
|
||||
}
|
||||
</script>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<video id="vid1" class="video-js vjs-default-skin" controls preload="auto" width="640" height="264"
|
||||
poster="http://video-js.zencoder.com/oceans-clip.png"
|
||||
data-setup='{}'>
|
||||
<source src="http://video-js.zencoder.com/oceans-clip.mp4" type='video/mp4'>
|
||||
<source src="http://video-js.zencoder.com/oceans-clip.webm" type='video/webm'>
|
||||
<source src="http://video-js.zencoder.com/oceans-clip.ogv" type='video/ogg'>
|
||||
<p>Video Playback Not Supported</p>
|
||||
</video>
|
||||
|
||||
<script>
|
||||
vid = document.getElementById("vid1");
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,17 @@
|
||||
#! /usr/bin/env ruby
|
||||
# Create javascript file with list of source files for easy inclusion in other development files.
|
||||
|
||||
# puts ARGV[0]
|
||||
|
||||
File.open("source-list.js", "w+") do |file|
|
||||
file.puts "var vjsSourceList = [];"
|
||||
|
||||
|
||||
Dir.foreach('../src') do |item|
|
||||
next if item == '.' or item == '..' or item == '.DS_Store'
|
||||
|
||||
file.puts "vjsSourceList.push('src/#{item}')"
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
@@ -1,13 +0,0 @@
|
||||
#! /bin/csh
|
||||
# Combines Source Files. In terminal, sh combine_sources.sh
|
||||
cat src/_begin.js > combined.js
|
||||
|
||||
cat src/main.js >> combined.js
|
||||
cat src/api.js >> combined.js
|
||||
cat src/html5.js >> combined.js
|
||||
cat src/flash.js >> combined.js
|
||||
cat src/behaviors.js >> combined.js
|
||||
cat src/lib.js >> combined.js
|
||||
cat src/video-js.jquery.js >> combined.js
|
||||
|
||||
cat src/_end.js >> combined.js
|
||||
-24
Diff do arquivo suprimido porque uma ou mais linhas são muito longas
@@ -1,114 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>HTML5 Video Player: flowplayer</title>
|
||||
|
||||
<!-- Include the VideoJS Library -->
|
||||
<script src="../src/main.js" type="text/javascript" charset="utf-8"></script>
|
||||
<script src="../src/api.js" type="text/javascript" charset="utf-8"></script>
|
||||
<script src="../src/html5.js" type="text/javascript" charset="utf-8"></script>
|
||||
<script src="../src/flash.js" type="text/javascript" charset="utf-8"></script>
|
||||
<script src="../src/behaviors.js" type="text/javascript" charset="utf-8"></script>
|
||||
<script src="../src/lib.js" type="text/javascript" charset="utf-8"></script>
|
||||
<script src="../src/video-js.jquery.js" type="text/javascript" charset="utf-8"></script>
|
||||
|
||||
<!-- <script type="text/javascript" src="flowplayer-3.2.4.min.js"></script> -->
|
||||
<script type="text/javascript" src="video-js.flowplayer.js"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
VideoJS.DOMReady(function(){
|
||||
myPlayer = VideoJS.setup("example_video_1", {
|
||||
controlsHiding: true,
|
||||
controlsBelow: false,
|
||||
showControlsAtStart: true,
|
||||
playerFallbackOrder: ["flash", "html5", "links"]
|
||||
});
|
||||
myPlayer.activateElement(document.getElementById("scrub"), "loadProgressBar");
|
||||
// var vid = document.getElementById("example_video_1"),
|
||||
// attrTable = document.getElementById("attributes"),
|
||||
// attrNames = ["error", "networkState", "readyState", "preload", "buffered",
|
||||
// "seeking", "currentTime", "initialTime", "duration", "startOffsetTime",
|
||||
// "paused", "defaultPlaybackRate", "playbackRate", "played", "seekable",
|
||||
// "ended", "autoplay", "loop", "controls", "volume", "muted", "tracks"
|
||||
// ],
|
||||
// attrs = {};
|
||||
//
|
||||
// for(var i=0,j=attrNames.length; i<j; i++) {
|
||||
// var row = _V_.createElement("tr");
|
||||
// var th = _V_.createElement("th");
|
||||
// th.innerHTML = attrNames[i];
|
||||
// attrs[attrNames[i]] = _V_.createElement("td", { id: attrNames[i] });
|
||||
// row.appendChild(th); row.appendChild(attrs[attrNames[i]]);
|
||||
// attrTable.appendChild(row);
|
||||
// }
|
||||
//
|
||||
// setInterval(function(){
|
||||
// for(var i=0,j=attrNames.length; i<j; i++) {
|
||||
// attrs[attrNames[i]].innerHTML = vid[attrNames[i]];
|
||||
// }
|
||||
// }, 100);
|
||||
//
|
||||
// var events = ["loadstart","progress","suspend","abort","error","emptied","stalled","play","pause",
|
||||
// "loadedmetadata", "loadeddata", "waiting", "playing", "canplay", "canplaythrough", "seeking", "seeked",
|
||||
// // "timeupdate",
|
||||
// "ended", "ratechange", "durationchange","volumechange"
|
||||
// ],
|
||||
// eventsList = document.getElementById("events");
|
||||
//
|
||||
// for(var i=0,j=events.length; i<j; i++) {
|
||||
// vid.addEventListener(events[i], function(){
|
||||
// eventsList.innerHTML = this + "\n" + eventsList.innerHTML
|
||||
// }.context(events[i]), false);
|
||||
// }
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
<style type="text/css" media="screen">
|
||||
#attributes { width: 300px; float: left; }
|
||||
#events { width: 300px; height: 500px; float: left; }
|
||||
</style>
|
||||
|
||||
<!-- Include the VideoJS Stylesheet -->
|
||||
<link rel="stylesheet" href="../../video-js.css" type="text/css" media="screen" title="Video JS">
|
||||
<link rel="stylesheet" href="../../skins/tube.css" type="text/css" media="screen" title="Video JS">
|
||||
<link rel="stylesheet" href="../../skins/hu.css" type="text/css" media="screen" title="Video JS">
|
||||
<link rel="stylesheet" href="../../skins/vim.css" type="text/css" media="screen" title="Video JS">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<!-- Begin VideoJS -->
|
||||
<div id="scrub" style="background: #000; height: 10px;"></div>
|
||||
|
||||
<div class="video-js-box">
|
||||
<!-- Using the Video for Everybody Embed Code http://camendesign.com/code/video_for_everybody -->
|
||||
<video id="example_video_1" class="video-js" width="640" height="264" controls="controls" preload="auto" poster="http://video-js.zencoder.com/oceans-clip.png">
|
||||
<source src="http://video-js.zencoder.com/oceans-clip.mp4" type='video/mp4; codecs="avc1.42E01E, mp4a.40.2"' />
|
||||
<source src="http://video-js.zencoder.com/oceans-clip.webm" type='video/webm; codecs="vp8, vorbis"' />
|
||||
<source src="http://video-js.zencoder.com/oceans-clip.ogv" type='video/ogg; codecs="theora, vorbis"' />
|
||||
<!-- <track kind="subtitles" src="../demo-subtitles.srt" srclang="en-US" label="English"></track> -->
|
||||
<!-- Flash Fallback. Use any flash video player here. Make sure to keep the vjs-flash-fallback class. -->
|
||||
<div class="vjs-flash-fallback" width="640" height="264" href="http://video-js.zencoder.com/oceans-clip.mp4"></div>
|
||||
</video>
|
||||
<!-- Download links provided for devices that can't play video in the browser. -->
|
||||
<p class="vjs-no-video"><strong>Download Video:</strong>
|
||||
<a href="http://video-js.zencoder.com/oceans-clip.mp4">MP4</a>,
|
||||
<a href="http://video-js.zencoder.com/oceans-clip.webm">WebM</a>,
|
||||
<a href="http://video-js.zencoder.com/oceans-clip.ogv">Ogg</a><br>
|
||||
<!-- Support VideoJS by keeping this link. -->
|
||||
<a href="http://videojs.com">HTML5 Video Player</a> by VideoJS
|
||||
</p>
|
||||
</div>
|
||||
<!-- End VideoJS -->
|
||||
|
||||
<a onClick="(function(){document.getElementById('example_video_1').player.flowplayer.play(); return false;})()">Click</a>
|
||||
|
||||
<table id="attributes">
|
||||
</table>
|
||||
|
||||
<textarea id="events"></textarea>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,13 +0,0 @@
|
||||
1
|
||||
00:00:02,400 --> 00:00:05,200
|
||||
41.586688,-100.112915
|
||||
|
||||
2
|
||||
00:00:15,712 --> 00:00:17,399
|
||||
46.920255,3.010254
|
||||
|
||||
3
|
||||
00:00:25,712 --> 00:00:30,399
|
||||
-36.208823,-67.192383
|
||||
|
||||
|
||||
@@ -1,92 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>HTML5 Video Player</title>
|
||||
|
||||
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
|
||||
|
||||
<!-- Include the VideoJS Library -->
|
||||
<script src="../../video.js" type="text/javascript" charset="utf-8"></script>
|
||||
<script type="text/javascript">
|
||||
VideoJS.DOMReady(function(){
|
||||
var myPlayer = VideoJS.setup("example_video_1", { controlsHiding: false });
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
<script type="text/javascript"
|
||||
src="http://maps.google.com/maps/api/js?sensor=false">
|
||||
</script>
|
||||
<script type="text/javascript">
|
||||
function initialize() {
|
||||
var latlng = new google.maps.LatLng(-34.397, 150.644);
|
||||
var myOptions = {
|
||||
zoom: 8,
|
||||
center: latlng,
|
||||
disableDefaultUI: true,
|
||||
mapTypeId: google.maps.MapTypeId.ROADMAP
|
||||
};
|
||||
var map = new google.maps.Map(document.getElementById("map_canvas"),
|
||||
myOptions);
|
||||
|
||||
setTimeout(function() { map.panTo(new google.maps.LatLng(37.4419, -122.1419), 13) }, 2000)
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<style type="text/css">
|
||||
html { height: 100% }
|
||||
body { height: 100%; margin: 0px; padding: 0px }
|
||||
#map_canvas { height: 100%; position: absolute; top: 0; left: 0; }
|
||||
|
||||
.video-js-box { position: absolute; top: 50%; left: 50%; z-index: 1; margin: -132px 0 0 -320px; }
|
||||
</style>
|
||||
|
||||
<style type="text/css" media="screen">
|
||||
#attributes { width: 300px; float: left; }
|
||||
#events { width: 300px; height: 500px; float: left; }
|
||||
</style>
|
||||
|
||||
<!-- Include the VideoJS Stylesheet -->
|
||||
<link rel="stylesheet" href="../../video-js.css" type="text/css" media="screen" title="Video JS">
|
||||
<link rel="stylesheet" href="../skins/tube.css" type="text/css" media="screen" title="Video JS">
|
||||
<link rel="stylesheet" href="../skins/hu.css" type="text/css" media="screen" title="Video JS">
|
||||
<link rel="stylesheet" href="../skins/vim.css" type="text/css" media="screen" title="Video JS">
|
||||
</head>
|
||||
<body onload="initialize()">
|
||||
|
||||
<!-- Begin VideoJS -->
|
||||
<div class="video-js-box">
|
||||
<!-- Using the Video for Everybody Embed Code http://camendesign.com/code/video_for_everybody -->
|
||||
<video data-subtitles="../demo-subtitles.srt" id="example_video_1" class="video-js" width="640" height="264" controls="controls" preload="auto" poster="http://video-js.zencoder.com/oceans-clip.png">
|
||||
<source src="http://video-js.zencoder.com/oceans-clip.mp4" type='video/mp4; codecs="avc1.42E01E, mp4a.40.2"' />
|
||||
<source src="http://video-js.zencoder.com/oceans-clip.webm" type='video/webm; codecs="vp8, vorbis"' />
|
||||
<source src="http://video-js.zencoder.com/oceans-clip.ogv" type='video/ogg; codecs="theora, vorbis"' />
|
||||
<!-- Flash Fallback. Use any flash video player here. Make sure to keep the vjs-flash-fallback class. -->
|
||||
<object id="flash_fallback_1" class="vjs-flash-fallback" width="640" height="264" type="application/x-shockwave-flash"
|
||||
data="http://releases.flowplayer.org/swf/flowplayer-3.2.1.swf">
|
||||
<param name="movie" value="http://releases.flowplayer.org/swf/flowplayer-3.2.1.swf" />
|
||||
<param name="wmode" value="opaque" />
|
||||
<param name="allowfullscreen" value="true" />
|
||||
<param name="flashvars" value='config={"playlist":["http://video-js.zencoder.com/oceans-clip.png", {"url": "http://video-js.zencoder.com/oceans-clip.mp4","autoPlay":false,"autoBuffering":true}]}' />
|
||||
<!-- Image Fallback. Typically the same as the poster image. -->
|
||||
<img src="http://video-js.zencoder.com/oceans-clip.png" width="640" height="264" alt="Poster Image"
|
||||
title="No video playback capabilities." />
|
||||
</object>
|
||||
</video>
|
||||
<!-- Download links provided for devices that can't play video in the browser. -->
|
||||
<p class="vjs-no-video"><strong>Download Video:</strong>
|
||||
<a href="http://video-js.zencoder.com/oceans-clip.mp4">MP4</a>,
|
||||
<a href="http://video-js.zencoder.com/oceans-clip.webm">WebM</a>,
|
||||
<a href="http://video-js.zencoder.com/oceans-clip.ogv">Ogg</a><br>
|
||||
<!-- Support VideoJS by keeping this link. -->
|
||||
<a href="http://videojs.com">HTML5 Video Player</a> by VideoJS
|
||||
</p>
|
||||
</div>
|
||||
<!-- End VideoJS -->
|
||||
|
||||
<div id="map_canvas" style="width:100%; height:100%"></div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,13 @@
|
||||
var vjsSourceList = [];
|
||||
vjsSourceList.push('_begin.js')
|
||||
vjsSourceList.push('_end.js')
|
||||
vjsSourceList.push('component.js')
|
||||
vjsSourceList.push('controls.js')
|
||||
vjsSourceList.push('core.js')
|
||||
vjsSourceList.push('ecma.js')
|
||||
vjsSourceList.push('events.js')
|
||||
vjsSourceList.push('json.js')
|
||||
vjsSourceList.push('lib.js')
|
||||
vjsSourceList.push('player.js')
|
||||
vjsSourceList.push('tech.js')
|
||||
vjsSourceList.push('tracks.js')
|
||||
@@ -1,161 +0,0 @@
|
||||
/* Player API
|
||||
================================================================================ */
|
||||
VideoJS.fn.extend({
|
||||
|
||||
/* Listener types: play, pause, timeupdate, bufferedupdate, ended, volumechange, error */
|
||||
addEventListener: function(type, fn){
|
||||
if (!this.listeners[type]) { this.listeners[type] = []; }
|
||||
this.listeners[type].push(fn);
|
||||
},
|
||||
// Alias for backwards compatibility
|
||||
addListener: function(){ return this.addEventListener.apply(this, arguments); },
|
||||
|
||||
triggerListeners: function(type, e){
|
||||
this.each(this.listeners[type], function(listener){
|
||||
listener.call(this, e);
|
||||
});
|
||||
},
|
||||
|
||||
removeListener: function(type, fn){
|
||||
var listeners = this.listeners[type];
|
||||
if (!listeners) { return; }
|
||||
for (var i=0; i<listeners.length; i++) {
|
||||
if (listeners[i] == fn) {
|
||||
listeners.splice(i--, 1);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
play: function(){ this.api.play.apply(this); return this; },
|
||||
pause: function(){ this.api.pause.apply(this); return this; },
|
||||
paused: function(){ return this.api.paused.apply(this); },
|
||||
|
||||
currentTime: function(seconds){
|
||||
if (seconds !== undefined) {
|
||||
this.values.currentTime = seconds; // Cache the last set value for smoother scrubbing.
|
||||
this.api.setCurrentTime.call(this, seconds);
|
||||
return this;
|
||||
}
|
||||
return this.api.currentTime.apply(this);
|
||||
},
|
||||
|
||||
duration: function(){ return this.api.duration.apply(this); },
|
||||
|
||||
buffered: function(){
|
||||
var buffered = this.api.buffered.apply(this),
|
||||
start = 0, end = this.values.bufferEnd = this.values.bufferEnd || 0,
|
||||
timeRange;
|
||||
|
||||
if (buffered && buffered.length > 0 && buffered.end(0) > end) {
|
||||
end = buffered.end(0);
|
||||
// Storing values allows them be overridden by setBufferedFromProgress
|
||||
this.values.bufferEnd = end;
|
||||
}
|
||||
|
||||
return this.createTimeRange(start, end);
|
||||
},
|
||||
// Mimic HTML5 TimeRange Spec.
|
||||
createTimeRange: function(start, end){
|
||||
return {
|
||||
length: 1,
|
||||
start: function() { return start; },
|
||||
end: function() { return end; }
|
||||
};
|
||||
},
|
||||
// Calculates amount of buffer is full
|
||||
bufferedPercent: function(){ return (this.duration()) ? this.buffered().end(0) / this.duration() : 0; },
|
||||
|
||||
volume: function(percentAsDecimal){
|
||||
if (percentAsDecimal !== undefined) {
|
||||
var vol = Math.max(0, Math.min(1, parseFloat(percentAsDecimal))); // Force value to between 0 and 1
|
||||
this.values.volume = vol;
|
||||
this.api.setVolume.call(this, vol);
|
||||
this.setLocalStorage("volume", vol);
|
||||
return this;
|
||||
}
|
||||
// if (this.values.volume) { return this.values.volume; }
|
||||
return this.api.volume.call(this);
|
||||
},
|
||||
|
||||
width: function(width, skipListeners){
|
||||
if (width !== undefined) {
|
||||
this.element.width = width; // Not using style so it can be overridden on fullscreen.
|
||||
this.box.style.width = width+"px";
|
||||
if (!skipListeners) { this.triggerListeners("resize"); }
|
||||
return this;
|
||||
}
|
||||
return parseInt(this.element.getAttribute("width"));
|
||||
// return this.element.offsetWidth;
|
||||
},
|
||||
height: function(height){
|
||||
if (height !== undefined) {
|
||||
this.element.height = height;
|
||||
this.box.style.height = height+"px";
|
||||
this.triggerListeners("resize");
|
||||
return this;
|
||||
}
|
||||
return parseInt(this.element.getAttribute("height"));
|
||||
// return this.element.offsetHeight;
|
||||
},
|
||||
size: function(width, height){
|
||||
// Skip resize listeners on width for optimization
|
||||
return this.width(width, true).height(height);
|
||||
},
|
||||
|
||||
supportsFullScreen: function(){ return this.api.supportsFullScreen.call(this); },
|
||||
|
||||
// Turn on fullscreen (or window) mode
|
||||
enterFullScreen: function(){
|
||||
if (this.supportsFullScreen()) {
|
||||
this.api.enterFullScreen.call(this);
|
||||
} else {
|
||||
this.enterFullWindow();
|
||||
}
|
||||
this.triggerListeners("enterFullScreen");
|
||||
return this;
|
||||
},
|
||||
|
||||
exitFullScreen: function(){
|
||||
if (!this.supportsFullScreen()) {
|
||||
this.exitFullWindow();
|
||||
}
|
||||
this.triggerListeners("exitFullScreen");
|
||||
// Otherwise Shouldn't be called since native fullscreen uses own controls.
|
||||
return this;
|
||||
},
|
||||
|
||||
enterFullWindow: function(){
|
||||
this.videoIsFullScreen = true;
|
||||
// Storing original doc overflow value to return to when fullscreen is off
|
||||
this.docOrigOverflow = document.documentElement.style.overflow;
|
||||
// Add listener for esc key to exit fullscreen
|
||||
_V_.addListener(document, "keydown", this.fullscreenOnEscKey.rEvtContext(this));
|
||||
// Add listener for a window resize
|
||||
_V_.addListener(window, "resize", this.fullscreenOnWindowResize.rEvtContext(this));
|
||||
// Hide any scroll bars
|
||||
document.documentElement.style.overflow = 'hidden';
|
||||
// Apply fullscreen styles
|
||||
_V_.addClass(this.box, "vjs-fullscreen");
|
||||
// Resize the box, controller, and poster
|
||||
this.positionAll();
|
||||
this.triggerListeners("enterFullWindow");
|
||||
},
|
||||
|
||||
exitFullWindow: function(){
|
||||
this.videoIsFullScreen = false;
|
||||
document.removeEventListener("keydown", this.fullscreenOnEscKey, false);
|
||||
window.removeEventListener("resize", this.fullscreenOnWindowResize, false);
|
||||
// Unhide scroll bars.
|
||||
document.documentElement.style.overflow = this.docOrigOverflow;
|
||||
// Remove fullscreen styles
|
||||
_V_.removeClass(this.box, "vjs-fullscreen");
|
||||
// Resize the box, controller, and poster to original sizes
|
||||
this.positionAll();
|
||||
this.triggerListeners("exitFullWindow");
|
||||
},
|
||||
|
||||
src: function(src){
|
||||
this.api.src.call(this, src);
|
||||
return this;
|
||||
}
|
||||
});
|
||||
@@ -1,579 +0,0 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Element Behaviors
|
||||
// Tell elements how to act or react
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/* Player Behaviors - How VideoJS reacts to what the video is doing.
|
||||
================================================================================ */
|
||||
VideoJS.fn.newBehavior("player", function(player){
|
||||
this.addListener("error", this.playerOnVideoError);
|
||||
this.addListener("play", this.playerOnVideoPlay);
|
||||
this.addListener("play", this.trackCurrentTime);
|
||||
this.addListener("pause", this.stopTrackingCurrentTime);
|
||||
this.addListener("ended", this.playerOnVideoEnded);
|
||||
this.trackBuffered();
|
||||
this.addListener("bufferedupdate", this.bufferFull);
|
||||
},{
|
||||
playerOnVideoError: function(event){
|
||||
this.log(event);
|
||||
this.log(this.video.error);
|
||||
},
|
||||
playerOnVideoPlay: function(event){ this.hasPlayed = true; },
|
||||
playerOnVideoEnded: function(event){
|
||||
if (this.options.loop) {
|
||||
this.currentTime(0);
|
||||
this.play();
|
||||
} else if (this.options.returnToStart) {
|
||||
this.currentTime(0);
|
||||
this.pause();
|
||||
}
|
||||
},
|
||||
|
||||
/* Load Tracking -------------------------------------------------------------- */
|
||||
// Buffer watching method for load progress.
|
||||
// Used for browsers that don't support the progress event
|
||||
trackBuffered: function(){
|
||||
this.bufferedInterval = setInterval(function(){
|
||||
// Don't trigger unless
|
||||
if (this.values.bufferEnd < this.buffered().end(0)) {
|
||||
this.triggerListeners("bufferedupdate");
|
||||
}
|
||||
}.context(this), 500);
|
||||
},
|
||||
stopTrackingBuffered: function(){ clearInterval(this.bufferedInterval); },
|
||||
bufferFull: function(){
|
||||
if (this.bufferedPercent() == 1) {
|
||||
this.stopTrackingBuffered();
|
||||
}
|
||||
},
|
||||
|
||||
/* Time Tracking -------------------------------------------------------------- */
|
||||
trackCurrentTime: function(){
|
||||
if (this.currentTimeInterval) { clearInterval(this.currentTimeInterval); }
|
||||
|
||||
this.currentTimeInterval = setInterval(function(){
|
||||
this.triggerListeners("timeupdate");
|
||||
}.context(this), 100); // 42 = 24 fps
|
||||
|
||||
this.trackingCurrentTime = true;
|
||||
},
|
||||
// Turn off play progress tracking (when paused or dragging)
|
||||
stopTrackingCurrentTime: function(){
|
||||
clearInterval(this.currentTimeInterval);
|
||||
this.trackingCurrentTime = false;
|
||||
}
|
||||
}
|
||||
);
|
||||
/* Mouse Over Video Reporter Behaviors - i.e. Controls hiding based on mouse location
|
||||
================================================================================ */
|
||||
VideoJS.fn.newBehavior("mouseOverVideoReporter", function(element){
|
||||
// Listen for the mouse move the video. Used to reveal the controller.
|
||||
_V_.addListener(element, "mousemove", this.mouseOverVideoReporterOnMouseMove.context(this));
|
||||
// Listen for the mouse moving out of the video. Used to hide the controller.
|
||||
_V_.addListener(element, "mouseout", this.mouseOverVideoReporterOnMouseOut.context(this));
|
||||
},{
|
||||
mouseOverVideoReporterOnMouseMove: function(){
|
||||
this.showControlBars();
|
||||
clearInterval(this.mouseMoveTimeout);
|
||||
this.mouseMoveTimeout = setTimeout(this.hideControlBars.context(this), 4000);
|
||||
},
|
||||
mouseOverVideoReporterOnMouseOut: function(event){
|
||||
// Prevent flicker by making sure mouse hasn't left the video
|
||||
var parent = event.relatedTarget;
|
||||
while (parent && parent !== this.box) {
|
||||
parent = parent.parentNode;
|
||||
}
|
||||
if (parent !== this.box) {
|
||||
this.hideControlBars();
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
/* Mouse Over Video Reporter Behaviors - i.e. Controls hiding based on mouse location
|
||||
================================================================================ */
|
||||
VideoJS.fn.newBehavior("box", function(element){
|
||||
this.positionBox();
|
||||
_V_.addClass(element, "vjs-paused");
|
||||
this.activateElement(element, "mouseOverVideoReporter");
|
||||
this.addListener("play", this.boxOnVideoPlay);
|
||||
this.addListener("pause", this.boxOnVideoPause);
|
||||
},{
|
||||
boxOnVideoPlay: function(){
|
||||
_V_.removeClass(this.box, "vjs-paused");
|
||||
_V_.addClass(this.box, "vjs-playing");
|
||||
},
|
||||
boxOnVideoPause: function(){
|
||||
_V_.removeClass(this.box, "vjs-playing");
|
||||
_V_.addClass(this.box, "vjs-paused");
|
||||
}
|
||||
}
|
||||
);
|
||||
/* Poster Image Overlay
|
||||
================================================================================ */
|
||||
VideoJS.fn.newBehavior("poster", function(element){
|
||||
this.activateElement(element, "mouseOverVideoReporter");
|
||||
this.activateElement(element, "playButton");
|
||||
this.addListener("play", this.hidePoster);
|
||||
this.addListener("ended", this.showPoster);
|
||||
this.addListener("resize", this.positionPoster);
|
||||
},{
|
||||
showPoster: function(){
|
||||
if (!this.poster) { return; }
|
||||
this.poster.style.display = "block";
|
||||
this.positionPoster();
|
||||
},
|
||||
positionPoster: function(){
|
||||
// Only if the poster is visible
|
||||
if (!this.poster || this.poster.style.display == 'none') { return; }
|
||||
this.poster.style.height = this.height() + "px"; // Need incase controlsBelow
|
||||
this.poster.style.width = this.width() + "px"; // Could probably do 100% of box
|
||||
},
|
||||
hidePoster: function(){
|
||||
if (!this.poster) { return; }
|
||||
this.poster.style.display = "none";
|
||||
},
|
||||
// Update poster source from attribute or fallback image
|
||||
// iPad breaks if you include a poster attribute, so this fixes that
|
||||
updatePosterSource: function(){
|
||||
if (!this.video.poster) {
|
||||
var images = this.video.getElementsByTagName("img");
|
||||
if (images.length > 0) { this.video.poster = images[0].src; }
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
/* Control Bar Behaviors
|
||||
================================================================================ */
|
||||
VideoJS.fn.newBehavior("controlBar", function(element){
|
||||
if (!this.controlBars) {
|
||||
this.controlBars = [];
|
||||
this.addListener("resize", this.positionControlBars);
|
||||
}
|
||||
this.controlBars.push(element);
|
||||
_V_.addListener(element, "mousemove", this.onControlBarsMouseMove.context(this));
|
||||
_V_.addListener(element, "mouseout", this.onControlBarsMouseOut.context(this));
|
||||
},{
|
||||
showControlBars: function(){
|
||||
if (!this.options.controlsEnabled) { return; }
|
||||
if (!this.options.controlsAtStart && !this.hasPlayed) { return; }
|
||||
this.each(this.controlBars, function(bar){
|
||||
// bar.style.opacity = 1;
|
||||
bar.style.display = "block";
|
||||
});
|
||||
},
|
||||
// Place controller relative to the video's position (now just resizing bars)
|
||||
positionControlBars: function(){
|
||||
this.updatePlayProgressBars();
|
||||
this.updateLoadProgressBars();
|
||||
},
|
||||
hideControlBars: function(){
|
||||
if (this.options.controlsHiding && !this.mouseIsOverControls) {
|
||||
this.each(this.controlBars, function(bar){
|
||||
// bar.style.opacity = 0;
|
||||
bar.style.display = "none";
|
||||
});
|
||||
}
|
||||
},
|
||||
// Block controls from hiding when mouse is over them.
|
||||
onControlBarsMouseMove: function(){ this.mouseIsOverControls = true; },
|
||||
onControlBarsMouseOut: function(event){
|
||||
this.mouseIsOverControls = false;
|
||||
}
|
||||
}
|
||||
);
|
||||
/* PlayToggle, PlayButton, PauseButton Behaviors
|
||||
================================================================================ */
|
||||
// Play Toggle
|
||||
VideoJS.fn.newBehavior("playToggle", function(element){
|
||||
if (!this.elements.playToggles) {
|
||||
this.elements.playToggles = [];
|
||||
this.addListener("play", this.playTogglesOnPlay);
|
||||
this.addListener("pause", this.playTogglesOnPause);
|
||||
}
|
||||
this.elements.playToggles.push(element);
|
||||
_V_.addListener(element, "click", this.onPlayToggleClick.context(this));
|
||||
},{
|
||||
onPlayToggleClick: function(event){
|
||||
if (this.paused()) {
|
||||
this.play();
|
||||
} else {
|
||||
this.pause();
|
||||
}
|
||||
},
|
||||
playTogglesOnPlay: function(event){
|
||||
this.each(this.elements.playToggles, function(toggle){
|
||||
_V_.removeClass(toggle, "vjs-paused");
|
||||
_V_.addClass(toggle, "vjs-playing");
|
||||
});
|
||||
},
|
||||
playTogglesOnPause: function(event){
|
||||
this.each(this.elements.playToggles, function(toggle){
|
||||
_V_.removeClass(toggle, "vjs-playing");
|
||||
_V_.addClass(toggle, "vjs-paused");
|
||||
});
|
||||
}
|
||||
}
|
||||
);
|
||||
// Play
|
||||
VideoJS.fn.newBehavior("playButton", function(element){
|
||||
_V_.addListener(element, "click", this.onPlayButtonClick.context(this));
|
||||
},{
|
||||
onPlayButtonClick: function(event){ this.play(); }
|
||||
}
|
||||
);
|
||||
// Pause
|
||||
VideoJS.fn.newBehavior("pauseButton", function(element){
|
||||
_V_.addListener(element, "click", this.onPauseButtonClick.context(this));
|
||||
},{
|
||||
onPauseButtonClick: function(event){ this.pause(); }
|
||||
}
|
||||
);
|
||||
/* Play Progress Bar Behaviors
|
||||
================================================================================ */
|
||||
VideoJS.fn.newBehavior("playProgressBar", function(element){
|
||||
if (!this.elements.playProgressBars) {
|
||||
this.elements.playProgressBars = [];
|
||||
this.addListener("timeupdate", this.updatePlayProgressBars);
|
||||
}
|
||||
this.elements.playProgressBars.push(element);
|
||||
},{
|
||||
// Ajust the play progress bar's width based on the current play time
|
||||
updatePlayProgressBars: function(newTime){
|
||||
var progress = (this.scrubbing) ? this.values.currentTime / this.duration() : this.currentTime() / this.duration();
|
||||
if (isNaN(progress)) { progress = 0; }
|
||||
this.each(this.elements.playProgressBars, function(bar){
|
||||
if (bar.style) { bar.style.width = _V_.round(progress * 100, 2) + "%"; }
|
||||
});
|
||||
}
|
||||
}
|
||||
);
|
||||
/* Load Progress Bar Behaviors
|
||||
================================================================================ */
|
||||
VideoJS.fn.newBehavior("loadProgressBar", function(element){
|
||||
if (!this.elements.loadProgressBars) { this.elements.loadProgressBars = []; }
|
||||
this.elements.loadProgressBars.push(element);
|
||||
this.addListener("bufferedupdate", this.updateLoadProgressBars);
|
||||
},{
|
||||
updateLoadProgressBars: function(){
|
||||
this.each(this.elements.loadProgressBars, function(bar){
|
||||
if (bar.style) { bar.style.width = _V_.round(this.bufferedPercent() * 100, 2) + "%"; }
|
||||
});
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
/* Current Time Display Behaviors
|
||||
================================================================================ */
|
||||
VideoJS.fn.newBehavior("currentTimeDisplay", function(element){
|
||||
if (!this.elements.currentTimeDisplays) {
|
||||
this.elements.currentTimeDisplays = [];
|
||||
this.addListener("timeupdate", this.updateCurrentTimeDisplays);
|
||||
}
|
||||
this.elements.currentTimeDisplays.push(element);
|
||||
},{
|
||||
// Update the displayed time (00:00)
|
||||
updateCurrentTimeDisplays: function(newTime){
|
||||
// Allows for smooth scrubbing, when player can't keep up.
|
||||
var time = (this.scrubbing) ? this.values.currentTime : this.currentTime();
|
||||
this.each(this.elements.currentTimeDisplays, function(dis){
|
||||
dis.innerHTML = _V_.formatTime(time);
|
||||
});
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
/* Duration Display Behaviors
|
||||
================================================================================ */
|
||||
VideoJS.fn.newBehavior("durationDisplay", function(element){
|
||||
if (!this.elements.durationDisplays) {
|
||||
this.elements.durationDisplays = [];
|
||||
this.addListener("timeupdate", this.updateDurationDisplays);
|
||||
}
|
||||
this.elements.durationDisplays.push(element);
|
||||
},{
|
||||
updateDurationDisplays: function(){
|
||||
this.each(this.elements.durationDisplays, function(dis){
|
||||
if (this.duration()) { dis.innerHTML = _V_.formatTime(this.duration()); }
|
||||
});
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
/* Current Time Scrubber Behaviors
|
||||
================================================================================ */
|
||||
VideoJS.fn.newBehavior("currentTimeScrubber", function(element){
|
||||
_V_.addListener(element, "mousedown", this.onCurrentTimeScrubberMouseDown.rEvtContext(this));
|
||||
},{
|
||||
// Adjust the play position when the user drags on the progress bar
|
||||
onCurrentTimeScrubberMouseDown: function(event, scrubber){
|
||||
event.preventDefault();
|
||||
this.currentScrubber = scrubber;
|
||||
|
||||
this.stopTrackingCurrentTime(); // Allows for smooth scrubbing
|
||||
this.scrubbing = true;
|
||||
|
||||
this.videoWasPlaying = !this.paused();
|
||||
this.pause();
|
||||
|
||||
_V_.blockTextSelection();
|
||||
this.setCurrentTimeWithScrubber(event);
|
||||
_V_.addListener(document, "mousemove", this.onCurrentTimeScrubberMouseMove.rEvtContext(this));
|
||||
_V_.addListener(document, "mouseup", this.onCurrentTimeScrubberMouseUp.rEvtContext(this));
|
||||
},
|
||||
onCurrentTimeScrubberMouseMove: function(event){ // Removeable
|
||||
this.setCurrentTimeWithScrubber(event);
|
||||
},
|
||||
onCurrentTimeScrubberMouseUp: function(event){ // Removeable
|
||||
_V_.unblockTextSelection();
|
||||
document.removeEventListener("mousemove", this.onCurrentTimeScrubberMouseMove, false);
|
||||
document.removeEventListener("mouseup", this.onCurrentTimeScrubberMouseUp, false);
|
||||
this.scrubbing = false;
|
||||
if (this.videoWasPlaying) {
|
||||
this.play();
|
||||
this.trackCurrentTime();
|
||||
}
|
||||
},
|
||||
setCurrentTimeWithScrubber: function(event){
|
||||
var newProgress = _V_.getRelativePosition(event.pageX, this.currentScrubber);
|
||||
var newTime = newProgress * this.duration();
|
||||
// Don't let video end while scrubbing.
|
||||
if (newTime == this.duration()) { newTime = newTime - 0.1; }
|
||||
this.currentTime(newTime);
|
||||
this.triggerListeners("timeupdate");
|
||||
}
|
||||
}
|
||||
);
|
||||
/* Volume Display Behaviors
|
||||
================================================================================ */
|
||||
VideoJS.fn.newBehavior("volumeDisplay", function(element){
|
||||
if (!this.elements.volumeDisplays) {
|
||||
this.elements.volumeDisplays = [];
|
||||
this.addListener("volumechange", this.updateVolumeDisplays);
|
||||
}
|
||||
this.elements.volumeDisplays.push(element);
|
||||
this.updateVolumeDisplay(element); // Set the display to the initial volume
|
||||
},{
|
||||
// Update the volume control display
|
||||
// Unique to these default controls. Uses borders to create the look of bars.
|
||||
updateVolumeDisplays: function(){
|
||||
if (!this.elements.volumeDisplays) { return; }
|
||||
this.each(this.elements.volumeDisplays, function(dis){
|
||||
this.updateVolumeDisplay(dis);
|
||||
});
|
||||
},
|
||||
updateVolumeDisplay: function(display){
|
||||
var volNum = Math.ceil(this.volume() * 6);
|
||||
this.each(display.children, function(child, num){
|
||||
if (num < volNum) {
|
||||
_V_.addClass(child, "vjs-volume-level-on");
|
||||
} else {
|
||||
_V_.removeClass(child, "vjs-volume-level-on");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
);
|
||||
/* Volume Scrubber Behaviors
|
||||
================================================================================ */
|
||||
VideoJS.fn.newBehavior("volumeScrubber", function(element){
|
||||
_V_.addListener(element, "mousedown", this.onVolumeScrubberMouseDown.rEvtContext(this));
|
||||
},{
|
||||
// Adjust the volume when the user drags on the volume control
|
||||
onVolumeScrubberMouseDown: function(event, scrubber){
|
||||
// event.preventDefault();
|
||||
_V_.blockTextSelection();
|
||||
this.currentScrubber = scrubber;
|
||||
this.setVolumeWithScrubber(event);
|
||||
_V_.addListener(document, "mousemove", this.onVolumeScrubberMouseMove.rEvtContext(this));
|
||||
_V_.addListener(document, "mouseup", this.onVolumeScrubberMouseUp.rEvtContext(this));
|
||||
},
|
||||
onVolumeScrubberMouseMove: function(event){
|
||||
this.setVolumeWithScrubber(event);
|
||||
},
|
||||
onVolumeScrubberMouseUp: function(event){
|
||||
this.setVolumeWithScrubber(event);
|
||||
_V_.unblockTextSelection();
|
||||
document.removeEventListener("mousemove", this.onVolumeScrubberMouseMove, false);
|
||||
document.removeEventListener("mouseup", this.onVolumeScrubberMouseUp, false);
|
||||
},
|
||||
setVolumeWithScrubber: function(event){
|
||||
var newVol = _V_.getRelativePosition(event.pageX, this.currentScrubber);
|
||||
this.volume(newVol);
|
||||
}
|
||||
}
|
||||
);
|
||||
/* Fullscreen Toggle Behaviors
|
||||
================================================================================ */
|
||||
VideoJS.fn.newBehavior("fullscreenToggle", function(element){
|
||||
_V_.addListener(element, "click", this.onFullscreenToggleClick.context(this));
|
||||
},{
|
||||
// When the user clicks on the fullscreen button, update fullscreen setting
|
||||
onFullscreenToggleClick: function(event){
|
||||
if (!this.videoIsFullScreen) {
|
||||
this.enterFullScreen();
|
||||
} else {
|
||||
this.exitFullScreen();
|
||||
}
|
||||
},
|
||||
|
||||
fullscreenOnWindowResize: function(event){ // Removeable
|
||||
this.positionControlBars();
|
||||
},
|
||||
// Create listener for esc key while in full screen mode
|
||||
fullscreenOnEscKey: function(event){ // Removeable
|
||||
if (event.keyCode == 27) {
|
||||
this.exitFullScreen();
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
/* Big Play Button Behaviors
|
||||
================================================================================ */
|
||||
VideoJS.fn.newBehavior("bigPlayButton", function(element){
|
||||
if (!this.elements.bigPlayButtons) {
|
||||
this.elements.bigPlayButtons = [];
|
||||
this.addListener("play", this.hideBigPlayButtons);
|
||||
this.addListener("ended", this.showBigPlayButtons);
|
||||
}
|
||||
this.elements.bigPlayButtons.push(element);
|
||||
this.activateElement(element, "playButton");
|
||||
},{
|
||||
showBigPlayButtons: function(){
|
||||
if (!this.options.controlsEnabled) { return; }
|
||||
this.each(this.elements.bigPlayButtons, function(element){
|
||||
element.style.display = "block";
|
||||
});
|
||||
},
|
||||
hideBigPlayButtons: function(){
|
||||
this.each(this.elements.bigPlayButtons, function(element){
|
||||
element.style.display = "none";
|
||||
});
|
||||
}
|
||||
}
|
||||
);
|
||||
/* Spinner
|
||||
================================================================================ */
|
||||
VideoJS.fn.newBehavior("spinner", function(element){
|
||||
if (!this.spinners) {
|
||||
this.spinners = [];
|
||||
this.spinnersRotated = 0;
|
||||
_V_.addListener(this.video, "loadeddata", this.spinnersOnVideoLoadedData.context(this));
|
||||
_V_.addListener(this.video, "loadstart", this.spinnersOnVideoLoadStart.context(this));
|
||||
_V_.addListener(this.video, "seeking", this.spinnersOnVideoSeeking.context(this));
|
||||
_V_.addListener(this.video, "seeked", this.spinnersOnVideoSeeked.context(this));
|
||||
_V_.addListener(this.video, "canplay", this.spinnersOnVideoCanPlay.context(this));
|
||||
_V_.addListener(this.video, "canplaythrough", this.spinnersOnVideoCanPlayThrough.context(this));
|
||||
_V_.addListener(this.video, "waiting", this.spinnersOnVideoWaiting.context(this));
|
||||
_V_.addListener(this.video, "stalled", this.spinnersOnVideoStalled.context(this));
|
||||
_V_.addListener(this.video, "suspend", this.spinnersOnVideoSuspend.context(this));
|
||||
_V_.addListener(this.video, "playing", this.spinnersOnVideoPlaying.context(this));
|
||||
_V_.addListener(this.video, "timeupdate", this.spinnersOnVideoTimeUpdate.context(this));
|
||||
}
|
||||
this.spinners.push(element);
|
||||
},{
|
||||
showSpinners: function(){
|
||||
this.each(this.spinners, function(spinner){
|
||||
spinner.style.display = "block";
|
||||
});
|
||||
clearInterval(this.spinnerInterval);
|
||||
this.spinnerInterval = setInterval(this.rotateSpinners.context(this), 100);
|
||||
},
|
||||
hideSpinners: function(){
|
||||
this.each(this.spinners, function(spinner){
|
||||
spinner.style.display = "none";
|
||||
});
|
||||
clearInterval(this.spinnerInterval);
|
||||
},
|
||||
rotateSpinners: function(){
|
||||
this.each(this.spinners, function(spinner){
|
||||
// spinner.style.transform = 'scale(0.5) rotate('+this.spinnersRotated+'deg)';
|
||||
spinner.style.WebkitTransform = 'scale(0.5) rotate('+this.spinnersRotated+'deg)';
|
||||
spinner.style.MozTransform = 'scale(0.5) rotate('+this.spinnersRotated+'deg)';
|
||||
});
|
||||
if (this.spinnersRotated == 360) { this.spinnersRotated = 0; }
|
||||
this.spinnersRotated += 45;
|
||||
},
|
||||
spinnersOnVideoLoadedData: function(event){ this.hideSpinners(); },
|
||||
spinnersOnVideoLoadStart: function(event){ this.showSpinners(); },
|
||||
spinnersOnVideoSeeking: function(event){ /* this.showSpinners(); */ },
|
||||
spinnersOnVideoSeeked: function(event){ /* this.hideSpinners(); */ },
|
||||
spinnersOnVideoCanPlay: function(event){ /* this.hideSpinners(); */ },
|
||||
spinnersOnVideoCanPlayThrough: function(event){ this.hideSpinners(); },
|
||||
spinnersOnVideoWaiting: function(event){
|
||||
// Safari sometimes triggers waiting inappropriately
|
||||
// Like after video has played, and you play again.
|
||||
this.showSpinners();
|
||||
},
|
||||
spinnersOnVideoStalled: function(event){},
|
||||
spinnersOnVideoSuspend: function(event){},
|
||||
spinnersOnVideoPlaying: function(event){ this.hideSpinners(); },
|
||||
spinnersOnVideoTimeUpdate: function(event){
|
||||
// Safari sometimes calls waiting and doesn't recover
|
||||
if(this.spinner.style.display == "block") { this.hideSpinners(); }
|
||||
}
|
||||
}
|
||||
);
|
||||
/* Subtitles
|
||||
================================================================================ */
|
||||
VideoJS.fn.newBehavior("subtitlesDisplay", function(element){
|
||||
if (!this.elements.subtitleDisplays) {
|
||||
this.elements.subtitleDisplays = [];
|
||||
this.addListener("timeupdate", this.subtitleDisplaysOnVideoTimeUpdate);
|
||||
this.addListener("ended", function() { this.lastSubtitleIndex = 0; }.context(this));
|
||||
}
|
||||
this.elements.subtitleDisplays.push(element);
|
||||
},{
|
||||
subtitleDisplaysOnVideoTimeUpdate: function(){
|
||||
// Assuming all subtitles are in order by time, and do not overlap
|
||||
if (this.subtitles) {
|
||||
var time = this.currentTime();
|
||||
// If current subtitle should stay showing, don't do anything. Otherwise, find new subtitle.
|
||||
if (!this.currentSubtitle || this.currentSubtitle.start >= time || this.currentSubtitle.end < time) {
|
||||
var newSubIndex = false,
|
||||
// Loop in reverse if lastSubtitle is after current time (optimization)
|
||||
// Meaning the user is scrubbing in reverse or rewinding
|
||||
reverse = (this.subtitles[this.lastSubtitleIndex].start > time),
|
||||
// If reverse, step back 1 becase we know it's not the lastSubtitle
|
||||
i = this.lastSubtitleIndex - (reverse) ? 1 : 0;
|
||||
while (true) { // Loop until broken
|
||||
if (reverse) { // Looping in reverse
|
||||
// Stop if no more, or this subtitle ends before the current time (no earlier subtitles should apply)
|
||||
if (i < 0 || this.subtitles[i].end < time) { break; }
|
||||
// End is greater than time, so if start is less, show this subtitle
|
||||
if (this.subtitles[i].start < time) {
|
||||
newSubIndex = i;
|
||||
break;
|
||||
}
|
||||
i--;
|
||||
} else { // Looping forward
|
||||
// Stop if no more, or this subtitle starts after time (no later subtitles should apply)
|
||||
if (i >= this.subtitles.length || this.subtitles[i].start > time) { break; }
|
||||
// Start is less than time, so if end is later, show this subtitle
|
||||
if (this.subtitles[i].end > time) {
|
||||
newSubIndex = i;
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
// Set or clear current subtitle
|
||||
if (newSubIndex !== false) {
|
||||
this.currentSubtitle = this.subtitles[newSubIndex];
|
||||
this.lastSubtitleIndex = newSubIndex;
|
||||
this.updateSubtitleDisplays(this.currentSubtitle.text);
|
||||
} else if (this.currentSubtitle) {
|
||||
this.currentSubtitle = false;
|
||||
this.updateSubtitleDisplays("");
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
updateSubtitleDisplays: function(val){
|
||||
this.each(this.elements.subtitleDisplays, function(disp){
|
||||
disp.innerHTML = val;
|
||||
});
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
@@ -1,77 +0,0 @@
|
||||
/* Flash Player Type
|
||||
================================================================================ */
|
||||
VideoJS.fn.extend({
|
||||
|
||||
flashSupported: function(){
|
||||
return !!this.flashPlayerVersionSupported();
|
||||
},
|
||||
|
||||
flashInit: function(){
|
||||
this.flashElement = this.getFlashElement();
|
||||
this.replaceWithFlash();
|
||||
this.element = this.flashElement;
|
||||
this.video.src = ""; // Stop video from downloading if HTML5 is still supported
|
||||
var flashPlayer = VideoJS.flashPlayers[this.options.flashPlayer];
|
||||
this.api = flashPlayer.api;
|
||||
flashPlayer.init.call(this);
|
||||
this.api.setupTriggers.call(this);
|
||||
},
|
||||
|
||||
// Get Flash Fallback object element from Embed Code
|
||||
getFlashElement: function(){
|
||||
var children = this.video.children;
|
||||
for (var i=0,j=children.length; i<j; i++) {
|
||||
if (children[i].className == "vjs-flash-fallback") {
|
||||
return children[i];
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
buildFlashElement: function(){
|
||||
this.flashElement = _V_.createElement("object", {
|
||||
id: "flash_fallback_2",
|
||||
className: "vjs-flash-fallback",
|
||||
type: "application/x-shockwave-flash",
|
||||
data: "http://releases.flowplayer.org/swf/flowplayer-3.2.1.swf"
|
||||
});
|
||||
// <object width="640" height="264" >
|
||||
|
||||
var params = {
|
||||
movie: 'http://releases.flowplayer.org/swf/flowplayer-3.2.1.swf',
|
||||
wmode: 'opaque',
|
||||
allowfullscreen: 'true',
|
||||
flashvars: 'config={"playlist":["http://video-js.zencoder.com/oceans-clip.png", {"url": "http://video-js.zencoder.com/oceans-clip.mp4","autoPlay":false,"autoBuffering":true}]}'
|
||||
};
|
||||
|
||||
for (var name in params){
|
||||
var p = _V_.createElement("param");
|
||||
p.name = name;
|
||||
p.value = params[name];
|
||||
this.flashElement.appendChild(p);
|
||||
}
|
||||
},
|
||||
|
||||
// Used to force a browser to fall back when it's an HTML5 browser but there's no supported sources
|
||||
replaceWithFlash: function(){
|
||||
// this.flashElement = this.video.removeChild(this.flashElement);
|
||||
if (this.flashElement) {
|
||||
this.box.insertBefore(this.flashElement, this.video);
|
||||
this.video.style.display = "none"; // Removing it was breaking later players
|
||||
}
|
||||
},
|
||||
|
||||
// Check if browser can use this flash player
|
||||
flashPlayerVersionSupported: function(){
|
||||
var playerVersion = (this.options.flashPlayerVersion) ? this.options.flashPlayerVersion : VideoJS.flashPlayers[this.options.flashPlayer].flashPlayerVersion;
|
||||
return VideoJS.getFlashVersion() >= playerVersion;
|
||||
}
|
||||
});
|
||||
|
||||
/* Flash Object Fallback (Flash Player)
|
||||
================================================================================ */
|
||||
VideoJS.flashPlayers = {};
|
||||
VideoJS.flashPlayers.htmlObject = {
|
||||
flashPlayerVersion: 9,
|
||||
init: function() { return true; },
|
||||
api: {} // No video API available with HTML Object embed method
|
||||
};
|
||||
@@ -1,474 +0,0 @@
|
||||
/* HTML5 Player Type
|
||||
================================================================================ */
|
||||
VideoJS.fn.extend({
|
||||
|
||||
html5Supported: function(){
|
||||
if (VideoJS.browserSupportsVideo() && this.canPlaySource()) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
|
||||
html5Init: function(){
|
||||
this.element = this.video;
|
||||
this.api = this.html5API;
|
||||
this.api.setupTriggers.call(this);
|
||||
|
||||
this.fixPreloading(); // Support old browsers that used autobuffer
|
||||
this.supportProgressEvents(); // Support browsers that don't use 'buffered'
|
||||
|
||||
// Set to stored volume OR 85%
|
||||
this.volume((localStorage && localStorage.volume) || this.options.defaultVolume);
|
||||
|
||||
// Update interface for device needs
|
||||
if (VideoJS.isIOS()) {
|
||||
this.options.useBuiltInControls = true;
|
||||
this.iOSInterface();
|
||||
} else if (VideoJS.isAndroid()) {
|
||||
this.options.useBuiltInControls = true;
|
||||
this.androidInterface();
|
||||
}
|
||||
|
||||
// Add VideoJS Controls
|
||||
if (!this.options.useBuiltInControls) {
|
||||
this.video.controls = false;
|
||||
|
||||
if (this.options.controlsBelow) { _V_.addClass(this.box, "vjs-controls-below"); }
|
||||
|
||||
// Make a click on th video act as a play button
|
||||
this.activateElement(this.video, "playToggle");
|
||||
|
||||
// Build Interface
|
||||
this.buildStylesCheckDiv(); // Used to check if style are loaded
|
||||
this.buildAndActivatePoster();
|
||||
this.buildBigPlayButton();
|
||||
this.buildAndActivateSpinner();
|
||||
this.buildAndActivateControlBar();
|
||||
this.loadInterface(); // Show everything once styles are loaded
|
||||
this.getSubtitles();
|
||||
}
|
||||
},
|
||||
/* Source Managemet
|
||||
================================================================================ */
|
||||
canPlaySource: function(){
|
||||
// Cache Result
|
||||
if (this.canPlaySourceResult) { return this.canPlaySourceResult; }
|
||||
// Loop through sources and check if any can play
|
||||
var children = this.video.children;
|
||||
for (var i=0,j=children.length; i<j; i++) {
|
||||
if (children[i].tagName.toUpperCase() == "SOURCE") {
|
||||
var canPlay = this.video.canPlayType(children[i].type) || this.canPlayExt(children[i].src);
|
||||
if (canPlay == "probably" || canPlay == "maybe") {
|
||||
this.firstPlayableSource = children[i];
|
||||
this.canPlaySourceResult = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
this.canPlaySourceResult = false;
|
||||
return false;
|
||||
},
|
||||
// Check if the extention is compatible, for when type won't work
|
||||
canPlayExt: function(src){
|
||||
if (!src) { return ""; }
|
||||
var match = src.match(/\.([^\.]+)$/);
|
||||
if (match && match[1]) {
|
||||
var ext = match[1].toLowerCase();
|
||||
// Android canPlayType doesn't work
|
||||
if (VideoJS.isAndroid()) {
|
||||
if (ext == "mp4" || ext == "m4v") { return "maybe"; }
|
||||
// Allow Apple HTTP Streaming for iOS
|
||||
} else if (VideoJS.isIOS()) {
|
||||
if (ext == "m3u8") { return "maybe"; }
|
||||
}
|
||||
}
|
||||
return "";
|
||||
},
|
||||
// Force the video source - Helps fix loading bugs in a handful of devices, like the iPad/iPhone poster bug
|
||||
// And iPad/iPhone javascript include location bug. And Android type attribute bug
|
||||
forceTheSource: function(){
|
||||
this.video.src = this.firstPlayableSource.src; // From canPlaySource()
|
||||
this.video.load();
|
||||
},
|
||||
/* Device Fixes
|
||||
================================================================================ */
|
||||
// Support older browsers that used "autobuffer"
|
||||
fixPreloading: function(){
|
||||
if (typeof this.video.hasAttribute == "function" && this.video.hasAttribute("preload") && this.video.preload != "none") {
|
||||
this.video.autobuffer = true; // Was a boolean
|
||||
} else {
|
||||
this.video.autobuffer = false;
|
||||
this.video.preload = "none";
|
||||
}
|
||||
},
|
||||
|
||||
// Listen for Video Load Progress (currently does not if html file is local)
|
||||
// Buffered does't work in all browsers, so watching progress as well
|
||||
supportProgressEvents: function(e){
|
||||
_V_.addListener(this.video, 'progress', this.setBufferedFromProgress.context(this));
|
||||
},
|
||||
// playerOnVideoProgress: function(event){
|
||||
// this.setBufferedFromProgress(event);
|
||||
// },
|
||||
setBufferedFromProgress: function(event){ // HTML5 Only
|
||||
if(event.total > 0 && this.duration()) {
|
||||
var newBufferEnd = (event.loaded / event.total) * this.duration();
|
||||
if (newBufferEnd > this.values.bufferEnd) {
|
||||
this.values.bufferEnd = newBufferEnd;
|
||||
this.triggerListeners("bufferedupdate");
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
iOSInterface: function(){
|
||||
if(VideoJS.iOSVersion() < 4) { this.forceTheSource(); } // Fix loading issues
|
||||
if(VideoJS.isIPad()) { // iPad could work with controlsBelow
|
||||
this.buildAndActivateSpinner(); // Spinner still works well on iPad, since iPad doesn't have one
|
||||
}
|
||||
},
|
||||
|
||||
// Fix android specific quirks
|
||||
// Use built-in controls, but add the big play button, since android doesn't have one.
|
||||
androidInterface: function(){
|
||||
this.forceTheSource(); // Fix loading issues
|
||||
_V_.addListener(this.video, "click", function(){ this.play(); }); // Required to play
|
||||
this.buildBigPlayButton(); // But don't activate the normal way. Pause doesn't work right on android.
|
||||
_V_.addListener(this.bigPlayButton, "click", function(){ this.play(); }.context(this));
|
||||
this.positionBox();
|
||||
this.showBigPlayButtons();
|
||||
},
|
||||
/* Wait for styles (TODO: move to _V_)
|
||||
================================================================================ */
|
||||
loadInterface: function(){
|
||||
if(!this.stylesHaveLoaded()) {
|
||||
// Don't want to create an endless loop either.
|
||||
if (!this.positionRetries) { this.positionRetries = 1; }
|
||||
if (this.positionRetries++ < 100) {
|
||||
setTimeout(this.loadInterface.context(this),10);
|
||||
return;
|
||||
}
|
||||
}
|
||||
this.hideStylesCheckDiv();
|
||||
this.showPoster();
|
||||
if (this.video.paused !== false) { this.showBigPlayButtons(); }
|
||||
if (this.options.controlsAtStart) { this.showControlBars(); }
|
||||
this.positionAll();
|
||||
},
|
||||
/* Control Bar
|
||||
================================================================================ */
|
||||
buildAndActivateControlBar: function(){
|
||||
/* Creating this HTML
|
||||
<div class="vjs-controls">
|
||||
<div class="vjs-play-control">
|
||||
<span></span>
|
||||
</div>
|
||||
<div class="vjs-progress-control">
|
||||
<div class="vjs-progress-holder">
|
||||
<div class="vjs-load-progress"></div>
|
||||
<div class="vjs-play-progress"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="vjs-time-control">
|
||||
<span class="vjs-current-time-display">00:00</span><span> / </span><span class="vjs-duration-display">00:00</span>
|
||||
</div>
|
||||
<div class="vjs-volume-control">
|
||||
<div>
|
||||
<span></span><span></span><span></span><span></span><span></span><span></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="vjs-fullscreen-control">
|
||||
<div>
|
||||
<span></span><span></span><span></span><span></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
*/
|
||||
|
||||
// Create a div to hold the different controls
|
||||
this.controls = _V_.createElement("div", { className: "vjs-controls" });
|
||||
// Add the controls to the video's container
|
||||
this.box.appendChild(this.controls);
|
||||
this.activateElement(this.controls, "controlBar");
|
||||
this.activateElement(this.controls, "mouseOverVideoReporter");
|
||||
|
||||
// Build the play control
|
||||
this.playControl = _V_.createElement("div", { className: "vjs-play-control", innerHTML: "<span></span>" });
|
||||
this.controls.appendChild(this.playControl);
|
||||
this.activateElement(this.playControl, "playToggle");
|
||||
|
||||
// Build the progress control
|
||||
this.progressControl = _V_.createElement("div", { className: "vjs-progress-control" });
|
||||
this.controls.appendChild(this.progressControl);
|
||||
|
||||
// Create a holder for the progress bars
|
||||
this.progressHolder = _V_.createElement("div", { className: "vjs-progress-holder" });
|
||||
this.progressControl.appendChild(this.progressHolder);
|
||||
this.activateElement(this.progressHolder, "currentTimeScrubber");
|
||||
|
||||
// Create the loading progress display
|
||||
this.loadProgressBar = _V_.createElement("div", { className: "vjs-load-progress" });
|
||||
this.progressHolder.appendChild(this.loadProgressBar);
|
||||
this.activateElement(this.loadProgressBar, "loadProgressBar");
|
||||
|
||||
// Create the playing progress display
|
||||
this.playProgressBar = _V_.createElement("div", { className: "vjs-play-progress" });
|
||||
this.progressHolder.appendChild(this.playProgressBar);
|
||||
this.activateElement(this.playProgressBar, "playProgressBar");
|
||||
|
||||
// Create the progress time display (00:00 / 00:00)
|
||||
this.timeControl = _V_.createElement("div", { className: "vjs-time-control" });
|
||||
this.controls.appendChild(this.timeControl);
|
||||
|
||||
// Create the current play time display
|
||||
this.currentTimeDisplay = _V_.createElement("span", { className: "vjs-current-time-display", innerHTML: "00:00" });
|
||||
this.timeControl.appendChild(this.currentTimeDisplay);
|
||||
this.activateElement(this.currentTimeDisplay, "currentTimeDisplay");
|
||||
|
||||
// Add time separator
|
||||
this.timeSeparator = _V_.createElement("span", { innerHTML: " / " });
|
||||
this.timeControl.appendChild(this.timeSeparator);
|
||||
|
||||
// Create the total duration display
|
||||
this.durationDisplay = _V_.createElement("span", { className: "vjs-duration-display", innerHTML: "00:00" });
|
||||
this.timeControl.appendChild(this.durationDisplay);
|
||||
this.activateElement(this.durationDisplay, "durationDisplay");
|
||||
|
||||
// Create the volumne control
|
||||
this.volumeControl = _V_.createElement("div", {
|
||||
className: "vjs-volume-control",
|
||||
innerHTML: "<div><span></span><span></span><span></span><span></span><span></span><span></span></div>"
|
||||
});
|
||||
this.controls.appendChild(this.volumeControl);
|
||||
this.activateElement(this.volumeControl, "volumeScrubber");
|
||||
|
||||
this.volumeDisplay = this.volumeControl.children[0];
|
||||
this.activateElement(this.volumeDisplay, "volumeDisplay");
|
||||
|
||||
// Crete the fullscreen control
|
||||
this.fullscreenControl = _V_.createElement("div", {
|
||||
className: "vjs-fullscreen-control",
|
||||
innerHTML: "<div><span></span><span></span><span></span><span></span></div>"
|
||||
});
|
||||
this.controls.appendChild(this.fullscreenControl);
|
||||
this.activateElement(this.fullscreenControl, "fullscreenToggle");
|
||||
},
|
||||
/* Poster Image
|
||||
================================================================================ */
|
||||
buildAndActivatePoster: function(){
|
||||
this.updatePosterSource();
|
||||
if (this.video.poster) {
|
||||
this.poster = document.createElement("img");
|
||||
// Add poster to video box
|
||||
this.box.appendChild(this.poster);
|
||||
|
||||
// Add poster image data
|
||||
this.poster.src = this.video.poster;
|
||||
// Add poster styles
|
||||
this.poster.className = "vjs-poster";
|
||||
this.activateElement(this.poster, "poster");
|
||||
} else {
|
||||
this.poster = false;
|
||||
}
|
||||
},
|
||||
/* Big Play Button
|
||||
================================================================================ */
|
||||
buildBigPlayButton: function(){
|
||||
/* Creating this HTML
|
||||
<div class="vjs-big-play-button"><span></span></div>
|
||||
*/
|
||||
this.bigPlayButton = _V_.createElement("div", {
|
||||
className: "vjs-big-play-button",
|
||||
innerHTML: "<span></span>"
|
||||
});
|
||||
this.box.appendChild(this.bigPlayButton);
|
||||
this.activateElement(this.bigPlayButton, "bigPlayButton");
|
||||
},
|
||||
/* Spinner (Loading)
|
||||
================================================================================ */
|
||||
buildAndActivateSpinner: function(){
|
||||
this.spinner = _V_.createElement("div", {
|
||||
className: "vjs-spinner",
|
||||
innerHTML: "<div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div>"
|
||||
});
|
||||
this.box.appendChild(this.spinner);
|
||||
this.activateElement(this.spinner, "spinner");
|
||||
},
|
||||
/* Styles Check - Check if styles are loaded (move ot _V_)
|
||||
================================================================================ */
|
||||
// Sometimes the CSS styles haven't been applied to the controls yet
|
||||
// when we're trying to calculate the height and position them correctly.
|
||||
// This causes a flicker where the controls are out of place.
|
||||
buildStylesCheckDiv: function(){
|
||||
this.stylesCheckDiv = _V_.createElement("div", { className: "vjs-styles-check" });
|
||||
this.stylesCheckDiv.style.position = "absolute";
|
||||
this.box.appendChild(this.stylesCheckDiv);
|
||||
},
|
||||
hideStylesCheckDiv: function(){ this.stylesCheckDiv.style.display = "none"; },
|
||||
stylesHaveLoaded: function(){
|
||||
if (this.stylesCheckDiv.offsetHeight != 5) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
},
|
||||
/* VideoJS Box - Holds all elements
|
||||
================================================================================ */
|
||||
positionAll: function(){
|
||||
this.positionBox();
|
||||
this.positionControlBars();
|
||||
this.positionPoster();
|
||||
},
|
||||
positionBox: function(){
|
||||
// Set width based on fullscreen or not.
|
||||
if (this.videoIsFullScreen) {
|
||||
this.box.style.width = "";
|
||||
this.element.style.height="";
|
||||
if (this.options.controlsBelow) {
|
||||
this.box.style.height = "";
|
||||
this.element.style.height = (this.box.offsetHeight - this.controls.offsetHeight) + "px";
|
||||
}
|
||||
} else {
|
||||
this.box.style.width = this.width() + "px";
|
||||
this.element.style.height=this.height()+"px";
|
||||
if (this.options.controlsBelow) {
|
||||
this.element.style.height = "";
|
||||
// this.box.style.height = this.video.offsetHeight + this.controls.offsetHeight + "px";
|
||||
}
|
||||
}
|
||||
},
|
||||
/* Subtitles
|
||||
================================================================================ */
|
||||
getSubtitles: function(){
|
||||
var tracks = this.video.getElementsByTagName("TRACK");
|
||||
for (var i=0,j=tracks.length; i<j; i++) {
|
||||
if (tracks[i].getAttribute("kind") == "subtitles" && tracks[i].getAttribute("src")) {
|
||||
this.subtitlesSource = tracks[i].getAttribute("src");
|
||||
this.loadSubtitles();
|
||||
this.buildSubtitles();
|
||||
}
|
||||
}
|
||||
},
|
||||
loadSubtitles: function() { _V_.get(this.subtitlesSource, this.parseSubtitles.context(this)); },
|
||||
parseSubtitles: function(subText) {
|
||||
var lines = subText.split("\n"),
|
||||
line = "",
|
||||
subtitle, time, text;
|
||||
this.subtitles = [];
|
||||
this.currentSubtitle = false;
|
||||
this.lastSubtitleIndex = 0;
|
||||
|
||||
for (var i=0; i<lines.length; i++) {
|
||||
line = _V_.trim(lines[i]); // Trim whitespace and linebreaks
|
||||
if (line) { // Loop until a line with content
|
||||
|
||||
// First line - Number
|
||||
subtitle = {
|
||||
id: line, // Subtitle Number
|
||||
index: this.subtitles.length // Position in Array
|
||||
};
|
||||
|
||||
// Second line - Time
|
||||
line = _V_.trim(lines[++i]);
|
||||
time = line.split(" --> ");
|
||||
subtitle.start = this.parseSubtitleTime(time[0]);
|
||||
subtitle.end = this.parseSubtitleTime(time[1]);
|
||||
|
||||
// Additional lines - Subtitle Text
|
||||
text = [];
|
||||
for (var j=i; j<lines.length; j++) { // Loop until a blank line or end of lines
|
||||
line = _V_.trim(lines[++i]);
|
||||
if (!line) { break; }
|
||||
text.push(line);
|
||||
}
|
||||
subtitle.text = text.join('<br/>');
|
||||
|
||||
// Add this subtitle
|
||||
this.subtitles.push(subtitle);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
parseSubtitleTime: function(timeText) {
|
||||
var parts = timeText.split(':'),
|
||||
time = 0;
|
||||
// hours => seconds
|
||||
time += parseFloat(parts[0])*60*60;
|
||||
// minutes => seconds
|
||||
time += parseFloat(parts[1])*60;
|
||||
// get seconds
|
||||
var seconds = parts[2].split(/\.|,/); // Either . or ,
|
||||
time += parseFloat(seconds[0]);
|
||||
// add miliseconds
|
||||
ms = parseFloat(seconds[1]);
|
||||
if (ms) { time += ms/1000; }
|
||||
return time;
|
||||
},
|
||||
|
||||
buildSubtitles: function(){
|
||||
/* Creating this HTML
|
||||
<div class="vjs-subtitles"></div>
|
||||
*/
|
||||
this.subtitlesDisplay = _V_.createElement("div", { className: 'vjs-subtitles' });
|
||||
this.box.appendChild(this.subtitlesDisplay);
|
||||
this.activateElement(this.subtitlesDisplay, "subtitlesDisplay");
|
||||
},
|
||||
|
||||
/* Player API - Translate functionality from player to video
|
||||
================================================================================ */
|
||||
html5API: {
|
||||
setupTriggers: function(){
|
||||
// Make video events trigger player events
|
||||
// May seem verbose here, but makes other APIs possible.
|
||||
var types = ["play", "pause", "ended", "volumechange", "error"],
|
||||
player = this, i, type;
|
||||
for (i = 0; i<types.length; i++) {
|
||||
type = types[i];
|
||||
_V_.addListener(this.video, type, function(e){
|
||||
player.triggerListeners(this, e);
|
||||
}.context(type));
|
||||
}
|
||||
},
|
||||
|
||||
play: function(){ this.video.play(); },
|
||||
pause: function(){ this.video.pause(); },
|
||||
paused: function(){ return this.video.paused; },
|
||||
|
||||
currentTime: function(){ return this.video.currentTime; },
|
||||
setCurrentTime: function(seconds){
|
||||
try { this.video.currentTime = seconds; }
|
||||
catch(e) { this.warning(VideoJS.warnings.videoNotReady); }
|
||||
},
|
||||
|
||||
duration: function(){ return this.video.duration; },
|
||||
buffered: function(){ return this.video.buffered; },
|
||||
|
||||
volume: function(){ return this.video.volume; },
|
||||
setVolume: function(percentAsDecimal){ this.video.volume = percentAsDecimal; },
|
||||
|
||||
width: function(){ return this.video.offsetWidth; },
|
||||
height: function(){ return this.video.offsetHeight; },
|
||||
|
||||
supportsFullScreen: function(){
|
||||
if(typeof this.video.webkitEnterFullScreen == 'function') {
|
||||
// Seems to be broken in Chromium/Chrome && Safari in Leopard
|
||||
if (!navigator.userAgent.match("Chrome") && !navigator.userAgent.match("Mac OS X 10.5")) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
enterFullScreen: function(){
|
||||
try {
|
||||
this.video.webkitEnterFullScreen();
|
||||
} catch (e) {
|
||||
if (e.code == 11) { this.warning(VideoJS.warnings.videoNotReady); }
|
||||
}
|
||||
},
|
||||
src: function(src){
|
||||
this.video.src = src;
|
||||
this.video.load();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,196 +0,0 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Convenience Functions (mini library)
|
||||
// Functions not specific to video or VideoJS and could probably be replaced with a library like jQuery
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
VideoJS.extend({
|
||||
|
||||
addClass: function(element, classToAdd){
|
||||
if ((" "+element.className+" ").indexOf(" "+classToAdd+" ") == -1) {
|
||||
element.className = element.className === "" ? classToAdd : element.className + " " + classToAdd;
|
||||
}
|
||||
},
|
||||
removeClass: function(element, classToRemove){
|
||||
if (element.className.indexOf(classToRemove) == -1) { return; }
|
||||
var classNames = element.className.split(/\s+/);
|
||||
classNames.splice(classNames.lastIndexOf(classToRemove),1);
|
||||
element.className = classNames.join(" ");
|
||||
},
|
||||
createElement: function(tagName, attributes){
|
||||
return this.merge(document.createElement(tagName), attributes);
|
||||
},
|
||||
|
||||
// Attempt to block the ability to select text while dragging controls
|
||||
blockTextSelection: function(){
|
||||
document.body.focus();
|
||||
document.onselectstart = function () { return false; };
|
||||
},
|
||||
// Turn off text selection blocking
|
||||
unblockTextSelection: function(){ document.onselectstart = function () { return true; }; },
|
||||
|
||||
// Return seconds as MM:SS
|
||||
formatTime: function(secs) {
|
||||
var seconds = Math.round(secs);
|
||||
var minutes = Math.floor(seconds / 60);
|
||||
minutes = (minutes >= 10) ? minutes : "0" + minutes;
|
||||
seconds = Math.floor(seconds % 60);
|
||||
seconds = (seconds >= 10) ? seconds : "0" + seconds;
|
||||
return minutes + ":" + seconds;
|
||||
},
|
||||
|
||||
// Return the relative horizonal position of an event as a value from 0-1
|
||||
getRelativePosition: function(x, relativeElement){
|
||||
return Math.max(0, Math.min(1, (x - this.findPosX(relativeElement)) / relativeElement.offsetWidth));
|
||||
},
|
||||
// Get an objects position on the page
|
||||
findPosX: function(obj) {
|
||||
var curleft = obj.offsetLeft;
|
||||
while(obj = obj.offsetParent) {
|
||||
curleft += obj.offsetLeft;
|
||||
}
|
||||
return curleft;
|
||||
},
|
||||
getComputedStyleValue: function(element, style){
|
||||
return window.getComputedStyle(element, null).getPropertyValue(style);
|
||||
},
|
||||
|
||||
round: function(num, dec) {
|
||||
if (!dec) { dec = 0; }
|
||||
return Math.round(num*Math.pow(10,dec))/Math.pow(10,dec);
|
||||
},
|
||||
|
||||
addListener: function(element, type, handler){
|
||||
if (element.addEventListener) {
|
||||
element.addEventListener(type, handler, false);
|
||||
} else if (element.attachEvent) {
|
||||
element.attachEvent("on"+type, handler);
|
||||
}
|
||||
},
|
||||
removeListener: function(element, type, handler){
|
||||
if (element.removeEventListener) {
|
||||
element.removeEventListener(type, handler, false);
|
||||
} else if (element.attachEvent) {
|
||||
element.detachEvent("on"+type, handler);
|
||||
}
|
||||
},
|
||||
|
||||
get: function(url, onSuccess){
|
||||
// if (netscape.security.PrivilegeManager.enablePrivilege) {
|
||||
// netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
|
||||
// }
|
||||
if (typeof XMLHttpRequest == "undefined") {
|
||||
XMLHttpRequest = function () {
|
||||
try { return new ActiveXObject("Msxml2.XMLHTTP.6.0"); } catch (e) {}
|
||||
try { return new ActiveXObject("Msxml2.XMLHTTP.3.0"); } catch (f) {}
|
||||
try { return new ActiveXObject("Msxml2.XMLHTTP"); } catch (g) {}
|
||||
//Microsoft.XMLHTTP points to Msxml2.XMLHTTP.3.0 and is redundant
|
||||
throw new Error("This browser does not support XMLHttpRequest.");
|
||||
};
|
||||
}
|
||||
var request = new XMLHttpRequest();
|
||||
request.open("GET",url);
|
||||
request.onreadystatechange = function() {
|
||||
if (request.readyState == 4 && request.status == 200) {
|
||||
onSuccess(request.responseText);
|
||||
}
|
||||
}.context(this);
|
||||
try {
|
||||
request.send();
|
||||
} catch(e) {
|
||||
// Can't access file.
|
||||
}
|
||||
},
|
||||
|
||||
trim: function(string){ return string.toString().replace(/^\s+/, "").replace(/\s+$/, ""); },
|
||||
|
||||
// DOM Ready functionality adapted from jQuery. http://jquery.com/
|
||||
bindDOMReady: function(){
|
||||
if (document.readyState === "complete") {
|
||||
return VideoJS.onDOMReady();
|
||||
}
|
||||
if (document.addEventListener) {
|
||||
document.addEventListener("DOMContentLoaded", VideoJS.DOMContentLoaded, false);
|
||||
window.addEventListener("load", VideoJS.onDOMReady, false);
|
||||
} else if (document.attachEvent) {
|
||||
document.attachEvent("onreadystatechange", VideoJS.DOMContentLoaded);
|
||||
window.attachEvent("onload", VideoJS.onDOMReady);
|
||||
}
|
||||
},
|
||||
|
||||
DOMContentLoaded: function(){
|
||||
if (document.addEventListener) {
|
||||
document.removeEventListener( "DOMContentLoaded", VideoJS.DOMContentLoaded, false);
|
||||
VideoJS.onDOMReady();
|
||||
} else if ( document.attachEvent ) {
|
||||
if ( document.readyState === "complete" ) {
|
||||
document.detachEvent("onreadystatechange", VideoJS.DOMContentLoaded);
|
||||
VideoJS.onDOMReady();
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
// Functions to be run once the DOM is loaded
|
||||
DOMReadyList: [],
|
||||
addToDOMReady: function(fn){
|
||||
if (VideoJS.DOMIsReady) {
|
||||
fn.call(document);
|
||||
} else {
|
||||
VideoJS.DOMReadyList.push(fn);
|
||||
}
|
||||
},
|
||||
|
||||
DOMIsReady: false,
|
||||
onDOMReady: function(){
|
||||
if (VideoJS.DOMIsReady) { return; }
|
||||
if (!document.body) { return setTimeout(VideoJS.onDOMReady, 13); }
|
||||
VideoJS.DOMIsReady = true;
|
||||
if (VideoJS.DOMReadyList) {
|
||||
for (var i=0; i<VideoJS.DOMReadyList.length; i++) {
|
||||
VideoJS.DOMReadyList[i].call(document);
|
||||
}
|
||||
VideoJS.DOMReadyList = null;
|
||||
}
|
||||
}
|
||||
});
|
||||
VideoJS.bindDOMReady();
|
||||
|
||||
// Allows for binding context to functions
|
||||
// when using in event listeners and timeouts
|
||||
Function.prototype.context = function(obj){
|
||||
var method = this,
|
||||
temp = function(){
|
||||
return method.apply(obj, arguments);
|
||||
};
|
||||
return temp;
|
||||
};
|
||||
|
||||
// Like context, in that it creates a closure
|
||||
// But insteaad keep "this" intact, and passes the var as the second argument of the function
|
||||
// Need for event listeners where you need to know what called the event
|
||||
// Only use with event callbacks
|
||||
Function.prototype.evtContext = function(obj){
|
||||
var method = this,
|
||||
temp = function(){
|
||||
var origContext = this;
|
||||
return method.call(obj, arguments[0], origContext);
|
||||
};
|
||||
return temp;
|
||||
};
|
||||
|
||||
// Removeable Event listener with Context
|
||||
// Replaces the original function with a version that has context
|
||||
// So it can be removed using the original function name.
|
||||
// In order to work, a version of the function must already exist in the player/prototype
|
||||
Function.prototype.rEvtContext = function(obj, funcParent){
|
||||
if (this.hasContext === true) { return this; }
|
||||
if (!funcParent) { funcParent = obj; }
|
||||
for (var attrname in funcParent) {
|
||||
if (funcParent[attrname] == this) {
|
||||
funcParent[attrname] = this.evtContext(obj);
|
||||
funcParent[attrname].hasContext = true;
|
||||
return funcParent[attrname];
|
||||
}
|
||||
}
|
||||
return this.evtContext(obj);
|
||||
};
|
||||
|
||||
@@ -1,306 +0,0 @@
|
||||
// Using jresig's Class implementation http://ejohn.org/blog/simple-javascript-inheritance/
|
||||
(function(){var initializing=false, fnTest=/xyz/.test(function(){xyz;}) ? /\b_super\b/ : /.*/; this.JRClass = function(){}; JRClass.extend = function(prop) { var _super = this.prototype; initializing = true; var prototype = new this(); initializing = false; for (var name in prop) { prototype[name] = typeof prop[name] == "function" && typeof _super[name] == "function" && fnTest.test(prop[name]) ? (function(name, fn){ return function() { var tmp = this._super; this._super = _super[name]; var ret = fn.apply(this, arguments); this._super = tmp; return ret; }; })(name, prop[name]) : prop[name]; } function JRClass() { if ( !initializing && this.init ) this.init.apply(this, arguments); } JRClass.prototype = prototype; JRClass.constructor = JRClass; JRClass.extend = arguments.callee; return JRClass;};})();
|
||||
|
||||
// Video JS Player Class
|
||||
var VideoJS = JRClass.extend({
|
||||
|
||||
// Initialize the player for the supplied video tag element
|
||||
// element: video tag
|
||||
init: function(element, setOptions){
|
||||
|
||||
// Allow an ID string or an element
|
||||
if (typeof element == 'string') {
|
||||
this.video = document.getElementById(element);
|
||||
} else {
|
||||
this.video = element;
|
||||
}
|
||||
|
||||
this.video.player = this; // Store reference to player on the video element.
|
||||
this.box = this.video.parentNode; // Container element for controls positioning
|
||||
this.values = {}; // Cache for video property values.
|
||||
this.elements = {}; // Store refs to controls elements.
|
||||
this.listeners = {}; // Store video event listeners.
|
||||
this.api = {}; // Current API to video functions (changes with player type)
|
||||
|
||||
// Hide Links. Will be shown again if "links" player is used
|
||||
this.linksFallback = this.getLinksFallback();
|
||||
this.hideLinksFallback();
|
||||
|
||||
// Default Options
|
||||
this.options = {
|
||||
autoplay: false,
|
||||
preload: true,
|
||||
loop: false,
|
||||
returnToStart: true, // Go back to the beginning when the video is done
|
||||
controlsEnabled: true,
|
||||
useBuiltInControls: false, // Use the browser's controls (iPhone)
|
||||
controlsBelow: false, // Display control bar below video vs. in front of
|
||||
controlsAtStart: false, // Make controls visible when page loads
|
||||
controlsHiding: true, // Hide controls when not over the video
|
||||
defaultVolume: 0.85, // Will be overridden by localStorage volume if available
|
||||
playerFallbackOrder: ["html5", "flash", "links"], // Players and order to use them
|
||||
flashPlayer: "htmlObject", // htmlObject, or custom options available
|
||||
flashPlayerVersion: false // Required flash version for fallback
|
||||
};
|
||||
// Override default options with global options
|
||||
if (typeof VideoJS.options == "object") { _V_.merge(this.options, VideoJS.options); }
|
||||
// Override default & global options with options specific to this player
|
||||
if (typeof setOptions == "object") { _V_.merge(this.options, setOptions); }
|
||||
// Override preload & autoplay with video attributes (test x = y || z on IE)
|
||||
if (this.getPreloadAttribute() !== undefined) { this.options.preload = this.getPreloadAttribute(); }
|
||||
if (this.getAutoplayAttribute() !== undefined) { this.options.autoplay = this.getAutoplayAttribute(); }
|
||||
|
||||
// Loop through the player names list in options, "html5" etc.
|
||||
// For each player name, initialize the player with that name under VideoJS.players
|
||||
// If the player successfully initializes, we're done
|
||||
// If not, try the next player in the list
|
||||
this.each(this.options.playerFallbackOrder, function(playerType){
|
||||
if (this[playerType+"Supported"]()) { // Check if player type is supported
|
||||
this[playerType+"Init"](); // Initialize player type
|
||||
return true; // Stop looping through players
|
||||
}
|
||||
});
|
||||
|
||||
// Start Global Listeners - API doesn't exist before now
|
||||
this.activateElement(this, "player");
|
||||
this.activateElement(this.box, "box");
|
||||
},
|
||||
/* Behaviors - Make elements act like specific controls or displays
|
||||
================================================================================ */
|
||||
behaviors: {},
|
||||
newBehavior: function(name, activate, functions){
|
||||
this.behaviors[name] = activate;
|
||||
this.extend(functions);
|
||||
},
|
||||
// Change to addBehavior or attachBehavior?
|
||||
activateElement: function(element, behavior){
|
||||
// Allow passing and ID string
|
||||
if (typeof element == "string") { element = document.getElementById(element); }
|
||||
this.behaviors[behavior].call(this, element);
|
||||
},
|
||||
/* Errors/Warnings
|
||||
================================================================================ */
|
||||
errors: [], // Array to track errors
|
||||
warnings: [],
|
||||
warning: function(warning){
|
||||
this.warnings.push(warning);
|
||||
this.log(warning);
|
||||
},
|
||||
/* History of errors/events (not quite there yet)
|
||||
================================================================================ */
|
||||
history: [],
|
||||
log: function(event){
|
||||
if (!event) { return; }
|
||||
if (typeof event == "string") { event = { type: event }; }
|
||||
if (event.type) { this.history.push(event.type); }
|
||||
if (this.history.length >= 50) { this.history.shift(); }
|
||||
try { console.log(event.type); } catch(e) { try { opera.postError(event.type); } catch(e){} }
|
||||
},
|
||||
/* Local Storage
|
||||
================================================================================ */
|
||||
setLocalStorage: function(key, value){
|
||||
if (!localStorage) { return; }
|
||||
try {
|
||||
localStorage[key] = value;
|
||||
} catch(e) {
|
||||
if (e.code == 22 || e.code == 1014) { // Webkit == 22 / Firefox == 1014
|
||||
this.warning(VideoJS.warnings.localStorageFull);
|
||||
}
|
||||
}
|
||||
},
|
||||
/* Helpers
|
||||
================================================================================ */
|
||||
getPreloadAttribute: function(){
|
||||
if (typeof this.video.hasAttribute == "function" && this.video.hasAttribute("preload")) {
|
||||
var preload = this.video.getAttribute("preload");
|
||||
// Only included the attribute, thinking it was boolean
|
||||
if (preload === "" || preload === "true") { return "auto"; }
|
||||
if (preload === "false") { return "none"; }
|
||||
return preload;
|
||||
}
|
||||
},
|
||||
getAutoplayAttribute: function(){
|
||||
if (typeof this.video.hasAttribute == "function" && this.video.hasAttribute("autoplay")) {
|
||||
var autoplay = this.video.getAttribute("autoplay");
|
||||
if (autoplay === "false") { return false; }
|
||||
return true;
|
||||
}
|
||||
},
|
||||
// Each that maintains player as context
|
||||
// Break if true is returned
|
||||
each: function(arr, fn){
|
||||
if (!arr || arr.length === 0) { return; }
|
||||
for (var i=0,j=arr.length; i<j; i++) {
|
||||
if (fn.call(this, arr[i], i)) { break; }
|
||||
}
|
||||
},
|
||||
// Add functions to the player
|
||||
extend: function(obj){
|
||||
for (var attrname in obj) {
|
||||
if (obj.hasOwnProperty(attrname)) { this[attrname]=obj[attrname]; }
|
||||
}
|
||||
}
|
||||
});
|
||||
VideoJS.fn = VideoJS.prototype;
|
||||
VideoJS.options = {}; // Globally set options
|
||||
|
||||
/* Download Links Fallback (Player Type)
|
||||
================================================================================ */
|
||||
VideoJS.fn.extend({
|
||||
linksSupported: function(){ return true; },
|
||||
linksInit: function(){
|
||||
this.showLinksFallback();
|
||||
this.element = this.video;
|
||||
},
|
||||
// Get the download links block element
|
||||
getLinksFallback: function(){ return this.box.getElementsByTagName("P")[0]; },
|
||||
// Hide no-video download paragraph
|
||||
hideLinksFallback: function(){
|
||||
if (this.linksFallback) { this.linksFallback.style.display = "none"; }
|
||||
},
|
||||
// Hide no-video download paragraph
|
||||
showLinksFallback: function(){
|
||||
if (this.linksFallback) { this.linksFallback.style.display = "block"; }
|
||||
}
|
||||
});
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Class Methods
|
||||
// Functions that don't apply to individual videos.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Combine Objects - Use "safe" to protect from overwriting existing items
|
||||
VideoJS.merge = function(obj1, obj2, safe){
|
||||
for (var attrname in obj2){
|
||||
if (obj2.hasOwnProperty(attrname) && (!safe || !obj1.hasOwnProperty(attrname))) { obj1[attrname]=obj2[attrname]; }
|
||||
}
|
||||
return obj1;
|
||||
};
|
||||
VideoJS.extend = function(obj){ this.merge(this, obj, true); };
|
||||
|
||||
VideoJS.extend({
|
||||
// Add VideoJS to all video tags with the video-js class when the DOM is ready
|
||||
setupAll: function(options, fn){
|
||||
// Options is stored globally, and added ot any new player on init
|
||||
VideoJS.options = options;
|
||||
VideoJS.DOMReady(VideoJS.setup);
|
||||
if (fn) { VideoJS.DOMReady(fn); }
|
||||
},
|
||||
|
||||
// Backward compatability. Changed to just SetupAll
|
||||
setupAllWhenReady: function(options){ VideoJS.setupAll(options); },
|
||||
|
||||
// Run the supplied function when the DOM is ready
|
||||
DOMReady: function(fn){
|
||||
VideoJS.addToDOMReady(fn);
|
||||
},
|
||||
|
||||
// Set up a specific video or array of video elements
|
||||
// "video" can be:
|
||||
// false, undefined, or "All": set up all videos with the video-js class
|
||||
// A video tag ID or video tag element: set up one video and return one player
|
||||
// An array of video tag elements/IDs: set up each and return an array of players
|
||||
setup: function(videos, options){
|
||||
var returnSingular = false,
|
||||
playerList = [],
|
||||
videoElement;
|
||||
|
||||
// If videos is undefined or "All", set up all videos with the video-js class
|
||||
if (!videos || videos == "All") {
|
||||
videos = VideoJS.getVideoJSTags();
|
||||
// If videos is not an array, add to an array
|
||||
} else if (typeof videos != 'object' || videos.nodeType == 1) {
|
||||
videos = [videos];
|
||||
returnSingular = true;
|
||||
}
|
||||
|
||||
// Loop through videos and create players for them
|
||||
for (var i=0; i<videos.length; i++) {
|
||||
if (typeof videos[i] == 'string') {
|
||||
videoElement = document.getElementById(videos[i]);
|
||||
} else { // assume DOM object
|
||||
videoElement = videos[i];
|
||||
}
|
||||
playerList.push(new VideoJS(videoElement, options));
|
||||
}
|
||||
|
||||
// Return one or all depending on what was passed in
|
||||
return (returnSingular) ? playerList[0] : playerList;
|
||||
},
|
||||
|
||||
// Get the player object for the supplied video tag ID
|
||||
player: function(id){ return document.getElementById(id).player; },
|
||||
|
||||
// Find video tags with the video-js class
|
||||
getVideoJSTags: function() {
|
||||
var videoTags = document.getElementsByTagName("video"),
|
||||
videoJSTags = [], videoTag;
|
||||
|
||||
for (var i=0,j=videoTags.length; i<j; i++) {
|
||||
videoTag = videoTags[i];
|
||||
if (videoTag.className.indexOf("video-js") != -1) {
|
||||
videoJSTags.push(videoTag);
|
||||
}
|
||||
}
|
||||
return videoJSTags;
|
||||
},
|
||||
|
||||
// Check if the browser supports video.
|
||||
browserSupportsVideo: function() {
|
||||
if (typeof VideoJS.videoSupport != "undefined") { return VideoJS.videoSupport; }
|
||||
VideoJS.videoSupport = !!document.createElement('video').canPlayType;
|
||||
return VideoJS.videoSupport;
|
||||
},
|
||||
|
||||
getFlashVersion: function(){
|
||||
// Cache Version
|
||||
if (typeof VideoJS.flashVersion != "undefined") { return VideoJS.flashVersion; }
|
||||
var version = 0, desc;
|
||||
if (typeof navigator.plugins != "undefined" && typeof navigator.plugins["Shockwave Flash"] == "object") {
|
||||
desc = navigator.plugins["Shockwave Flash"].description;
|
||||
if (desc && !(typeof navigator.mimeTypes != "undefined" && navigator.mimeTypes["application/x-shockwave-flash"] && !navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin)) {
|
||||
version = parseInt(desc.match(/^.*\s+([^\s]+)\.[^\s]+\s+[^\s]+$/)[1], 10);
|
||||
}
|
||||
} else if (typeof window.ActiveXObject != "undefined") {
|
||||
try {
|
||||
var testObject = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
|
||||
if (testObject) {
|
||||
version = parseInt(testObject.GetVariable("$version").match(/^[^\s]+\s(\d+)/)[1], 10);
|
||||
}
|
||||
}
|
||||
catch(e) {}
|
||||
}
|
||||
VideoJS.flashVersion = version;
|
||||
return VideoJS.flashVersion;
|
||||
},
|
||||
|
||||
// Browser & Device Checks
|
||||
isIE: function(){ return !+"\v1"; },
|
||||
isIPad: function(){ return navigator.userAgent.match(/iPad/i) !== null; },
|
||||
isIPhone: function(){ return navigator.userAgent.match(/iPhone/i) !== null; },
|
||||
isIOS: function(){ return VideoJS.isIPhone() || VideoJS.isIPad(); },
|
||||
iOSVersion: function() {
|
||||
var match = navigator.userAgent.match(/OS (\d+)_/i);
|
||||
if (match && match[1]) { return match[1]; }
|
||||
},
|
||||
isAndroid: function(){ return navigator.userAgent.match(/Android.*AppleWebKit/i) !== null; },
|
||||
androidVersion: function() {
|
||||
var match = navigator.userAgent.match(/Android (\d+)\./i);
|
||||
if (match && match[1]) { return match[1]; }
|
||||
},
|
||||
//isAndroidBrowser
|
||||
|
||||
warnings: {
|
||||
// Safari errors if you call functions on a video that hasn't loaded yet
|
||||
videoNotReady: "Video is not ready yet (try playing the video first).",
|
||||
// Getting a QUOTA_EXCEEDED_ERR when setting local storage occasionally
|
||||
localStorageFull: "Local Storage is Full"
|
||||
}
|
||||
});
|
||||
|
||||
// Shim to make Video tag valid in IE
|
||||
if(VideoJS.isIE()) { document.createElement("video"); }
|
||||
|
||||
// Expose to global
|
||||
window.VideoJS = window._V_ = VideoJS;
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
/* jQuery Plugin
|
||||
================================================================================ */
|
||||
if (window.jQuery) {
|
||||
(function($) {
|
||||
|
||||
$.fn.setupPlayer = function(options) {
|
||||
return VideoJS.setup(this[0], options);
|
||||
};
|
||||
|
||||
// Deprecated
|
||||
$.fn.VideoJS = function(options) {
|
||||
this.each(function() {
|
||||
VideoJS.setup(this, options);
|
||||
});
|
||||
return this;
|
||||
};
|
||||
|
||||
$.fn.player = function() {
|
||||
return this[0].player;
|
||||
};
|
||||
|
||||
})(jQuery);
|
||||
}
|
||||
|
||||
-150
@@ -1,150 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>HTML5 Video Player</title>
|
||||
|
||||
<!-- Include the VideoJS Library -->
|
||||
<script src="src/main.js" type="text/javascript" charset="utf-8"></script>
|
||||
<script src="src/api.js" type="text/javascript" charset="utf-8"></script>
|
||||
<script src="src/html5.js" type="text/javascript" charset="utf-8"></script>
|
||||
<script src="src/flash.js" type="text/javascript" charset="utf-8"></script>
|
||||
<script src="src/behaviors.js" type="text/javascript" charset="utf-8"></script>
|
||||
<script src="src/lib.js" type="text/javascript" charset="utf-8"></script>
|
||||
<script src="src/video-js.jquery.js" type="text/javascript" charset="utf-8"></script>
|
||||
<!-- <script src="flowplayer/video-js.flowplayer.js" type="text/javascript" charset="utf-8"></script> -->
|
||||
|
||||
<script type="text/javascript">
|
||||
VideoJS.setupAllWhenReady({ playerFallbackOrder: ["flash", "links"] });
|
||||
VideoJS.DOMReady(function(){
|
||||
// myPlayer = VideoJS.setup("example_video_1", {
|
||||
// // controlsHiding: true,
|
||||
// // controlsBelow: false,
|
||||
// // showControlsAtStart: true
|
||||
// });
|
||||
// myPlayer.activateElement(document.getElementById("scrub"), "playProgressBar");
|
||||
// var vid = document.getElementById("example_video_1"),
|
||||
// attrTable = document.getElementById("attributes"),
|
||||
// attrNames = ["error", "networkState", "readyState", "preload", "buffered",
|
||||
// "seeking", "currentTime", "initialTime", "duration", "startOffsetTime",
|
||||
// "paused", "defaultPlaybackRate", "playbackRate", "played", "seekable",
|
||||
// "ended", "autoplay", "loop", "controls", "volume", "muted", "tracks"
|
||||
// ],
|
||||
// attrs = {};
|
||||
//
|
||||
// for(var i=0,j=attrNames.length; i<j; i++) {
|
||||
// var row = _V_.createElement("tr");
|
||||
// var th = _V_.createElement("th");
|
||||
// th.innerHTML = attrNames[i];
|
||||
// attrs[attrNames[i]] = _V_.createElement("td", { id: attrNames[i] });
|
||||
// row.appendChild(th); row.appendChild(attrs[attrNames[i]]);
|
||||
// attrTable.appendChild(row);
|
||||
// }
|
||||
//
|
||||
// setInterval(function(){
|
||||
// for(var i=0,j=attrNames.length; i<j; i++) {
|
||||
// attrs[attrNames[i]].innerHTML = vid[attrNames[i]];
|
||||
// }
|
||||
// }, 100);
|
||||
//
|
||||
// var events = ["loadstart","progress","suspend","abort","error","emptied","stalled","play","pause",
|
||||
// "loadedmetadata", "loadeddata", "waiting", "playing", "canplay", "canplaythrough", "seeking", "seeked",
|
||||
// // "timeupdate",
|
||||
// "ended", "ratechange", "durationchange","volumechange"
|
||||
// ],
|
||||
// eventsList = document.getElementById("events");
|
||||
//
|
||||
// for(var i=0,j=events.length; i<j; i++) {
|
||||
// _V_.addListener(vid, events[i], function(){
|
||||
// eventsList.innerHTML = this + "\n" + eventsList.innerHTML
|
||||
// }.context(events[i]));
|
||||
// }
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
<style type="text/css" media="screen">
|
||||
#attributes { width: 300px; float: left; }
|
||||
#events { width: 300px; height: 500px; float: left; }
|
||||
</style>
|
||||
|
||||
<!-- Include the VideoJS Stylesheet -->
|
||||
<link rel="stylesheet" href="../video-js.css" type="text/css" media="screen" title="Video JS">
|
||||
<link rel="stylesheet" href="../skins/tube.css" type="text/css" media="screen" title="Video JS">
|
||||
<link rel="stylesheet" href="../skins/hu.css" type="text/css" media="screen" title="Video JS">
|
||||
<link rel="stylesheet" href="../skins/vim.css" type="text/css" media="screen" title="Video JS">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<!-- Begin VideoJS -->
|
||||
<div id="scrub" style="background: #000; height: 10px;"></div>
|
||||
|
||||
<div class="video-js-box">
|
||||
<!-- Using the Video for Everybody Embed Code http://camendesign.com/code/video_for_everybody -->
|
||||
<video id="example_video_1" class="video-js" width="640" height="264" controls="controls" preload="auto" poster="http://video-js.zencoder.com/oceans-clip.png">
|
||||
<source src="http://video-js.zencoder.com/oceans-clip.mp4" type='video/mp4; codecs="avc1.42E01E, mp4a.40.2"' />
|
||||
<source src="http://video-js.zencoder.com/oceans-clip.webm" type='video/webm; codecs="vp8, vorbis"' />
|
||||
<source src="http://video-js.zencoder.com/oceans-clip.ogv" type='video/ogg; codecs="theora, vorbis"' />
|
||||
<track kind="subtitles" src="../demo-subtitles.srt" srclang="en-US" label="English"></track>
|
||||
<!-- Flash Fallback. Use any flash video player here. Make sure to keep the vjs-flash-fallback class. -->
|
||||
<object id="flash_fallback_1" class="vjs-flash-fallback" width="640" height="264" type="application/x-shockwave-flash"
|
||||
data="http://releases.flowplayer.org/swf/flowplayer-3.2.1.swf">
|
||||
<param name="movie" value="http://releases.flowplayer.org/swf/flowplayer-3.2.1.swf" />
|
||||
<param name="wmode" value="opaque" />
|
||||
<param name="allowfullscreen" value="true" />
|
||||
<param name="flashvars" value='config={"playlist":["http://video-js.zencoder.com/oceans-clip.png", {"url": "http://video-js.zencoder.com/oceans-clip.mp4","autoPlay":false,"autoBuffering":true}]}' />
|
||||
<!-- Image Fallback. Typically the same as the poster image. -->
|
||||
<img src="http://video-js.zencoder.com/oceans-clip.png" width="640" height="264" alt="Poster Image"
|
||||
title="No video playback capabilities." />
|
||||
</object>
|
||||
</video>
|
||||
<!-- Download links provided for devices that can't play video in the browser. -->
|
||||
<p class="vjs-no-video"><strong>Download Video:</strong>
|
||||
<a href="http://video-js.zencoder.com/oceans-clip.mp4">MP4</a>,
|
||||
<a href="http://video-js.zencoder.com/oceans-clip.webm">WebM</a>,
|
||||
<a href="http://video-js.zencoder.com/oceans-clip.ogv">Ogg</a><br>
|
||||
<!-- Support VideoJS by keeping this link. -->
|
||||
<a href="http://videojs.com">HTML5 Video Player</a> by VideoJS
|
||||
</p>
|
||||
</div>
|
||||
<!-- End VideoJS -->
|
||||
|
||||
<div class="video-js-box">
|
||||
<!-- Using the Video for Everybody Embed Code http://camendesign.com/code/video_for_everybody -->
|
||||
<!-- <video id="example_video_2" class="video-jsnot" width="640" height="264" controls="controls" preload="none" poster="http://video-js.zencoder.com/oceans-clip.png"> -->
|
||||
<source src="http://video-js.zencoder.com/oceans-clip.mp4" type='video/mp4; codecs="avc1.42E01E, mp4a.40.2"' />
|
||||
<source src="http://video-js.zencoder.com/oceans-clip.webm" type='video/webm; codecs="vp8, vorbis"' />
|
||||
<source src="http://video-js.zencoder.com/oceans-clip.ogv" type='video/ogg; codecs="theora, vorbis"' />
|
||||
<!-- Flash Fallback. Use any flash video player here. Make sure to keep the vjs-flash-fallback class. -->
|
||||
<object id="flash_fallback_1" class="vjs-flash-fallback" width="640" height="264" type="application/x-shockwave-flash"
|
||||
data="http://releases.flowplayer.org/swf/flowplayer-3.2.1.swf">
|
||||
<param name="movie" value="http://releases.flowplayer.org/swf/flowplayer-3.2.1.swf" />
|
||||
<param name="wmode" value="opaque" />
|
||||
<param name="allowfullscreen" value="true" />
|
||||
<param name="flashvars" value='config={"playlist":["http://video-js.zencoder.com/oceans-clip.png", {"url": "http://video-js.zencoder.com/oceans-clip.mp4","autoPlay":false,"autoBuffering":true}]}' />
|
||||
<!-- Image Fallback. Typically the same as the poster image. -->
|
||||
<img src="http://video-js.zencoder.com/oceans-clip.png" width="640" height="264" alt="Poster Image"
|
||||
title="No video playback capabilities." />
|
||||
</object>
|
||||
<!-- </video> -->
|
||||
<!-- Download links provided for devices that can't play video in the browser. -->
|
||||
<p class="vjs-no-video"><strong>Download Video:</strong>
|
||||
<a href="http://video-js.zencoder.com/oceans-clip.mp4">MP4</a>,
|
||||
<a href="http://video-js.zencoder.com/oceans-clip.webm">WebM</a>,
|
||||
<a href="http://video-js.zencoder.com/oceans-clip.ogv">Ogg</a><br>
|
||||
<!-- Support VideoJS by keeping this link. -->
|
||||
<a href="http://videojs.com">HTML5 Video Player</a> by VideoJS
|
||||
</p>
|
||||
</div>
|
||||
<!-- End VideoJS -->
|
||||
|
||||
<a href="#" onclick="document.getElementById('example_video_1').currentTime = 10; return false;">Click</a>
|
||||
|
||||
<table id="attributes">
|
||||
</table>
|
||||
|
||||
<textarea id="events"></textarea>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,214 +0,0 @@
|
||||
API
|
||||
===
|
||||
The VideoJS API allows you to interact with the video through Javascript, whether the browser is playing the video through HTML5 video or through the Flash fallback (with supported Flash players).
|
||||
|
||||
To use the API functions, you need access to the video player object. Luckily this is easy to get. You just need to make sure your video tag has an ID. The default 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.
|
||||
|
||||
NOTE: Before you can access the player, the DOM must be ready and the VideoJS setup methods must have run. Follow the examples and you'll be fine.
|
||||
|
||||
Using the VideoJS setup with built-in DOM ready function.
|
||||
|
||||
VideoJS.setupAll(options, function(){
|
||||
|
||||
var myPlayer = VideoJS.player("example_video_id");
|
||||
|
||||
});
|
||||
|
||||
Using a javascript library's DOM ready function (jQuery example)
|
||||
|
||||
$(function(){ // DOM Ready
|
||||
|
||||
var myPlayer = VideoJS.setup("example_video_1", options);
|
||||
|
||||
});
|
||||
|
||||
After the player has been setup, you can also always access the player through the video element's "player" attribute.
|
||||
|
||||
// Javascript Example
|
||||
myPlayer = document.getElementById("example_video_1").player;
|
||||
|
||||
// jQuery Example
|
||||
myPlayer = $("#example_video_1")[0].player
|
||||
|
||||
// VideoJS jQuery Plugin Example
|
||||
myPlayer = $("#example_video_1").player();
|
||||
|
||||
|
||||
Now that you have access to the player through the myPlayer variable, you can control the video or react to video events using the following methods.
|
||||
|
||||
|
||||
### play()
|
||||
Start video playback.
|
||||
Returns the player object.
|
||||
Example:
|
||||
|
||||
myPlayer.play();
|
||||
|
||||
### onPlay(callback) // Type: Function
|
||||
Trigger the supplied callback function every time the video starts playing.
|
||||
Returns the player object.
|
||||
Example:
|
||||
|
||||
myPlayer.onPlay(function(){
|
||||
alert("OMG Video is playing!");
|
||||
});
|
||||
|
||||
### pause()
|
||||
Pause the video playback.
|
||||
Returns: the player object
|
||||
Example:
|
||||
|
||||
myPlayer.pause();
|
||||
|
||||
### onPause(callback) // Type: Function
|
||||
Trigger the supplied callback function every time the video is paused.
|
||||
Returns the player object.
|
||||
Example:
|
||||
|
||||
myPlayer.onPause(function(){
|
||||
alert("OMG Video is paused now!");
|
||||
});
|
||||
|
||||
### currentTime()
|
||||
Returns the current time of the video in seconds.
|
||||
Example:
|
||||
|
||||
var whereYouAt = myPlayer.currentTime();
|
||||
|
||||
### currentTime(seconds) // Type: Integer or Float
|
||||
Seek to the supplied time (seconds).
|
||||
Returns the player object.
|
||||
Example:
|
||||
|
||||
myPlayer.currentTime(120); // 2 minutes into the video
|
||||
|
||||
### onTimeUpdate(callback) // Type: Function
|
||||
Trigger the supplied callback function every time the currentTime changes. This is triggered about 10 times per second.
|
||||
Returns the player object.
|
||||
Example:
|
||||
|
||||
myPlayer.onTimeUpdate(function(){
|
||||
alert("The video is now " + myPlayer.currentTime() + " seconds in.");
|
||||
});
|
||||
|
||||
### onEnded(callback) // Type: Function
|
||||
Trigger the supplied callback function when the video finishes playing.
|
||||
Returns the player object.
|
||||
Example:
|
||||
|
||||
myPlayer.onEnded(function(){
|
||||
alert("Fin!");
|
||||
});
|
||||
|
||||
### duration()
|
||||
Returns the length in time of the video in seconds. Note: The video must have started loading before the duration can be known.
|
||||
Example:
|
||||
|
||||
var howLongIsThis = myPlayer.duration();
|
||||
|
||||
### onDurationUpdate(callback) // Type: Function
|
||||
Trigger the supplied callback function when the video's duration is updated.
|
||||
Returns the player object.
|
||||
Example:
|
||||
|
||||
myPlayer.onDurationUpdate(function(){
|
||||
alert("The video's duration is now " + myPlayer.duration());
|
||||
});
|
||||
|
||||
### buffered()
|
||||
Returns the amount of video that has loaded (downloaded) into the buffer.
|
||||
Example:
|
||||
|
||||
// Needs to be expanded
|
||||
var howMuchIsLoaded = myPlayer.duration();
|
||||
|
||||
### onBufferedUpdate(callback) // Type: Function
|
||||
Trigger the supplied callback function when the video's buffered amount is updated.
|
||||
Returns the player object.
|
||||
Example:
|
||||
|
||||
// Needs to be updated
|
||||
myPlayer.onBufferedUpdate(function(){
|
||||
alert("The video's duration is now " + myPlayer.duration());
|
||||
});
|
||||
|
||||
### 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.
|
||||
Example:
|
||||
|
||||
var howLoudIsIt = myPlayer.volume();
|
||||
|
||||
### volume(percentAsDecimal)
|
||||
Set the volume to the supplied percent (as a decimal between 0 and 1).
|
||||
Example:
|
||||
|
||||
myPlayer.volume(0.5); // Set volume to half
|
||||
|
||||
### onVolumeChange(callback)
|
||||
Trigger the supplied callback function when the video's volume changes.
|
||||
Returns the player object.
|
||||
Example:
|
||||
|
||||
myPlayer.onVolumeChange(function(){
|
||||
alert("The video's volume is now " + myPlayer.volume());
|
||||
});
|
||||
|
||||
### width()
|
||||
Returns the current width of the video in pixels.
|
||||
Example:
|
||||
|
||||
var howWideIsIt = myPlayer.width();
|
||||
|
||||
### width(pixels)
|
||||
Change the width of the video to the supplied width in pixels.
|
||||
Returns the player object
|
||||
Example:
|
||||
|
||||
myPlayer.width(640);
|
||||
|
||||
### height()
|
||||
Returns the current height of the video in pixels.
|
||||
Example:
|
||||
|
||||
var howTallIsIt = myPlayer.height();
|
||||
|
||||
### height(pixels)
|
||||
Change the height of the video to the supplied height in pixels.
|
||||
Returns the player object
|
||||
|
||||
myPlayer.height(480);
|
||||
|
||||
### size(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.
|
||||
Returns the player object.
|
||||
|
||||
myPlayer.size(640,480);
|
||||
|
||||
### onResize(callback)
|
||||
Trigger the supplied callback function when the video's size (width, height, or both) changes.
|
||||
Returns the player object.
|
||||
|
||||
myPlayer.onResize(function(){
|
||||
alert("The video is now " + myPlayer.width() + " by " + myPlayer.height());
|
||||
});
|
||||
|
||||
### enterFullScreen()
|
||||
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 fills the browser window. In browsers that support native full screen, typically the browser's default controls will be shown, and not the VideoJS custom skin. In full window mode, the VideoJS controls and skin will always be used.
|
||||
Returns the player object.
|
||||
|
||||
myPlayer.enterFullScreen();
|
||||
|
||||
### exitFullScreen()
|
||||
Return the video to its normal size after having been in full screen mode.
|
||||
Returns the player object.
|
||||
|
||||
myPlayer.exitFullScreen();
|
||||
|
||||
### onError(callback)
|
||||
Trigger the supplied callback function when the video when there is an error with the video.
|
||||
Returns the player object.
|
||||
|
||||
// Need to make work
|
||||
myPlayer.onError(function(errorText, errorID){
|
||||
alert("There's something wrong. " + errorText);
|
||||
});
|
||||
+243
@@ -0,0 +1,243 @@
|
||||
---
|
||||
layout: docs
|
||||
title: API
|
||||
description: Video.JS API Docs - API settings based on the HTML5 video API
|
||||
body_id: api
|
||||
body_class: docs subpage
|
||||
---
|
||||
|
||||
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.
|
||||
|
||||
{% highlight javascript %}
|
||||
|
||||
var myPlayer = _V_("example_video_1");
|
||||
|
||||
{% endhighlight %}
|
||||
|
||||
(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.
|
||||
|
||||
{% highlight javascript %}
|
||||
|
||||
_V_("example_video_1").ready(function(){
|
||||
|
||||
var myPlayer = this;
|
||||
|
||||
// EXAMPLE: Start playing the video.
|
||||
myPlayer.play();
|
||||
|
||||
});
|
||||
|
||||
{% endhighlight %}
|
||||
|
||||
API Methods
|
||||
-----------
|
||||
Now that you have access to a ready player, you can control the video 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.
|
||||
|
||||
{% highlight javascript %}
|
||||
|
||||
myPlayer.play();
|
||||
|
||||
{% endhighlight %}
|
||||
|
||||
|
||||
|
||||
### pause()
|
||||
Pause the video playback. Returns: the player object
|
||||
|
||||
{% highlight javascript %}
|
||||
|
||||
myPlayer.pause();
|
||||
|
||||
{% endhighlight %}
|
||||
|
||||
### currentTime()
|
||||
Returns the current time of the video in seconds.
|
||||
|
||||
{% highlight javascript %}
|
||||
|
||||
var whereYouAt = myPlayer.currentTime();
|
||||
|
||||
{% endhighlight %}
|
||||
|
||||
### currentTime(seconds) // Type: Integer or Float
|
||||
Seek to the supplied time (seconds).
|
||||
Returns the player object.
|
||||
|
||||
{% highlight javascript %}
|
||||
|
||||
myPlayer.currentTime(120); // 2 minutes into the video
|
||||
|
||||
{% endhighlight %}
|
||||
|
||||
|
||||
### 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.
|
||||
|
||||
|
||||
{% highlight javascript %}
|
||||
|
||||
var howLongIsThis = myPlayer.duration();
|
||||
|
||||
{% endhighlight %}
|
||||
|
||||
### buffered()
|
||||
Returns a [TimeRange](http://videojs.com/docs/glossary.html#timerange) with sections of the video that have been downloaded. If you just want the percent of the video that's been downloaded, use bufferedPercent.
|
||||
|
||||
{% highlight javascript %}
|
||||
|
||||
var whatHasBeenBuffered = myPlayer.buffered();
|
||||
|
||||
{% endhighlight %}
|
||||
|
||||
### bufferedPercent()
|
||||
Returns the percent (as a decimal) of the video that's been downloaded.
|
||||
|
||||
{% highlight javascript %}
|
||||
|
||||
var howMuchIsDownloaded = myPlayer.bufferedPercent();
|
||||
|
||||
{% endhighlight %}
|
||||
|
||||
### 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.
|
||||
|
||||
{% highlight javascript %}
|
||||
|
||||
var howLoudIsIt = myPlayer.volume();
|
||||
|
||||
{% endhighlight %}
|
||||
|
||||
### volume(percentAsDecimal)
|
||||
Set the volume to the supplied percent (as a decimal between 0 and 1).
|
||||
|
||||
{% highlight javascript %}
|
||||
|
||||
myPlayer.volume(0.5); // Set volume to half
|
||||
|
||||
{% endhighlight %}
|
||||
|
||||
### width()
|
||||
Returns the current width of the video in pixels.
|
||||
|
||||
{% highlight javascript %}
|
||||
|
||||
var howWideIsIt = myPlayer.width();
|
||||
|
||||
{% endhighlight %}
|
||||
|
||||
### width(pixels)
|
||||
Change the width of the video to the supplied width in pixels.
|
||||
Returns the player object
|
||||
|
||||
{% highlight javascript %}
|
||||
|
||||
myPlayer.width(640);
|
||||
|
||||
{% endhighlight %}
|
||||
|
||||
|
||||
### height()
|
||||
Returns the current height of the video in pixels.
|
||||
|
||||
{% highlight javascript %}
|
||||
|
||||
var howTallIsIt = myPlayer.height();
|
||||
|
||||
{% endhighlight %}
|
||||
|
||||
|
||||
### height(pixels)
|
||||
Change the height of the video to the supplied height in pixels.
|
||||
Returns the player object
|
||||
|
||||
{% highlight javascript %}
|
||||
|
||||
myPlayer.height(480);
|
||||
|
||||
{% endhighlight %}
|
||||
|
||||
|
||||
### size(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.
|
||||
|
||||
{% highlight javascript %}
|
||||
|
||||
myPlayer.size(640,480);
|
||||
|
||||
{% endhighlight %}
|
||||
|
||||
|
||||
### 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 fills the browser window. In browsers that support native full screen, typically the browser's default controls will be shown, and not the Video.js custom skin. In full window mode, the Video.js controls and skin will always be used.
|
||||
Returns the player object.
|
||||
|
||||
{% highlight javascript %}
|
||||
|
||||
myPlayer.enterFullScreen();
|
||||
|
||||
{% endhighlight %}
|
||||
|
||||
|
||||
### cancelFullScreen()
|
||||
Return the video to its normal size after having been in full screen mode.
|
||||
Returns the player object.
|
||||
|
||||
{% highlight javascript %}
|
||||
|
||||
myPlayer.exitFullScreen();
|
||||
|
||||
{% endhighlight %}
|
||||
|
||||
|
||||
Events
|
||||
------
|
||||
You can attach event listeners to the player similarly to how you would for a video element.
|
||||
|
||||
{% highlight javascript %}
|
||||
|
||||
var myFunc = function(){
|
||||
// Do something when the event is fired
|
||||
};
|
||||
myPlayer.addEvent("eventName", myFunc);
|
||||
|
||||
{% endhighlight %}
|
||||
|
||||
|
||||
You can also remove the listeners later.
|
||||
|
||||
{% highlight javascript %}
|
||||
|
||||
myPlayer.removeEvent("eventName", myFunc);
|
||||
|
||||
{% endhighlight %}
|
||||
|
||||
|
||||
### Event Types
|
||||
List of player events you can add listeners for.
|
||||
|
||||
<table border="0" cellspacing="5" cellpadding="5">
|
||||
<tr><th>Name</th><th>Description</th></tr>
|
||||
<tr><td>loadstart</td><td>Fired when the user agent begins looking for media data.</td></tr>
|
||||
<tr><td>play</td><td>Fired whenever the media begins or resumes playback.</td></tr>
|
||||
<tr><td>pause</td><td>Fired whenever the media has been paused.</td></tr>
|
||||
<tr><td>timeupdate</td><td>Fired when the current playback position has changed. During playback this is fired every 15-250 milliseconds, depnding on the playback technology in use.</td></tr>
|
||||
<tr><td>ended</td><td>Fired when the end of the media resource is reached. currentTime == duration</td></tr>
|
||||
<tr><td>durationchange</td><td>Fired when the duration of the media resource is changed, or known for the first time.</td></tr>
|
||||
<tr><td>progress</td><td>Fired while the user agent is downloading media data.</td></tr>
|
||||
<tr><td>resize</td><td>Fired when the width and/or height of the video window changes.</td></tr>
|
||||
<tr><td>volumechange</td><td>Fired when the volume changes.</td></tr>
|
||||
<tr><td>error</td><td>Fired when there is an error in playback.</td></tr>
|
||||
</table>
|
||||
@@ -1,53 +0,0 @@
|
||||
Behaviors
|
||||
=========
|
||||
Behaviors allow you to make an element on your page act as a video control or a display of video information. The easiest example of this is creating a play button. The following code will make a click on your element play the video.
|
||||
|
||||
myPlayer.activateElement(myElement, "playButton");
|
||||
|
||||
mouseOverVideoReporter
|
||||
The mouseOverVideoReporter behavior is mostly used internally to trigger showing the controls when a user's mouse is over the video. It's used on elements that are shown in front of the video, that might block a mouseover on the video itself from registering.
|
||||
|
||||
controlBar
|
||||
The controlBar behavior is what's added to the main control bar to make it show/hide depending on the user's mouse and the set preferences. It can also be added to other elements if the same effect is desired.
|
||||
|
||||
playButton
|
||||
The playButton behavior can be added to an element to make it play the video when clicked. (See also playToggle)
|
||||
|
||||
pauseButton
|
||||
The pauseButton behavior can be added to an element to make it pause the video when clicked.
|
||||
|
||||
playToggle
|
||||
The playToggle behavior can be added to an element to make it toggle between play and pause. When the video is playing it will pause the video, and vice versa. The play button in the default control bar works this way.
|
||||
The icon in the play button changes to pause (two vertical bars) or play (triangle) depending on the state of the video. This is done through CSS classes. When the video is playing, a class of "vjs-playing" will be added to the playToggle element. When the video is paused, a class of "vjs-paused" will be added to the element. If you are using an image for the icon, set it as a background image of the element (or a sub element) and change the background image accordingly.
|
||||
|
||||
#my_play_toggle.vjs-playing { background-image: url("my-pause-icon.png") }
|
||||
#my_play_toggle.vjs-paused { background-image: url("my-play-icon.png") }
|
||||
|
||||
playProgressBar
|
||||
With the playProgressBar behavior, you can make an element grow like a progress bar as the video plays. The width of the element is set as a percent, and uses the video's current time divided by the video's total duration. For this reason, you may also need a container element to get the desired effect. In this example the width of the playProgressBar will be based on the width of myPlayProgressHolder.
|
||||
<div id="myPlayProgressHolder">
|
||||
<div id="myPlayProgressBar"></div>
|
||||
</div>
|
||||
|
||||
loadProgressBar
|
||||
The loadProgressBar behavior works similarly to the playProgressBar behavior, except that it's based on the amount of video data that's been downloaded to the users machine.
|
||||
|
||||
currentTimeDisplay
|
||||
The currentTimeDisplay behavior will make an element display the video's current playback time in the format of 00:00. It does so by changing the innerHTML of the element to the time.
|
||||
|
||||
durationDisplay
|
||||
The durationDisplay behavior will make an element display the video's duration in the format of 00:00. It does so by changing the innerHTML of the element to the duration.
|
||||
|
||||
currentTimeScrubber
|
||||
The currentTimeScrubber behavior allows you to make an element that controls the current time of the video by clicking and dragging on the element. The current time will be set based on where the user clicks or drags to, in relation to the width of the element.
|
||||
|
||||
volumeDisplay
|
||||
...
|
||||
|
||||
volumeScrubber
|
||||
The volumeScrubber behavior allows you to make an element that controls the volume of the video by clicking and dragging on the element. The volume will be set based on where the user clicks or drags to, in relation to the width of the element.
|
||||
|
||||
fullscreenToggle
|
||||
...
|
||||
|
||||
(Note to self: Have a video that is fixed position beside the behavior docs, that all examples are tied to)
|
||||
@@ -1,9 +0,0 @@
|
||||
Glossary
|
||||
========
|
||||
|
||||
### DOM (Document Object Model)
|
||||
The container of elements on the page that must be loaded before you can interact with the elements with through Javascript.
|
||||
http://en.wikipedia.org/wiki/Document_Object_Model
|
||||
|
||||
### Flash Fallback
|
||||
The Flash video player (SWF) used to play a video when HTML5 isn't supported.
|
||||
@@ -0,0 +1,47 @@
|
||||
---
|
||||
layout: docs
|
||||
title: VideoJS Glossary
|
||||
description: Video.JS Glossary
|
||||
body_id: glossary
|
||||
body_class: docs subpage
|
||||
---
|
||||
|
||||
|
||||
Glossary
|
||||
========
|
||||
|
||||
### DOM (Document Object Model)
|
||||
The container of elements on the page that must be loaded before you can interact with the elements with through Javascript.
|
||||
http://en.wikipedia.org/wiki/Document_Object_Model
|
||||
|
||||
### Flash Fallback
|
||||
The Flash video player (SWF) used to play a video when HTML5 isn't supported.
|
||||
|
||||
<a name="timerange"></a>
|
||||
### TimeRange
|
||||
|
||||
<a name="html5-video"></a>
|
||||
### HTML5 Video
|
||||
HTML is the markup language that makes up every page on the web. The newest version, HTML5, includes specifications for a video tag, that is meant to allow website developers to add a video to a page the same way they would add an image. In order for this to work, web browser developers (Mozilla, Apple, Microsoft, Google, Opera, etc.) have to build the video playback functionality into their browsers. The W3C has created directions on how video should work in browsers, and it’s up to browser developers to follow those directions, so that video works the same across all browsers. This doesn’t always happen thanks to technology, legal, and financial choices made by browser developers, but so far no one’s varying too far from the specifications. However the specifications are still being changed and refined, so browsers developers have to keep up with that as well.
|
||||
|
||||
Playing video in a web page may not seem so special since you can already view video on a web page through plugins like Flash Player, Quicktime, Silverlight, and RealPlayer, however this is a big step forward for standardizing video playback across web browsers and devices. The goal is that in the future, developers will only need to use one method for embedding a video, that’s based on open standards (not controlled by one company), and it will work everywhere.
|
||||
|
||||
A prime example of this is the iPhone and iPad. Apple has decided not to support Flash on their mobile devices, but they do support HTML5 video. Since Flash is currently the most common way video is added to web pages, most web video (aside from YouTube who has a special relationship with Apple) can’t be viewed on the iPhone or iPad. These devices are very popular, so many web sites are switching to hybrid HTML5/Flash player setups (like VideoJS).
|
||||
|
||||
<a name="video-tag"></a>
|
||||
### Video Tag
|
||||
There are a number of great resources that will give you an introduction to the video tag an how it is used including:
|
||||
|
||||
- [Dive into HTML5](http://diveintohtml5.org/video.html)
|
||||
- Lynda.com's ['HTML5 Video and Audio in Depth'](http://www.lynda.com/HTML-5-tutorials/HTML5-Video-and-Audio-in-Depth/80781-2.html) video tutorials created by yours truly.
|
||||
|
||||
An if you really want to dig in, you can read the (W3C Spec)[http://www.w3.org/TR/html5/video.html]. (Warning - not for the faint of heart)
|
||||
|
||||
|
||||
<a name="skin"></a>
|
||||
### Skin
|
||||
"Skin" refers to the design of the player's controls, also sometimes called the chrome. With VideoJS, new skins can be built simply by creating a new stylesheet.
|
||||
|
||||
<a name="cdn"></a>
|
||||
### Content Delivery Network (CDN)
|
||||
A network of servers around the world that host copies of a file. When your browser requests one of these files, the CDN automatically determines which server is closest to your location and delivers the file from there. This drastically increases delivery time, especially internationally.
|
||||
@@ -0,0 +1,29 @@
|
||||
---
|
||||
layout: docs
|
||||
title: Docs
|
||||
description: Video.JS Docs
|
||||
body_id: docs
|
||||
body_class: docs subpage
|
||||
---
|
||||
|
||||
<h1>Start</h1>
|
||||
|
||||
The Video.js documentation is here to help you setup and use the player. These docs can be found and contributed to in the [Video.js library repository](https://github.com/zencoder/video-js/tree/master/docs).
|
||||
|
||||
### [Setup](/docs/setup)
|
||||
Check out the [5 second setup](/#setup) if you're just getting started. The setup documentation gives a deeper view of the additional methods you can use to trigger the player setup.
|
||||
|
||||
### [Options](/docs/options/)
|
||||
There are a number of options that can be used to change how the player behaves, starting with the HTML5 media options like autoplay and preload, and expanding to Video.JS specific options.
|
||||
|
||||
### [API](/docs/api/)
|
||||
The Video.js API allows you to control the video through javascript or trigger event listeners, whether the video is playing through HTML5, flash, or another playback technology.
|
||||
|
||||
### [Skins](/docs/skins/)
|
||||
You can change the look of the player across playback technologies just by editing a CSS file. The skins documentation gives you a intro to how the HTML and CSS of the default skin is put together.
|
||||
|
||||
### [Tech](/docs/tech/)
|
||||
A 'playback technology' is the term we're using to represent HTML5 video, Flash, and other video plugins, as well as other players like the YouTube player. Basically anything that has a unique API to audio or video. Additional playback technologies can be added relatively easily.
|
||||
|
||||
### [Glossary](/docs/glossary/)
|
||||
Some helpful definitions.
|
||||
@@ -0,0 +1,30 @@
|
||||
---
|
||||
layout: docs
|
||||
title: Options
|
||||
description: Player Options
|
||||
body_id: options
|
||||
body_class: docs subpage
|
||||
---
|
||||
|
||||
Options
|
||||
=======
|
||||
|
||||
The Video.js emebed code is simply an HTML5 video tag with the video.js classes. So for many of the options you can use the standard tag attributes to set video.js options.
|
||||
|
||||
{% highlight html %}
|
||||
<video controls autoplay preload="auto" ...>
|
||||
{% endhighlight %}
|
||||
|
||||
Alternatively, you can use the data-setup attribute to provide options in the JSON format. This is also how you would set options that aren't standard to the video tag.
|
||||
|
||||
{% highlight html %}
|
||||
<video data-setup='{ "controls": true, "autoplay": false, "preload": "auto" }'...>
|
||||
{% endhighlight %}
|
||||
|
||||
Finally, if you're not using the data-setup attribute to trigger the player setup, you can pass in an object with the player options as the second argument in the setup function.
|
||||
|
||||
{% highlight javascript %}
|
||||
_V_("myVideoID", { "controls": true, "autoplay": false, "preload": "auto" });
|
||||
{% endhighlight %}
|
||||
|
||||
(More options documentation coming soon.)
|
||||
@@ -0,0 +1,50 @@
|
||||
---
|
||||
layout: docs
|
||||
title: Setup
|
||||
description: Setup
|
||||
body_id: setup
|
||||
body_class: docs subpage
|
||||
---
|
||||
|
||||
Setup
|
||||
=====
|
||||
|
||||
Video.js is pretty easy to set up. It can take a matter of seconds to get the player up and working on your web page.
|
||||
|
||||
Step 1: Include the Video.js Javascript and CSS files in the head of your page.
|
||||
------------------------------------------------------------------------------
|
||||
You can download the Video.js source and host it on your own servers, or use the free CDN hosted version (thanks to Zencoder). It's often recommended now to put JavaScript before the end \</body\> tag instead of the head but Video.js includes an 'HTML5 Shiv', which needs to be in the \<head\> for older IE versions. If you
|
||||
|
||||
{% highlight html %}
|
||||
|
||||
<script src="http://vjs.zencdn.com/c/video.js"></script>
|
||||
<link href="http://vjs.zencdn.com/c/video-js.css" rel="stylesheet">
|
||||
|
||||
{% endhighlight %}
|
||||
|
||||
|
||||
Step 2: Add an HTML5 video tag to your page.
|
||||
--------------------------------------------
|
||||
Use the video tag as normal, with a few extra pieces for Video.js:
|
||||
|
||||
1. The 'data-setup' Atrribute tells Video.js to automatically set up the video when the page is ready, and read any options (in JSON format) from the attribute (see ['options'](http://videojs.com/docs/options.html)).
|
||||
2. The 'id' Attribute: Should be used and unique for every video on the same page.
|
||||
3. The 'class' attribute contains two classes:
|
||||
- 'video-js' applies styles that are required for Video.js functionality, like fullscreen and subtitles.
|
||||
- 'vjs-default-skin' applies the default skin to the HTML controls, and can be removed or overridden to create your own controls design.
|
||||
|
||||
Otherwise include/exclude attributes, settings, sources, and tracks exactly as you would for HTML5 video (see ['video-tag'](http://videojs.com/docs/video-tag.html)).
|
||||
|
||||
{% highlight html %}
|
||||
|
||||
<video id="example_video_1" class="video-js vjs-default-skin"
|
||||
controls preload="auto" width="640" height="264"
|
||||
poster="http://video-js.zencoder.com/oceans-clip.png"
|
||||
data-setup='{"example_option":true}'>
|
||||
<source src="http://video-js.zencoder.com/oceans-clip.mp4" type='video/mp4' />
|
||||
<source src="http://video-js.zencoder.com/oceans-clip.webm" type='video/webm' />
|
||||
<source src="http://video-js.zencoder.com/oceans-clip.ogv" type='video/ogg' />
|
||||
</video>
|
||||
|
||||
{% endhighlight %}
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
---
|
||||
layout: docs
|
||||
title: Skins
|
||||
description: Controls Skins, Chrome, Design, look-and-feel.
|
||||
body_id: skins
|
||||
body_class: docs subpage
|
||||
---
|
||||
|
||||
Skins
|
||||
=====
|
||||
|
||||
The default Video.js skin is made using HTML and CSS, so there's no need to learn a complicated skinning language to update colors or even create an entirely new skin. New in version 3.0 is the use of a sprites image file (video-js.png). The image allows for a little bit more classy design, as well as compatibility with older versions of IE now that the HTML skin also shows when Flash is used for those browsers.
|
||||
|
||||
You can view the uncompressed CSS for the default skin by downloading the latest version of Video.js or viewing [the source version](https://github.com/zencoder/video-js/blob/master/design/video-js.css) on Github.
|
||||
|
||||
You can either override styles in the default skin:
|
||||
|
||||
{% highlight css %}
|
||||
|
||||
.vjs-default-skin .vjs-play-progress { background: #900; }
|
||||
|
||||
{% endhighlight %}
|
||||
|
||||
Or remove the 'vjs-default-skin' class from the video tag and create your own skin.
|
||||
|
||||
{% highlight html %}
|
||||
|
||||
<video class="video-js my-custom-skin" ...>
|
||||
|
||||
{% endhighlight %}
|
||||
|
||||
More custom skins will be available for download soon. If you have one you'd like to contribute back, please email it to <script type="text/javascript">eval(decodeURIComponent('%64%6f%63%75%6d%65%6e%74%2e%77%72%69%74%65%28%27%3c%61%20%68%72%65%66%3d%22%6d%61%69%6c%74%6f%3a%73%6b%69%6e%73%40%76%69%64%65%6f%6a%73%2e%63%6f%6d%22%3e%73%6b%69%6e%73%40%76%69%64%65%6f%6a%73%2e%63%6f%6d%3c%2f%61%3e%27%29%3b'))</script>.
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
---
|
||||
layout: docs
|
||||
title: Playback Technology
|
||||
description: Video.js Playback Technology
|
||||
body_id: tech
|
||||
body_class: docs subpage
|
||||
---
|
||||
|
||||
Playback Technology ("Tech")
|
||||
============================
|
||||
Playback Technology refers to the specific browser or plugin technology used to play the video or audio. When using HTML5, the playback technology is the video or audio element. When using Flash, the playback technology is the specific Flash player used, e.g. Flowplayer, YouTube Player, video-js.swf, etc. (not just "Flash"). This could also include Silverlight, Quicktime, or any other plugin that will play back video in the browser, as long as there is an API wrapper written for it.
|
||||
|
||||
Essentially we're using HTML5 and plugins only as video decoders, and using HTML and JavaScript to create a consistent API and skinning experience across all of them.
|
||||
|
||||
Building an API Wrapper
|
||||
-----------------------
|
||||
We'll write a more complete guide on writing a wrapper soon, but for now the best resource is the [Video.js](https://github.com/zencoder/video-js/tree/master/src) source where you can see how both the HTML5 and video-js.swf API wrappers were created.
|
||||
|
||||
Required Methods
|
||||
----------------
|
||||
canPlayType
|
||||
play
|
||||
pause
|
||||
currentTime
|
||||
volume
|
||||
duration
|
||||
buffered
|
||||
supportsFullScreen
|
||||
|
||||
Required Events
|
||||
---------------
|
||||
loadstart
|
||||
play
|
||||
pause
|
||||
playing
|
||||
ended
|
||||
volumechange
|
||||
durationchange
|
||||
error
|
||||
|
||||
Optional Events (include if supported)
|
||||
--------------------------------------
|
||||
timeupdate
|
||||
progress
|
||||
enterFullScreen
|
||||
exitFullScreen
|
||||
Diff do arquivo suprimido porque uma ou mais linhas são muito longas
Arquivo binário não exibido.
-116
@@ -1,116 +0,0 @@
|
||||
/*
|
||||
VideoJS HuCSS Skin (http://videojs.com)
|
||||
Version 2.0.0
|
||||
*/
|
||||
|
||||
.hu-css .vjs-controls {
|
||||
height: 47px; opacity: 0.95; color: #fff;
|
||||
background: #3A3835;
|
||||
}
|
||||
.hu-css.video-js-box.vjs-controls-below .vjs-controls { background: #3A3835; }
|
||||
|
||||
.hu-css .vjs-controls > div {
|
||||
top: 0;
|
||||
background: none;
|
||||
-webkit-border-radius: 0; -moz-border-radius: 0; border-radius: 0;
|
||||
-webkit-box-shadow: none; -moz-box-shadow: none; box-shadow: none;
|
||||
}
|
||||
|
||||
/* Top Level Items */
|
||||
.hu-css .vjs-controls > div.vjs-play-control,
|
||||
.hu-css .vjs-controls > div.vjs-volume-control,
|
||||
.hu-css .vjs-controls > div.vjs-fullscreen-control {
|
||||
bottom: 20px; height: 27px;
|
||||
}
|
||||
/* Bottom Level Items */
|
||||
.hu-css .vjs-controls > div.vjs-progress-control, .hu-css .vjs-controls > div.vjs-time-control {
|
||||
margin-top: 28px; height: 19px;
|
||||
}
|
||||
|
||||
/* Placement of Control Items */
|
||||
.hu-css .vjs-controls > div.vjs-play-control { width: 33px; left: 0px; }
|
||||
.hu-css .vjs-controls > div.vjs-progress-control { width: left: 84px; right: 0; }
|
||||
.hu-css .vjs-controls > div.vjs-time-control { width: 84px; left: 0px; }
|
||||
.hu-css .vjs-controls > div.vjs-volume-control { width: 43px; right: 44px; }
|
||||
.hu-css .vjs-controls > div.vjs-fullscreen-control { width: 43px; right: 0px; }
|
||||
|
||||
/* Play/Pause
|
||||
-------------------------------------------------------------------------------- */
|
||||
.hu-css.vjs-paused .vjs-play-control span { margin: 9px 0 0 12px; }
|
||||
.hu-css.vjs-playing .vjs-play-control span { margin: 9px 0 0 12px; }
|
||||
.hu-css .vjs-play-control:hover { background-color: #000; }
|
||||
|
||||
/* Progress
|
||||
-------------------------------------------------------------------------------- */
|
||||
.hu-css .vjs-progress-holder { /* Box containing play and load progresses */
|
||||
height: 19px; border: none;
|
||||
margin: 0px 0px 0 0px; /* Placement within the progress control item */
|
||||
background: #000;
|
||||
-webkit-border-radius: 0; -moz-border-radius: 0; border-radius: 0;
|
||||
}
|
||||
.hu-css .vjs-progress-holder div { height: 13px; margin-top: 3px; -webkit-border-radius: 0; -moz-border-radius: 0; border-radius: 0; }
|
||||
.hu-css .vjs-play-progress {
|
||||
/* Default */ background: #777;
|
||||
/* Webkit */ background: -webkit-gradient(linear, left top, left bottom, from(#999), to(#777));
|
||||
/* Firefox */ background: -moz-linear-gradient(top, #999, #777);
|
||||
}
|
||||
.hu-css .vjs-load-progress { background: #555; }
|
||||
|
||||
/* Time Display
|
||||
-------------------------------------------------------------------------------- */
|
||||
.hu-css .vjs-controls .vjs-time-control { font-size: 11px; background: #000; }
|
||||
.hu-css .vjs-controls .vjs-time-control span { line-height: 19px; /* Centering vertically */ }
|
||||
|
||||
/* Volume
|
||||
-------------------------------------------------------------------------------- */
|
||||
/*.hu-css .vjs-volume-control:hover { background-color: #000; }*/
|
||||
.hu-css .vjs-volume-control div { margin: 0 5px 0 5px; padding: 9px 0 0 0; }
|
||||
.hu-css .vjs-volume-control div span { /* Individual volume bars */
|
||||
margin: 0 2px 0 0; /* Space between */
|
||||
width: 3px; height: 0px; /* Total height is height + bottom border */
|
||||
border-bottom: 12px solid #555; /* Default (off) color and height of visible portion */
|
||||
}
|
||||
.hu-css .vjs-volume-control div span.vjs-volume-level-on { border-color: #fff; /* Volume on bar color */ }
|
||||
/* Creating differnt bar heights through height (transparent) and bottom border (visible). */
|
||||
.hu-css .vjs-volume-control div span:nth-child(1) { border-bottom-width: 2px; height: 10px; }
|
||||
.hu-css .vjs-volume-control div span:nth-child(2) { border-bottom-width: 4px; height: 8px; }
|
||||
.hu-css .vjs-volume-control div span:nth-child(3) { border-bottom-width: 6px; height: 6px; }
|
||||
.hu-css .vjs-volume-control div span:nth-child(4) { border-bottom-width: 8px; height: 4px; }
|
||||
.hu-css .vjs-volume-control div span:nth-child(5) { border-bottom-width: 10px; height: 2px; }
|
||||
|
||||
/* Fullscreen
|
||||
-------------------------------------------------------------------------------- */
|
||||
.hu-css .vjs-fullscreen-control:hover { background-color: #000; }
|
||||
.hu-css .vjs-fullscreen-control div { margin: 8px 0 0 0px; padding-left: 13px; height: 13px; border-left: 1px solid #555; }
|
||||
.hu-css .vjs-fullscreen-control div span:nth-child(1) { margin-right: 9px; margin-bottom: 5px; border-top: 4px solid #fff; border-right: 4px solid rgba(0,0,0,0); }
|
||||
.hu-css .vjs-fullscreen-control div span:nth-child(2) { border-top: 4px solid #fff; border-left: 4px solid rgba(0,0,0,0); }
|
||||
.hu-css .vjs-fullscreen-control div span:nth-child(3) { clear: both; margin: 0 9px 0 0; border-bottom: 4px solid #fff; border-right: 4px solid rgba(0,0,0,0); }
|
||||
.hu-css .vjs-fullscreen-control div span:nth-child(4) { border-bottom: 4px solid #fff; border-left: 4px solid rgba(0,0,0,0); }
|
||||
/* Icon when video is in fullscreen mode */
|
||||
.hu-css.vjs-fullscreen .vjs-fullscreen-control div span:nth-child(1) { border: none; border-bottom: 4px solid #fff; border-left: 4px solid rgba(0,0,0,0); }
|
||||
.hu-css.vjs-fullscreen .vjs-fullscreen-control div span:nth-child(2) { border: none; border-bottom: 4px solid #fff; border-right: 4px solid rgba(0,0,0,0); }
|
||||
.hu-css.vjs-fullscreen .vjs-fullscreen-control div span:nth-child(3) { border: none; border-top: 4px solid #fff; border-left: 4px solid rgba(0,0,0,0); }
|
||||
.hu-css.vjs-fullscreen .vjs-fullscreen-control div span:nth-child(4) { border: none; border-top: 4px solid #fff; border-right: 4px solid rgba(0,0,0,0); }
|
||||
|
||||
/* Big Play Button (at start)
|
||||
---------------------------------------------------------*/
|
||||
.hu-css div.vjs-big-play-button {
|
||||
width: 76px; height: 70px; margin: -35px 0 0 -38px;
|
||||
border: 1px solid #ccc; opacity: 0.8;
|
||||
-webkit-border-radius: 0px; -moz-border-radius: 0px; border-radius: 0px;
|
||||
|
||||
background: rgba(50,50,50,0.8);
|
||||
|
||||
/* CSS Shadows */
|
||||
-webkit-box-shadow: none; -moz-box-shadow: none; box-shadow: none;
|
||||
}
|
||||
.hu-css div.vjs-big-play-button:hover {
|
||||
-webkit-box-shadow: 0px 0px 80px #fff; -moz-box-shadow: 0px 0px 80px #fff; box-shadow: 0px 0px 80px #fff;
|
||||
}
|
||||
.hu-css div.vjs-big-play-button span {
|
||||
margin: 16px 0 0 21px;
|
||||
/* Drawing the play triangle with borders - http://www.infimum.dk/HTML/slantinfo.html */
|
||||
border-left: 40px solid #fff; /* Width & Color of play icon */
|
||||
/* Height of play icon is total top & bottom border widths. Color is transparent. */
|
||||
border-top: 20px solid rgba(0,0,0,0); border-bottom: 20px solid rgba(0,0,0,0);
|
||||
}
|
||||
@@ -1,111 +0,0 @@
|
||||
/*
|
||||
VideoJS TubeCSS Skin (http://videojs.com)
|
||||
Version 2.0.0
|
||||
*/
|
||||
|
||||
.tube-css .vjs-controls {
|
||||
opacity: 1; color: #000;
|
||||
height: 24px;
|
||||
bottom: 0;
|
||||
background-color: #ccc;
|
||||
background: #fcfcfc -webkit-gradient(linear, left top, left bottom, from(#fcfcfc), to(#d0d0d0)) left top;
|
||||
background: #fcfcfc -moz-linear-gradient(top, #fcfcfc, #d0d0d0) left top;
|
||||
}
|
||||
|
||||
.tube-css .vjs-controls > div {
|
||||
height: 23px; margin: 0; background: none; top: 0;
|
||||
border: 1px solid #b1b1b1; border-left-color: #eee;
|
||||
-webkit-border-radius: 0; -moz-border-radius: 0; border-radius: 0;
|
||||
-webkit-box-shadow: none; -moz-box-shadow: none; box-shadow: none;
|
||||
}
|
||||
|
||||
/* Placement of Control Items */
|
||||
.tube-css .vjs-controls > div.vjs-play-control { width: 25px; left: 0; }
|
||||
.tube-css .vjs-controls > div.vjs-progress-control { left: 102px; right: 83px; }
|
||||
.tube-css .vjs-controls > div.vjs-time-control { width: 75px; left: 27px; }
|
||||
.tube-css .vjs-controls > div.vjs-volume-control { width: 50px; right: 30px; }
|
||||
.tube-css .vjs-controls > div.vjs-fullscreen-control { width: 30px; right: 0; }
|
||||
|
||||
/* Removing borders on time & progress to join them */
|
||||
.tube-css .vjs-controls > div.vjs-progress-control { border-left: none; }
|
||||
.tube-css .vjs-controls > div.vjs-time-control { border-right: none; }
|
||||
|
||||
|
||||
/* Play/Pause
|
||||
-------------------------------------------------------------------------------- */
|
||||
.tube-css .vjs-play-control { margin-left: 0; border-left-color: #b1b1b1; }
|
||||
.tube-css.vjs-paused .vjs-play-control span { border-left-color: #333; border-top-width: 7px; border-left-width: 13px; border-bottom-width: 7px; margin: 5px 0 0 7px; }
|
||||
.tube-css.vjs-playing .vjs-play-control span { height: 14px; margin: 5px auto 0; border-left: 4px solid #333; border-right: 4px solid #333; }
|
||||
.tube-css.vjs-paused .vjs-play-control:hover span { border-left-color: #CF1A1A; }
|
||||
.tube-css.vjs-playing .vjs-play-control:hover span { border-left-color: #CF1A1A; border-right-color: #CF1A1A; }
|
||||
|
||||
/* Time Display
|
||||
-------------------------------------------------------------------------------- */
|
||||
.tube-css .vjs-controls .vjs-time-control { font-size: 11px; }
|
||||
.tube-css .vjs-controls .vjs-time-control span { line-height: 25px; /* Centering vertically */ }
|
||||
|
||||
/* Progress
|
||||
-------------------------------------------------------------------------------- */
|
||||
.tube-css .vjs-progress-holder {
|
||||
margin-right: 10px;
|
||||
background-color: #b1b1b1;
|
||||
background: #b1b1b1 -webkit-gradient(linear, left top, left bottom, from(#b1b1b1), to(#cacaca)) left top;
|
||||
background: #b1b1b1 -moz-linear-gradient(top, #b1b1b1, #cacaca) left top;
|
||||
border-color: #CACACA; border-bottom-color: #eaeaea;
|
||||
-webkit-border-radius: 0; -moz-border-radius: 0; border-radius: 0;
|
||||
}
|
||||
.tube-css .vjs-progress-control .vjs-load-progress { background: #C89191; -webkit-border-radius: 0; -moz-border-radius: 0; border-radius: 0; }
|
||||
.tube-css .vjs-progress-control .vjs-play-progress { background: #f33; background: -webkit-gradient(linear, left top, left bottom, from(#f33), to(#CF1A1A)); background: -moz-linear-gradient(top, #f33, #CF1A1A); -webkit-border-radius: 0; -moz-border-radius: 0; border-radius: 0; }
|
||||
|
||||
/* Volume
|
||||
-------------------------------------------------------------------------------- */
|
||||
.tube-css .vjs-volume-control div { padding: 3px 0 0 0; }
|
||||
.tube-css .vjs-volume-control div span { border-bottom-color: #ccc; }
|
||||
/* Volume icon color */
|
||||
.tube-css .vjs-volume-control div span.vjs-volume-level-on { border-color: #333; }
|
||||
/* Volume icon hovering color */
|
||||
.tube-css .vjs-volume-control:hover div span.vjs-volume-level-on { border-color: #CF1A1A; }
|
||||
|
||||
/* Fullscreen
|
||||
-------------------------------------------------------------------------------- */
|
||||
.tube-css .vjs-fullscreen-control div { margin: 4px 0 0 8px; }
|
||||
/* Fullscreen icon color */
|
||||
.tube-css .vjs-fullscreen-control div span:nth-child(3), .tube-css .vjs-fullscreen-control div span:nth-child(4), .tube-css.vjs-fullscreen .vjs-fullscreen-control div span:nth-child(1), .tube-css.vjs-fullscreen .vjs-fullscreen-control div span:nth-child(2) {
|
||||
border-bottom-color: #333;
|
||||
}
|
||||
.tube-css .vjs-fullscreen-control div span:nth-child(1), .tube-css .vjs-fullscreen-control div span:nth-child(2), .tube-css.vjs-fullscreen .vjs-fullscreen-control div span:nth-child(3), .tube-css.vjs-fullscreen .vjs-fullscreen-control div span:nth-child(4) {
|
||||
border-top-color: #333;
|
||||
}
|
||||
/* Fullscreen icon hovering color */
|
||||
.tube-css .vjs-fullscreen-control:hover div span:nth-child(3), .tube-css .vjs-fullscreen-control:hover div span:nth-child(4), .tube-css.vjs-fullscreen .vjs-fullscreen-control:hover div span:nth-child(1), .tube-css.vjs-fullscreen .vjs-fullscreen-control:hover div span:nth-child(2) {
|
||||
border-bottom-color: #CF1A1A;
|
||||
}
|
||||
.tube-css .vjs-fullscreen-control:hover div span:nth-child(1), .tube-css .vjs-fullscreen-control:hover div span:nth-child(2), .tube-css.vjs-fullscreen .vjs-fullscreen-control:hover div span:nth-child(3), .tube-css.vjs-fullscreen .vjs-fullscreen-control:hover div span:nth-child(4) {
|
||||
border-top-color: #CF1A1A;
|
||||
}
|
||||
|
||||
/* Big Play Button (at start)
|
||||
---------------------------------------------------------*/
|
||||
.tube-css div.vjs-big-play-button {
|
||||
width: 84px; height: 58px; margin: -29px 0 0 -42px;
|
||||
border: 2px solid #ccc; opacity: 0.9;
|
||||
-webkit-border-radius: 10px; -moz-border-radius: 10px; border-radius: 10px;
|
||||
|
||||
/* CSS Background Gradients */
|
||||
/* Default */ background-color: #333;
|
||||
/* Webkit */ background: #000 -webkit-gradient(linear, left top, left bottom, from(#000), to(#333)) left 29px;
|
||||
/* Firefox */ background: #000 -moz-linear-gradient(top, #000, #333) left 29px;
|
||||
|
||||
/* CSS Shadows */
|
||||
-webkit-box-shadow: none; -moz-box-shadow: none; box-shadow: none;
|
||||
}
|
||||
.tube-css div.vjs-big-play-button:hover {
|
||||
opacity: 1;
|
||||
}
|
||||
.tube-css div.vjs-big-play-button span {
|
||||
margin: 11px 0 0 26px;
|
||||
/* Drawing the play triangle with borders - http://www.infimum.dk/HTML/slantinfo.html */
|
||||
border-left: 36px solid #fff; /* Width & Color of play icon */
|
||||
/* Height of play icon is total top & bottom border widths. Color is transparent. */
|
||||
border-top: 18px solid rgba(0,0,0,0); border-bottom: 18px solid rgba(0,0,0,0);
|
||||
}
|
||||
@@ -1,89 +0,0 @@
|
||||
/*
|
||||
VideoJS VimCSS Skin (http://videojs.com)
|
||||
Version 2.0.0
|
||||
*/
|
||||
|
||||
.vim-css .vjs-controls {
|
||||
height: 60px; opacity: 0.9; color: #fff;
|
||||
}
|
||||
.vim-css .vjs-controls > div {
|
||||
height: 32px; top: 18px; padding: 0; text-align: center; background: rgba(23, 35, 34, 0.746094);
|
||||
-webkit-border-radius: 0; -moz-border-radius: 0; border-radius: 0;
|
||||
-webkit-box-shadow: none; -moz-box-shadow: none; box-shadow: none;
|
||||
}
|
||||
/* Placement of Control Items */
|
||||
.vim-css .vjs-controls > div.vjs-play-control { width: 65px; left: 10px; }
|
||||
.vim-css .vjs-controls > div.vjs-progress-control { left: 85px; right: 160px; }
|
||||
.vim-css .vjs-controls > div.vjs-time-control { width: 75px; right: 85px; }
|
||||
.vim-css .vjs-controls > div.vjs-volume-control { width: 50px; right: 35px; }
|
||||
.vim-css .vjs-controls > div.vjs-fullscreen-control { width: 25px; right: 10px; }
|
||||
|
||||
/* Play/Pause
|
||||
-------------------------------------------------------------------------------- */
|
||||
.vim-css .vjs-controls .vjs-play-control { top: 10px; margin: 0; height: 40px; -webkit-border-radius: 5px; -moz-border-radius: 5px; border-radius: 5px; }
|
||||
.vim-css .vjs-play-control:hover { background: #00ADEF; }
|
||||
.vim-css.vjs-paused .vjs-play-control span { border-left-color: #fff; border-top-width: 9px; border-left-width: 18px; border-bottom-width: 9px; margin: 11px 0 0 24px; }
|
||||
.vim-css.vjs-playing .vjs-play-control span { width: 5px; height: 18px; margin: 5px auto 0; border-left: 5px solid #fff; border-right: 5px solid #fff; margin: 11px 0 0 24px; }
|
||||
|
||||
/* Progress
|
||||
-------------------------------------------------------------------------------- */
|
||||
.vim-css .vjs-controls .vjs-progress-control { -webkit-border-radius: 5px 0 0 5px; -moz-border-radius: 5px 0 0 5px; border-radius: 5px 0 0 5px; }
|
||||
.vim-css .vjs-progress-control .vjs-progress-holder { height: 8px; padding: 1px; margin: 10px 5px 0 10px; border-color: #666666; -webkit-border-radius: 0; -moz-border-radius: 0; border-radius: 0; }
|
||||
.vim-css .vjs-progress-control .vjs-play-progress { height: 8px; background: #00ADEF; -webkit-border-radius: 0; -moz-border-radius: 0; border-radius: 0; }
|
||||
.vim-css .vjs-progress-control .vjs-load-progress { height: 8px; background: #898F8F; -webkit-border-radius: 0; -moz-border-radius: 0; border-radius: 0; }
|
||||
|
||||
/* Time Display
|
||||
-------------------------------------------------------------------------------- */
|
||||
.vim-css .vjs-controls .vjs-time-control { font-size: 11px; }
|
||||
.vim-css .vjs-controls .vjs-time-control span { line-height: 32px; /* Centering vertically */ }
|
||||
|
||||
/* Volume
|
||||
-------------------------------------------------------------------------------- */
|
||||
.vim-css .vjs-volume-control div { padding: 7px 0 0 5px; width: 30px; }
|
||||
.vim-css .vjs-volume-control div span {
|
||||
float: left; margin: 0 2px 0 0; padding: 0; width: 3px; height: 3px; border-bottom: 12px solid #666666;
|
||||
-webkit-transition: all 100ms linear; -moz-transition: all 100ms linear;
|
||||
}
|
||||
.vim-css .vjs-volume-control div span.vjs-volume-level-on { border-color: #00ADEF; }
|
||||
.vim-css .vjs-volume-control div span:hover { height: 0; border-bottom-width: 15px; }
|
||||
|
||||
/* Fullscreen
|
||||
-------------------------------------------------------------------------------- */
|
||||
.vim-css .vjs-fullscreen-control div { margin: 10px 0 0 0; }
|
||||
.vim-css .vjs-controls .vjs-fullscreen-control { -webkit-border-radius: 0 5px 5px 0; -moz-border-radius: 0 5px 5px 0; border-radius: 0 5px 5px 0; }
|
||||
/* Making default fullscreen icon smaller */
|
||||
.vim-css .vjs-fullscreen-control div span:nth-child(1) { margin: 0 4px 4px 0; border: none; border-top: 4px solid #fff; border-right: 4px solid rgba(0,0,0,0); }
|
||||
.vim-css .vjs-fullscreen-control div span:nth-child(2) { border: none; border-top: 4px solid #fff; border-left: 4px solid rgba(0,0,0,0); }
|
||||
.vim-css .vjs-fullscreen-control div span:nth-child(3) { clear: both; margin: 0 4px 0 0; border: none; border-bottom: 4px solid #fff; border-right: 4px solid rgba(0,0,0,0); }
|
||||
.vim-css .vjs-fullscreen-control div span:nth-child(4) { border: none; border-bottom: 4px solid #fff; border-left: 4px solid rgba(0,0,0,0); }
|
||||
.vim-css.vjs-fullscreen .vjs-fullscreen-control div span:nth-child(1) { border: none; border-bottom: 4px solid #fff; border-left: 4px solid rgba(0,0,0,0); }
|
||||
.vim-css.vjs-fullscreen .vjs-fullscreen-control div span:nth-child(2) { border: none; border-bottom: 4px solid #fff; border-right: 4px solid rgba(0,0,0,0); }
|
||||
.vim-css.vjs-fullscreen .vjs-fullscreen-control div span:nth-child(3) { border: none; border-top: 4px solid #fff; border-left: 4px solid rgba(0,0,0,0); }
|
||||
.vim-css.vjs-fullscreen .vjs-fullscreen-control div span:nth-child(4) { border: none; border-top: 4px solid #fff; border-right: 4px solid rgba(0,0,0,0); }
|
||||
/* Fullscreen control hovering */
|
||||
.vim-css .vjs-fullscreen-control:hover div span:nth-child(3), .vim-css .vjs-fullscreen-control:hover div span:nth-child(4), .vim-css.vjs-fullscreen .vjs-fullscreen-control:hover div span:nth-child(1), .vim-css.vjs-fullscreen .vjs-fullscreen-control:hover div span:nth-child(2) { border-bottom-color: #00ADEF; }
|
||||
.vim-css .vjs-fullscreen-control:hover div span:nth-child(1), .vim-css .vjs-fullscreen-control:hover div span:nth-child(2), .vim-css.vjs-fullscreen .vjs-fullscreen-control:hover div span:nth-child(3), .vim-css.vjs-fullscreen .vjs-fullscreen-control:hover div span:nth-child(4) { border-top-color: #00ADEF; }
|
||||
|
||||
/* Big Play Button (at start)
|
||||
---------------------------------------------------------*/
|
||||
.vim-css div.vjs-big-play-button {
|
||||
width: 130px; height: 80px; margin: -40px 0 0 -65px;
|
||||
border: none; opacity: 0.9;
|
||||
-webkit-border-radius: 10px; -moz-border-radius: 10px; border-radius: 10px;
|
||||
|
||||
background: rgba(23, 35, 34, 0.746094);
|
||||
|
||||
/* CSS Shadows */
|
||||
-webkit-box-shadow: none; -moz-box-shadow: none; box-shadow: none;
|
||||
}
|
||||
.vim-css div.vjs-big-play-button:hover {
|
||||
background: #00ADEF;
|
||||
opacity: 1;
|
||||
}
|
||||
.vim-css div.vjs-big-play-button span {
|
||||
margin: 22px 0 0 48px;
|
||||
/* Drawing the play triangle with borders - http://www.infimum.dk/HTML/slantinfo.html */
|
||||
border-left: 36px solid #fff; /* Width & Color of play icon */
|
||||
/* Height of play icon is total top & bottom border widths. Color is transparent. */
|
||||
border-top: 18px solid rgba(0,0,0,0); border-bottom: 18px solid rgba(0,0,0,0);
|
||||
}
|
||||
@@ -1,24 +1,25 @@
|
||||
/*
|
||||
VideoJS - HTML5 Video Player
|
||||
v2.0.2
|
||||
/*!
|
||||
Video.js - HTML5 Video Player
|
||||
Version 3.0r2
|
||||
|
||||
This file is part of VideoJS. Copyright 2010 Zencoder, Inc.
|
||||
LGPL v3 LICENSE INFO
|
||||
This file is part of Video.js. Copyright 2011 Zencoder, Inc.
|
||||
|
||||
VideoJS is free software: you can redistribute it and/or modify
|
||||
Video.js is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
VideoJS is distributed in the hope that it will be useful,
|
||||
Video.js is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with VideoJS. If not, see <http://www.gnu.org/licenses/>.
|
||||
along with Video.js. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
// Self-executing function to prevent global vars and help with minification
|
||||
(function(window, undefined){
|
||||
;(function(window, undefined){
|
||||
var document = window.document;
|
||||
|
||||
@@ -2,5 +2,8 @@
|
||||
// Expose to global
|
||||
window.VideoJS = window._V_ = VideoJS;
|
||||
|
||||
// Run Auto-load players
|
||||
_V_.autoSetup();
|
||||
|
||||
// End self-executing function
|
||||
})(window);
|
||||
@@ -0,0 +1,188 @@
|
||||
// Using John Resig's Class implementation http://ejohn.org/blog/simple-javascript-inheritance/
|
||||
// (function(){var initializing=false, fnTest=/xyz/.test(function(){xyz;}) ? /\b_super\b/ : /.*/; _V_.Class = function(){}; _V_.Class.extend = function(prop) { var _super = this.prototype; initializing = true; var prototype = new this(); initializing = false; for (var name in prop) { prototype[name] = typeof prop[name] == "function" && typeof _super[name] == "function" && fnTest.test(prop[name]) ? (function(name, fn){ return function() { var tmp = this._super; this._super = _super[name]; var ret = fn.apply(this, arguments); this._super = tmp; return ret; }; })(name, prop[name]) : prop[name]; } function Class() { if ( !initializing && this.init ) this.init.apply(this, arguments); } Class.prototype = prototype; Class.constructor = Class; Class.extend = arguments.callee; return Class;};})();
|
||||
(function(){
|
||||
var initializing = false, fnTest = /xyz/.test(function(){xyz;}) ? /\b_super\b/ : /.*/;
|
||||
_V_.Class = function(){};
|
||||
_V_.Class.extend = function(prop) {
|
||||
var _super = this.prototype;
|
||||
initializing = true;
|
||||
var prototype = new this();
|
||||
initializing = false;
|
||||
for (var name in prop) {
|
||||
prototype[name] = typeof prop[name] == "function" &&
|
||||
typeof _super[name] == "function" && fnTest.test(prop[name]) ?
|
||||
(function(name, fn){
|
||||
return function() {
|
||||
var tmp = this._super;
|
||||
this._super = _super[name];
|
||||
var ret = fn.apply(this, arguments);
|
||||
this._super = tmp;
|
||||
return ret;
|
||||
};
|
||||
})(name, prop[name]) :
|
||||
prop[name];
|
||||
}
|
||||
function Class() {
|
||||
if ( !initializing && this.init ) {
|
||||
return this.init.apply(this, arguments);
|
||||
|
||||
// Attempting to recreate accessing function form of class.
|
||||
} else if (!initializing) {
|
||||
return arguments.callee.prototype.init()
|
||||
}
|
||||
}
|
||||
Class.prototype = prototype;
|
||||
Class.constructor = Class;
|
||||
Class.extend = arguments.callee;
|
||||
return Class;
|
||||
};
|
||||
})();
|
||||
|
||||
/* Player Component- Base class for all UI objects
|
||||
================================================================================ */
|
||||
_V_.Component = _V_.Class.extend({
|
||||
|
||||
init: function(player, options){
|
||||
this.player = player;
|
||||
|
||||
if (options && options.el) {
|
||||
this.el = options.el;
|
||||
} else {
|
||||
this.el = this.createElement();
|
||||
}
|
||||
|
||||
// Array of sub-components
|
||||
if (options && options.components) {
|
||||
_V_.each.call(this, options.components, function(comp){
|
||||
this.addComponent(comp);
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
destroy: function(){},
|
||||
|
||||
createElement: function(type, attrs){
|
||||
return _V_.createElement(type || "div", attrs);
|
||||
},
|
||||
|
||||
buildCSSClass: function(){
|
||||
// Child classes can include a function that does:
|
||||
// return "CLASS NAME" + this._super();
|
||||
return "";
|
||||
},
|
||||
|
||||
// Add child components to this component.
|
||||
// Will generate a new child component and then append child component's element to this component's element.
|
||||
// Takes either the name of the UI component class, or an object that contains a name, UI Class, and options.
|
||||
addComponent: function(nameORobj){
|
||||
var name, componentClass, options, component;
|
||||
|
||||
if (typeof nameORobj == "string") {
|
||||
name = nameORobj;
|
||||
|
||||
// Can also pass in object to define a different class than the name and add other options
|
||||
} else {
|
||||
name = nameORobj.name;
|
||||
componentClass = nameORobj.componentClass;
|
||||
options = nameORobj.options;
|
||||
}
|
||||
|
||||
if (!componentClass) {
|
||||
// Assume name of set is a lowercased name of the UI Class (PlayButton, etc.)
|
||||
componentClass = _V_.capitalize(name);
|
||||
}
|
||||
|
||||
// Create a new object & element for this controls set
|
||||
// If there's no .player, this is a player
|
||||
component = new _V_[componentClass](this.player || this, options);
|
||||
|
||||
if (this.components === undefined) {
|
||||
this.components = [];
|
||||
}
|
||||
this.components.push(component);
|
||||
|
||||
// Add the UI object's element to the container div (box)
|
||||
this.el.appendChild(component.el);
|
||||
},
|
||||
|
||||
/* Display
|
||||
================================================================================ */
|
||||
show: function(){
|
||||
this.el.style.display = "block";
|
||||
},
|
||||
|
||||
hide: function(){
|
||||
this.el.style.display = "none";
|
||||
},
|
||||
|
||||
addClass: function(classToAdd){
|
||||
_V_.addClass(this.el, classToAdd);
|
||||
},
|
||||
|
||||
removeClass: function(classToRemove){
|
||||
_V_.removeClass(this.el, classToRemove);
|
||||
},
|
||||
|
||||
/* Events
|
||||
================================================================================ */
|
||||
addEvent: function(type, fn){
|
||||
return _V_.addEvent(this.el, type, _V_.proxy(this, fn));
|
||||
},
|
||||
removeEvent: function(type, fn){
|
||||
return _V_.removeEvent(this.el, type, fn);
|
||||
},
|
||||
triggerEvent: function(type, e){
|
||||
return _V_.triggerEvent(this.el, type, e);
|
||||
},
|
||||
|
||||
/* Ready - Trigger functions when component is ready
|
||||
================================================================================ */
|
||||
ready: function(fn){
|
||||
if (!fn) return this;
|
||||
|
||||
if (this.isReady) {
|
||||
fn.call(this);
|
||||
} else {
|
||||
if (this.readyQueue === undefined) {
|
||||
this.readyQueue = [];
|
||||
}
|
||||
this.readyQueue.push(fn);
|
||||
}
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
triggerReady: function(){
|
||||
this.isReady = true;
|
||||
if (this.readyQueue && this.readyQueue.length > 0) {
|
||||
// Call all functions in ready queue
|
||||
this.each(this.readyQueue, function(fn){
|
||||
fn.call(this);
|
||||
});
|
||||
|
||||
// Reset Ready Queue
|
||||
this.readyQueue = [];
|
||||
}
|
||||
},
|
||||
|
||||
/* Utility
|
||||
================================================================================ */
|
||||
each: function(arr, fn){
|
||||
if (!arr || arr.length === 0) { return; }
|
||||
for (var i=0,j=arr.length; i<j; i++) {
|
||||
if (fn.call(this, arr[i], i)) { break; }
|
||||
}
|
||||
},
|
||||
|
||||
extend: function(obj){
|
||||
for (var attrname in obj) {
|
||||
if (obj.hasOwnProperty(attrname)) { this[attrname]=obj[attrname]; }
|
||||
}
|
||||
},
|
||||
|
||||
// More easily attach 'this' to functions
|
||||
proxy: function(fn){
|
||||
return _V_.proxy(this, fn);
|
||||
}
|
||||
|
||||
});
|
||||
externo
+795
@@ -0,0 +1,795 @@
|
||||
/* Control - Base class for all control elements
|
||||
================================================================================ */
|
||||
_V_.Control = _V_.Component.extend({
|
||||
|
||||
buildCSSClass: function(){
|
||||
return "vjs-control " + this._super();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
/* Button - Base class for all buttons
|
||||
================================================================================ */
|
||||
_V_.Button = _V_.Control.extend({
|
||||
|
||||
init: function(player, options){
|
||||
this._super(player, options);
|
||||
|
||||
this.addEvent("click", this.onClick);
|
||||
this.addEvent("focus", this.onFocus);
|
||||
this.addEvent("blur", this.onBlur);
|
||||
},
|
||||
|
||||
createElement: function(type, attrs){
|
||||
// Add standard Aria and Tabindex info
|
||||
attrs = _V_.merge({
|
||||
className: this.buildCSSClass(),
|
||||
innerHTML: '<div><span class="vjs-control-text">' + (this.buttonText || "Need Text") + '</span></div>',
|
||||
role: "button",
|
||||
tabIndex: 0
|
||||
}, attrs);
|
||||
|
||||
return this._super(type, attrs);
|
||||
},
|
||||
|
||||
// Click - Override with specific functionality for button
|
||||
onClick: function(){},
|
||||
|
||||
// Focus - Add keyboard functionality to element
|
||||
onFocus: function(){
|
||||
_V_.addEvent(document, "keyup", _V_.proxy(this, this.onKeyPress));
|
||||
},
|
||||
|
||||
// KeyPress (document level) - Trigger click when keys are pressed
|
||||
onKeyPress: function(event){
|
||||
// Check for space bar (32) or enter (13) keys
|
||||
if (event.which == 32 || event.which == 13) {
|
||||
event.preventDefault();
|
||||
this.onClick();
|
||||
}
|
||||
},
|
||||
|
||||
// Blur - Remove keyboard triggers
|
||||
onBlur: function(){
|
||||
_V_.removeEvent(document, "keyup", _V_.proxy(this, this.onKeyPress));
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
/* Play Button
|
||||
================================================================================ */
|
||||
_V_.PlayButton = _V_.Button.extend({
|
||||
|
||||
buttonText: "Play",
|
||||
|
||||
buildCSSClass: function(){
|
||||
return "vjs-play-button " + this._super();
|
||||
},
|
||||
|
||||
onClick: function(){
|
||||
this.player.play();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
/* Pause Button
|
||||
================================================================================ */
|
||||
_V_.PauseButton = _V_.Button.extend({
|
||||
|
||||
buttonText: "Pause",
|
||||
|
||||
buildCSSClass: function(){
|
||||
return "vjs-pause-button " + this._super();
|
||||
},
|
||||
|
||||
onClick: function(){
|
||||
this.player.pause();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
/* Play Toggle - Play or Pause Media
|
||||
================================================================================ */
|
||||
_V_.PlayToggle = _V_.Button.extend({
|
||||
|
||||
buttonText: "Play",
|
||||
|
||||
init: function(player, options){
|
||||
this._super(player, options);
|
||||
|
||||
player.addEvent("play", _V_.proxy(this, this.onPlay));
|
||||
player.addEvent("pause", _V_.proxy(this, this.onPause));
|
||||
},
|
||||
|
||||
buildCSSClass: function(){
|
||||
return "vjs-play-control " + this._super();
|
||||
},
|
||||
|
||||
// OnClick - Toggle between play and pause
|
||||
onClick: function(){
|
||||
if (this.player.paused()) {
|
||||
this.player.play();
|
||||
} else {
|
||||
this.player.pause();
|
||||
}
|
||||
},
|
||||
|
||||
// OnPlay - Add the vjs-playing class to the element so it can change appearance
|
||||
onPlay: function(){
|
||||
_V_.removeClass(this.el, "vjs-paused");
|
||||
_V_.addClass(this.el, "vjs-playing");
|
||||
},
|
||||
|
||||
// OnPause - Add the vjs-paused class to the element so it can change appearance
|
||||
onPause: function(){
|
||||
_V_.removeClass(this.el, "vjs-playing");
|
||||
_V_.addClass(this.el, "vjs-paused");
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
/* Fullscreen Toggle Behaviors
|
||||
================================================================================ */
|
||||
_V_.FullscreenToggle = _V_.Button.extend({
|
||||
|
||||
buttonText: "Fullscreen",
|
||||
|
||||
buildCSSClass: function(){
|
||||
return "vjs-fullscreen-control " + this._super();
|
||||
},
|
||||
|
||||
onClick: function(){
|
||||
if (!this.player.videoIsFullScreen) {
|
||||
this.player.requestFullScreen();
|
||||
} else {
|
||||
this.player.cancelFullScreen();
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
/* Big Play Button
|
||||
================================================================================ */
|
||||
_V_.BigPlayButton = _V_.Button.extend({
|
||||
init: function(player, options){
|
||||
this._super(player, options);
|
||||
|
||||
player.addEvent("play", _V_.proxy(this, this.hide));
|
||||
player.addEvent("ended", _V_.proxy(this, this.show));
|
||||
},
|
||||
|
||||
createElement: function(){
|
||||
return this._super("div", {
|
||||
className: "vjs-big-play-button",
|
||||
innerHTML: "<span></span>"
|
||||
});
|
||||
},
|
||||
|
||||
onClick: function(){
|
||||
// Go back to the beginning if big play button is showing at the end.
|
||||
// Have to check for current time otherwise it might throw a 'not ready' error.
|
||||
if(this.player.currentTime()) {
|
||||
this.player.currentTime(0);
|
||||
}
|
||||
this.player.play();
|
||||
}
|
||||
});
|
||||
|
||||
/* Loading Spinner
|
||||
================================================================================ */
|
||||
_V_.LoadingSpinner = _V_.Component.extend({
|
||||
init: function(player, options){
|
||||
this._super(player, options);
|
||||
|
||||
player.addEvent("canplay", _V_.proxy(this, this.hide));
|
||||
player.addEvent("canplaythrough", _V_.proxy(this, this.hide));
|
||||
player.addEvent("playing", _V_.proxy(this, this.hide));
|
||||
|
||||
player.addEvent("seeking", _V_.proxy(this, this.show));
|
||||
player.addEvent("error", _V_.proxy(this, this.show));
|
||||
player.addEvent("stalled", _V_.proxy(this, this.show));
|
||||
player.addEvent("waiting", _V_.proxy(this, this.show));
|
||||
},
|
||||
|
||||
createElement: function(){
|
||||
|
||||
var classNameSpinner, innerHtmlSpinner;
|
||||
|
||||
if ( typeof this.player.el.style.WebkitBorderRadius == "string"
|
||||
|| typeof this.player.el.style.MozBorderRadius == "string"
|
||||
|| typeof this.player.el.style.KhtmlBorderRadius == "string"
|
||||
|| typeof this.player.el.style.borderRadius == "string")
|
||||
{
|
||||
classNameSpinner = "vjs-loading-spinner";
|
||||
innerHtmlSpinner = "<div class='ball1'></div><div class='ball2'></div><div class='ball3'></div><div class='ball4'></div><div class='ball5'></div><div class='ball6'></div><div class='ball7'></div><div class='ball8'></div>";
|
||||
} else {
|
||||
classNameSpinner = "vjs-loading-spinner-fallback";
|
||||
innerHtmlSpinner = "";
|
||||
}
|
||||
|
||||
return this._super("div", {
|
||||
className: classNameSpinner,
|
||||
innerHTML: innerHtmlSpinner
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
/* Control Bar
|
||||
================================================================================ */
|
||||
_V_.ControlBar = _V_.Component.extend({
|
||||
init: function(player, options){
|
||||
this._super(player, options);
|
||||
|
||||
player.addEvent("play", this.proxy(this.show));
|
||||
|
||||
player.addEvent("mouseover", this.proxy(this.reveal));
|
||||
player.addEvent("mouseout", this.proxy(this.conceal));
|
||||
},
|
||||
|
||||
createElement: function(){
|
||||
return _V_.createElement("div", {
|
||||
className: "vjs-controls"
|
||||
});
|
||||
},
|
||||
|
||||
// Used for transitions (fading out)
|
||||
reveal: function(){
|
||||
this.el.style.opacity = 1;
|
||||
},
|
||||
|
||||
conceal: function(){
|
||||
this.el.style.opacity = 0;
|
||||
}
|
||||
});
|
||||
|
||||
/* Time
|
||||
================================================================================ */
|
||||
_V_.CurrentTimeDisplay = _V_.Component.extend({
|
||||
|
||||
init: function(player, options){
|
||||
this._super(player, options);
|
||||
|
||||
player.addEvent("timeupdate", _V_.proxy(this, this.updateContent));
|
||||
},
|
||||
|
||||
createElement: function(){
|
||||
var el = this._super("div", {
|
||||
className: "vjs-current-time vjs-time-controls vjs-control"
|
||||
});
|
||||
|
||||
this.content = _V_.createElement("div", {
|
||||
className: "vjs-current-time-display",
|
||||
innerHTML: '0:00'
|
||||
});
|
||||
|
||||
el.appendChild(_V_.createElement("div").appendChild(this.content));
|
||||
return el;
|
||||
},
|
||||
|
||||
updateContent: function(){
|
||||
// Allows for smooth scrubbing, when player can't keep up.
|
||||
var time = (this.player.scrubbing) ? this.player.values.currentTime : this.player.currentTime();
|
||||
this.content.innerHTML = _V_.formatTime(time, this.player.duration());
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
_V_.DurationDisplay = _V_.Component.extend({
|
||||
|
||||
init: function(player, options){
|
||||
this._super(player, options);
|
||||
|
||||
player.addEvent("timeupdate", _V_.proxy(this, this.updateContent));
|
||||
},
|
||||
|
||||
createElement: function(){
|
||||
var el = this._super("div", {
|
||||
className: "vjs-duration vjs-time-controls vjs-control"
|
||||
});
|
||||
|
||||
this.content = _V_.createElement("div", {
|
||||
className: "vjs-duration-display",
|
||||
innerHTML: '0:00'
|
||||
});
|
||||
|
||||
el.appendChild(_V_.createElement("div").appendChild(this.content));
|
||||
return el;
|
||||
},
|
||||
|
||||
updateContent: function(){
|
||||
if (this.player.duration()) { this.content.innerHTML = _V_.formatTime(this.player.duration()); }
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
// Time Separator (Not used in main skin, but still available, and could be used as a 'spare element')
|
||||
_V_.TimeDivider = _V_.Component.extend({
|
||||
|
||||
createElement: function(){
|
||||
return this._super("div", {
|
||||
className: "vjs-time-divider",
|
||||
innerHTML: '<div><span>/</span></div>'
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
_V_.RemainingTimeDisplay = _V_.Component.extend({
|
||||
|
||||
init: function(player, options){
|
||||
this._super(player, options);
|
||||
|
||||
player.addEvent("timeupdate", _V_.proxy(this, this.updateContent));
|
||||
},
|
||||
|
||||
createElement: function(){
|
||||
var el = this._super("div", {
|
||||
className: "vjs-remaining-time vjs-time-controls vjs-control"
|
||||
});
|
||||
|
||||
this.content = _V_.createElement("div", {
|
||||
className: "vjs-remaining-time-display",
|
||||
innerHTML: '-0:00'
|
||||
});
|
||||
|
||||
el.appendChild(_V_.createElement("div").appendChild(this.content));
|
||||
return el;
|
||||
},
|
||||
|
||||
updateContent: function(){
|
||||
if (this.player.duration()) { this.content.innerHTML = "-"+_V_.formatTime(this.player.remainingTime()); }
|
||||
|
||||
// Allows for smooth scrubbing, when player can't keep up.
|
||||
// var time = (this.player.scrubbing) ? this.player.values.currentTime : this.player.currentTime();
|
||||
// this.content.innerHTML = _V_.formatTime(time, this.player.duration());
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
/* Slider - Parent for seek bar and volume slider
|
||||
================================================================================ */
|
||||
_V_.Slider = _V_.Component.extend({
|
||||
|
||||
init: function(player, options){
|
||||
this._super(player, options);
|
||||
|
||||
_V_.each.call(this, this.components, function(comp){
|
||||
if (comp instanceof _V_[this.barClass]) {
|
||||
this.bar = comp;
|
||||
} else if (comp instanceof _V_[this.handleClass]) {
|
||||
this.handle = comp;
|
||||
}
|
||||
});
|
||||
|
||||
player.addEvent(this.playerEvent, _V_.proxy(this, this.update));
|
||||
|
||||
this.addEvent("mousedown", this.onMouseDown);
|
||||
this.addEvent("focus", this.onFocus);
|
||||
this.addEvent("blur", this.onBlur);
|
||||
|
||||
// Update Display
|
||||
// Need to wait for styles to be loaded.
|
||||
// TODO - replace setTimeout with stylesReady function.
|
||||
setTimeout(this.proxy(this.update), 0);
|
||||
},
|
||||
|
||||
createElement: function(type, attrs) {
|
||||
attrs = _V_.merge({
|
||||
role: "slider",
|
||||
"aria-valuenow": 0,
|
||||
"aria-valuemin": 0,
|
||||
"aria-valuemax": 100,
|
||||
tabIndex: 0
|
||||
}, attrs);
|
||||
|
||||
return this._super(type, attrs);
|
||||
},
|
||||
|
||||
onMouseDown: function(event){
|
||||
event.preventDefault();
|
||||
_V_.blockTextSelection();
|
||||
|
||||
_V_.addEvent(document, "mousemove", _V_.proxy(this, this.onMouseMove));
|
||||
_V_.addEvent(document, "mouseup", _V_.proxy(this, this.onMouseUp));
|
||||
|
||||
this.onMouseMove(event);
|
||||
},
|
||||
|
||||
onMouseUp: function(event) {
|
||||
_V_.unblockTextSelection();
|
||||
_V_.removeEvent(document, "mousemove", this.onMouseMove, false);
|
||||
_V_.removeEvent(document, "mouseup", this.onMouseUp, false);
|
||||
|
||||
this.update();
|
||||
},
|
||||
|
||||
update: function(){
|
||||
// If scrubbing, we could use a cached value to make the handle keep up with the user's mouse.
|
||||
// On HTML5 browsers scrubbing is really smooth, but some flash players are slow, so we might want to utilize this later.
|
||||
// var progress = (this.player.scrubbing) ? this.player.values.currentTime / this.player.duration() : this.player.currentTime() / this.player.duration();
|
||||
|
||||
var barProgress,
|
||||
progress = this.getPercent();
|
||||
handle = this.handle,
|
||||
bar = this.bar;
|
||||
|
||||
// Protect against no duration and other division issues
|
||||
if (isNaN(progress)) { progress = 0; }
|
||||
|
||||
barProgress = progress;
|
||||
|
||||
// If there is a handle, we need to account for the handle in our calculation for progress bar
|
||||
// so that it doesn't fall short of or extend past the handle.
|
||||
if (handle) {
|
||||
var box = this.el,
|
||||
boxWidth = box.offsetWidth,
|
||||
|
||||
// The width of the handle in percent of the containing box
|
||||
// In IE, widths may not be ready yet causing NaN
|
||||
handlePercent = (handle.el.offsetWidth) ? handle.el.offsetWidth / boxWidth : 0,
|
||||
|
||||
// Get the adjusted size of the box, considering that the handle's center never touches the left or right side.
|
||||
// There is a margin of half the handle's width on both sides.
|
||||
boxAdjustedPercent = 1 - handlePercent;
|
||||
|
||||
// Adjust the progress that we'll use to set widths to the new adjusted box width
|
||||
adjustedProgress = progress * boxAdjustedPercent,
|
||||
|
||||
// The bar does reach the left side, so we need to account for this in the bar's width
|
||||
barProgress = adjustedProgress + (handlePercent / 2);
|
||||
|
||||
// Move the handle from the left based on the adjected progress
|
||||
handle.el.style.left = _V_.round(adjustedProgress * 100, 2) + "%";
|
||||
}
|
||||
|
||||
// Set the new bar width
|
||||
bar.el.style.width = _V_.round(barProgress * 100, 2) + "%";
|
||||
},
|
||||
|
||||
calculateDistance: function(event){
|
||||
var box = this.el,
|
||||
boxX = _V_.findPosX(box),
|
||||
boxW = box.offsetWidth,
|
||||
handle = this.handle;
|
||||
|
||||
if (handle) {
|
||||
var handleW = handle.el.offsetWidth;
|
||||
|
||||
// Adjusted X and Width, so handle doesn't go outside the bar
|
||||
boxX = boxX + (handleW / 2);
|
||||
boxW = boxW - handleW;
|
||||
}
|
||||
|
||||
// Percent that the click is through the adjusted area
|
||||
return Math.max(0, Math.min(1, (event.pageX - boxX) / boxW));
|
||||
},
|
||||
|
||||
onFocus: function(event){
|
||||
_V_.addEvent(document, "keyup", _V_.proxy(this, this.onKeyPress));
|
||||
},
|
||||
|
||||
onKeyPress: function(event){
|
||||
if (event.which == 37) { // Left Arrow
|
||||
event.preventDefault();
|
||||
this.stepBack();
|
||||
} else if (event.which == 39) { // Right Arrow
|
||||
event.preventDefault();
|
||||
this.stepForward();
|
||||
}
|
||||
},
|
||||
|
||||
onBlur: function(event){
|
||||
_V_.removeEvent(document, "keyup", _V_.proxy(this, this.onKeyPress));
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
/* Progress
|
||||
================================================================================ */
|
||||
|
||||
// Progress Control: Seek, Load Progress, and Play Progress
|
||||
_V_.ProgressControl = _V_.Component.extend({
|
||||
|
||||
createElement: function(){
|
||||
return this._super("div", {
|
||||
className: "vjs-progress-control vjs-control"
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
// Seek Bar and holder for the progress bars
|
||||
_V_.SeekBar = _V_.Slider.extend({
|
||||
|
||||
barClass: "PlayProgressBar",
|
||||
handleClass: "SeekHandle",
|
||||
playerEvent: "timeupdate",
|
||||
|
||||
init: function(player, options){
|
||||
this._super(player, options);
|
||||
},
|
||||
|
||||
createElement: function(){
|
||||
return this._super("div", {
|
||||
className: "vjs-progress-holder"
|
||||
});
|
||||
},
|
||||
|
||||
getPercent: function(){
|
||||
return this.player.currentTime() / this.player.duration();
|
||||
},
|
||||
|
||||
onMouseDown: function(event){
|
||||
this._super(event);
|
||||
|
||||
this.player.scrubbing = true;
|
||||
|
||||
this.videoWasPlaying = !this.player.paused();
|
||||
this.player.pause();
|
||||
},
|
||||
|
||||
onMouseMove: function(event){
|
||||
var newTime = this.calculateDistance(event) * this.player.duration();
|
||||
|
||||
// Don't let video end while scrubbing.
|
||||
if (newTime == this.player.duration()) { newTime = newTime - 0.1; }
|
||||
|
||||
// Set new time (tell player to seek to new time)
|
||||
this.player.currentTime(newTime);
|
||||
},
|
||||
|
||||
onMouseUp: function(event){
|
||||
this._super(event);
|
||||
|
||||
this.player.scrubbing = false;
|
||||
if (this.videoWasPlaying) {
|
||||
this.player.play();
|
||||
}
|
||||
},
|
||||
|
||||
stepForward: function(){
|
||||
this.player.currentTime(this.player.currentTime() + 1);
|
||||
},
|
||||
|
||||
stepBack: function(){
|
||||
this.player.currentTime(this.player.currentTime() - 1);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
// Load Progress Bar
|
||||
_V_.LoadProgressBar = _V_.Component.extend({
|
||||
|
||||
init: function(player, options){
|
||||
this._super(player, options);
|
||||
player.addEvent("progress", _V_.proxy(this, this.update));
|
||||
},
|
||||
|
||||
createElement: function(){
|
||||
return this._super("div", {
|
||||
className: "vjs-load-progress",
|
||||
innerHTML: '<span class="vjs-control-text">Loaded: 0%</span>'
|
||||
});
|
||||
},
|
||||
|
||||
update: function(){
|
||||
if (this.el.style) { this.el.style.width = _V_.round(this.player.bufferedPercent() * 100, 2) + "%"; }
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
// Play Progress Bar
|
||||
_V_.PlayProgressBar = _V_.Component.extend({
|
||||
|
||||
createElement: function(){
|
||||
return this._super("div", {
|
||||
className: "vjs-play-progress",
|
||||
innerHTML: '<span class="vjs-control-text">Progress: 0%</span>'
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
// Seek Handle
|
||||
// SeekBar Behavior includes play progress bar, and seek handle
|
||||
// Needed so it can determine seek position based on handle position/size
|
||||
_V_.SeekHandle = _V_.Component.extend({
|
||||
|
||||
createElement: function(){
|
||||
return this._super("div", {
|
||||
className: "vjs-seek-handle",
|
||||
innerHTML: '<span class="vjs-control-text">00:00</span>'
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
/* Volume Scrubber
|
||||
================================================================================ */
|
||||
// Progress Control: Seek, Load Progress, and Play Progress
|
||||
_V_.VolumeControl = _V_.Component.extend({
|
||||
|
||||
createElement: function(){
|
||||
return this._super("div", {
|
||||
className: "vjs-volume-control vjs-control"
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
_V_.VolumeBar = _V_.Slider.extend({
|
||||
|
||||
barClass: "VolumeLevel",
|
||||
handleClass: "VolumeHandle",
|
||||
playerEvent: "volumechange",
|
||||
|
||||
createElement: function(){
|
||||
return this._super("div", {
|
||||
className: "vjs-volume-bar"
|
||||
});
|
||||
},
|
||||
|
||||
onMouseMove: function(event) {
|
||||
this.player.volume(this.calculateDistance(event));
|
||||
},
|
||||
|
||||
getPercent: function(){
|
||||
return this.player.volume();
|
||||
},
|
||||
|
||||
stepForward: function(){
|
||||
this.player.volume(this.player.volume() + 0.1);
|
||||
},
|
||||
|
||||
stepBack: function(){
|
||||
this.player.volume(this.player.volume() - 0.1);
|
||||
}
|
||||
});
|
||||
|
||||
_V_.VolumeLevel = _V_.Component.extend({
|
||||
|
||||
createElement: function(){
|
||||
return this._super("div", {
|
||||
className: "vjs-volume-level",
|
||||
innerHTML: '<span class="vjs-control-text"></span>'
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
_V_.VolumeHandle = _V_.Component.extend({
|
||||
|
||||
createElement: function(){
|
||||
return this._super("div", {
|
||||
className: "vjs-volume-handle",
|
||||
innerHTML: '<span class="vjs-control-text"></span>'
|
||||
// tabindex: 0,
|
||||
// role: "slider", "aria-valuenow": 0, "aria-valuemin": 0, "aria-valuemax": 100
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
_V_.MuteToggle = _V_.Button.extend({
|
||||
|
||||
init: function(player, options){
|
||||
this._super(player, options);
|
||||
|
||||
player.addEvent("volumechange", _V_.proxy(this, this.update));
|
||||
},
|
||||
|
||||
createElement: function(){
|
||||
return this._super("div", {
|
||||
className: "vjs-mute-control vjs-control",
|
||||
innerHTML: '<div><span class="vjs-control-text">Mute</span></div>'
|
||||
});
|
||||
},
|
||||
|
||||
onClick: function(event){
|
||||
this.player.muted( this.player.muted() ? false : true );
|
||||
},
|
||||
|
||||
update: function(event){
|
||||
var vol = this.player.volume(),
|
||||
level = 3;
|
||||
|
||||
if (vol == 0 || this.player.muted()) {
|
||||
level = 0;
|
||||
} else if (vol < 0.33) {
|
||||
level = 1;
|
||||
} else if (vol < 0.67) {
|
||||
level = 2;
|
||||
}
|
||||
|
||||
/* TODO improve muted icon classes */
|
||||
_V_.each.call(this, [0,1,2,3], function(i){
|
||||
_V_.removeClass(this.el, "vjs-vol-"+i);
|
||||
});
|
||||
_V_.addClass(this.el, "vjs-vol-"+level);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
/* Poster Image
|
||||
================================================================================ */
|
||||
_V_.Poster = _V_.Button.extend({
|
||||
init: function(player, options){
|
||||
this._super(player, options);
|
||||
|
||||
if (!this.player.options.poster) {
|
||||
this.hide();
|
||||
}
|
||||
|
||||
player.addEvent("play", _V_.proxy(this, this.hide));
|
||||
},
|
||||
|
||||
createElement: function(){
|
||||
_V_.log(this.player.options.poster)
|
||||
return this._super("img", {
|
||||
className: "vjs-poster",
|
||||
src: this.player.options.poster,
|
||||
|
||||
// Don't want poster to be tabbable.
|
||||
tabIndex: -1
|
||||
});
|
||||
},
|
||||
|
||||
onClick: function(){
|
||||
this.player.play();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
/* Text Track Displays
|
||||
================================================================================ */
|
||||
// Create a behavior type for each text track type (subtitlesDisplay, captionsDisplay, etc.).
|
||||
// Then you can easily do something like.
|
||||
// player.addBehavior(myDiv, "subtitlesDisplay");
|
||||
// And the myDiv's content will be updated with the text change.
|
||||
|
||||
// Base class for all track displays. Should not be instantiated on its own.
|
||||
_V_.TextTrackDisplay = _V_.Component.extend({
|
||||
|
||||
init: function(player, options){
|
||||
this._super(player, options);
|
||||
|
||||
player.addEvent(this.trackType + "update", _V_.proxy(this, this.update));
|
||||
},
|
||||
|
||||
createElement: function(){
|
||||
return this._super("div", {
|
||||
className: "vjs-" + this.trackType
|
||||
});
|
||||
},
|
||||
|
||||
update: function(){
|
||||
this.el.innerHTML = this.player.textTrackValue(this.trackType);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
_V_.SubtitlesDisplay = _V_.TextTrackDisplay.extend({
|
||||
|
||||
trackType: "subtitles"
|
||||
|
||||
});
|
||||
|
||||
_V_.CaptionsDisplay = _V_.TextTrackDisplay.extend({
|
||||
|
||||
trackType: "captions"
|
||||
|
||||
});
|
||||
|
||||
_V_.ChaptersDisplay = _V_.TextTrackDisplay.extend({
|
||||
|
||||
trackType: "chapters"
|
||||
|
||||
});
|
||||
|
||||
_V_.DescriptionsDisplay = _V_.TextTrackDisplay.extend({
|
||||
|
||||
trackType: "descriptions"
|
||||
|
||||
});
|
||||
+158
@@ -0,0 +1,158 @@
|
||||
// HTML5 Shiv. Must be in <head> to support older browsers.
|
||||
document.createElement("video");document.createElement("audio");
|
||||
|
||||
var VideoJS = function(id, addOptions, ready){
|
||||
var tag; // Element of ID
|
||||
|
||||
// Allow for element or ID to be passed in
|
||||
// String ID
|
||||
if (typeof id == "string") {
|
||||
|
||||
// Adjust for jQuery ID syntax
|
||||
if (id.indexOf("#") === 0) {
|
||||
id = id.slice(1);
|
||||
}
|
||||
|
||||
// If a player instance has already been created for this ID return it.
|
||||
if (_V_.players[id]) {
|
||||
return _V_.players[id];
|
||||
|
||||
// Otherwise get element for ID
|
||||
} else {
|
||||
tag = _V_.el(id)
|
||||
}
|
||||
|
||||
// ID is a media element
|
||||
} else {
|
||||
tag = id;
|
||||
}
|
||||
|
||||
// Check for a useable element
|
||||
if (!tag || !tag.nodeName) { // re: nodeName, could be a box div also
|
||||
throw new TypeError("The element or ID supplied is not valid. (VideoJS)"); // Returns
|
||||
}
|
||||
|
||||
// Element may have a player attr referring to an already created player instance.
|
||||
// If not, set up a new player and return the instance.
|
||||
return tag.player || new _V_.Player(tag, addOptions, ready);
|
||||
},
|
||||
|
||||
// Shortcut
|
||||
_V_ = VideoJS;
|
||||
|
||||
VideoJS.players = {};
|
||||
|
||||
VideoJS.options = {
|
||||
|
||||
// Default order of fallback technology
|
||||
techOrder: ["html5","flash"],
|
||||
// techOrder: ["flash","html5"],
|
||||
|
||||
html5: {},
|
||||
flash: {
|
||||
swf: "http://vjs.zencdn.net/c/video-js.swf"
|
||||
// swf: "https://s3.amazonaws.com/video-js/3.0b/video-js.swf"
|
||||
// swf: "http://video-js.zencoder.com/3.0b/video-js.swf"
|
||||
// swf: "http://video-js.com/test/video-js.swf"
|
||||
// swf: "http://video-js.com/source/flash/video-js.swf"
|
||||
// swf: "http://video-js.com/source/flash/video-js.swf"
|
||||
// swf: "video-js.swf"
|
||||
},
|
||||
|
||||
// Default of web browser is 300x150. Should rely on source width/height.
|
||||
width: "auto",
|
||||
height: "auto",
|
||||
|
||||
// defaultVolume: 0.85,
|
||||
defaultVolume: 0.00, // The freakin seaguls are driving me crazy!
|
||||
|
||||
// Included control sets
|
||||
components: [
|
||||
"poster",
|
||||
"loadingSpinner",
|
||||
"bigPlayButton",
|
||||
{ name: "controlBar", options: {
|
||||
components: [
|
||||
"playToggle",
|
||||
"fullscreenToggle",
|
||||
"currentTimeDisplay",
|
||||
"timeDivider",
|
||||
"durationDisplay",
|
||||
"remainingTimeDisplay",
|
||||
{ name: "progressControl", options: {
|
||||
components: [
|
||||
{ name: "seekBar", options: {
|
||||
components: [
|
||||
"loadProgressBar",
|
||||
"playProgressBar",
|
||||
"seekHandle"
|
||||
]}
|
||||
}
|
||||
]}
|
||||
},
|
||||
{ name: "volumeControl", options: {
|
||||
components: [
|
||||
{ name: "volumeBar", options: {
|
||||
components: [
|
||||
"volumeLevel",
|
||||
"volumeHandle"
|
||||
]}
|
||||
}
|
||||
]}
|
||||
},
|
||||
"muteToggle"
|
||||
]
|
||||
}},
|
||||
"subtitlesDisplay"/*, "replay"*/
|
||||
]
|
||||
};
|
||||
|
||||
// Automatically set up any tags that have a data-setup attribute
|
||||
_V_.autoSetup = function(){
|
||||
var options, vid, player,
|
||||
vids = document.getElementsByTagName("video");
|
||||
|
||||
// Check if any media elements exist
|
||||
if (vids && vids.length > 0) {
|
||||
|
||||
for (var i=0,j=vids.length; i<j; i++) {
|
||||
vid = vids[i];
|
||||
|
||||
// Check if element exists, has getAttribute func.
|
||||
// IE seems to consider typeof el.getAttribute == "object" instead of "function" like expected, at least when loading the player immediately.
|
||||
if (vid && vid.getAttribute) {
|
||||
|
||||
// Make sure this player hasn't already been set up.
|
||||
if (vid.player === undefined) {
|
||||
options = vid.getAttribute("data-setup");
|
||||
|
||||
// Check if data-setup attr exists.
|
||||
// We only auto-setup if they've added the data-setup attr.
|
||||
if (options !== null) {
|
||||
|
||||
// Parse options JSON
|
||||
// If empty string, make it a parsable json object.
|
||||
options = JSON.parse(options || "{}");
|
||||
|
||||
// Create new video.js instance.
|
||||
player = _V_(vid, options);
|
||||
}
|
||||
}
|
||||
|
||||
// If getAttribute isn't defined, we need to wait for the DOM.
|
||||
} else {
|
||||
_V_.autoSetupTimeout(1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// No videos were found, so keep looping unless page is finisehd loading.
|
||||
} else if (!_V_.windowLoaded) {
|
||||
_V_.autoSetupTimeout(1);
|
||||
}
|
||||
};
|
||||
|
||||
// Pause to let the DOM keep processing
|
||||
_V_.autoSetupTimeout = function(wait){
|
||||
setTimeout(_V_.autoSetup, wait);
|
||||
};
|
||||
+217
@@ -0,0 +1,217 @@
|
||||
// ECMA-262 is the standard for javascript.
|
||||
// The following methods are impelemented EXACTLY as described in the standard (according to Mozilla Docs), and do not override the default method if one exists.
|
||||
// This may conflict with other libraries that modify the array prototype, but those libs should update to use the standard.
|
||||
|
||||
// [].indexOf
|
||||
// https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/indexOf
|
||||
if (!Array.prototype.indexOf) {
|
||||
Array.prototype.indexOf = function (searchElement /*, fromIndex */ ) {
|
||||
"use strict";
|
||||
if (this === void 0 || this === null) {
|
||||
throw new TypeError();
|
||||
}
|
||||
var t = Object(this);
|
||||
var len = t.length >>> 0;
|
||||
if (len === 0) {
|
||||
return -1;
|
||||
}
|
||||
var n = 0;
|
||||
if (arguments.length > 0) {
|
||||
n = Number(arguments[1]);
|
||||
if (n !== n) { // shortcut for verifying if it's NaN
|
||||
n = 0;
|
||||
} else if (n !== 0 && n !== (1 / 0) && n !== -(1 / 0)) {
|
||||
n = (n > 0 || -1) * Math.floor(Math.abs(n));
|
||||
}
|
||||
}
|
||||
if (n >= len) {
|
||||
return -1;
|
||||
}
|
||||
var k = n >= 0 ? n : Math.max(len - Math.abs(n), 0);
|
||||
for (; k < len; k++) {
|
||||
if (k in t && t[k] === searchElement) {
|
||||
return k;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
// NOT NEEDED YET
|
||||
// [].lastIndexOf
|
||||
// https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/lastIndexOf
|
||||
// if (!Array.prototype.lastIndexOf)
|
||||
// {
|
||||
// Array.prototype.lastIndexOf = function(searchElement /*, fromIndex*/)
|
||||
// {
|
||||
// "use strict";
|
||||
//
|
||||
// if (this === void 0 || this === null)
|
||||
// throw new TypeError();
|
||||
//
|
||||
// var t = Object(this);
|
||||
// var len = t.length >>> 0;
|
||||
// if (len === 0)
|
||||
// return -1;
|
||||
//
|
||||
// var n = len;
|
||||
// if (arguments.length > 1)
|
||||
// {
|
||||
// n = Number(arguments[1]);
|
||||
// if (n !== n)
|
||||
// n = 0;
|
||||
// else if (n !== 0 && n !== (1 / 0) && n !== -(1 / 0))
|
||||
// n = (n > 0 || -1) * Math.floor(Math.abs(n));
|
||||
// }
|
||||
//
|
||||
// var k = n >= 0
|
||||
// ? Math.min(n, len - 1)
|
||||
// : len - Math.abs(n);
|
||||
//
|
||||
// for (; k >= 0; k--)
|
||||
// {
|
||||
// if (k in t && t[k] === searchElement)
|
||||
// return k;
|
||||
// }
|
||||
// return -1;
|
||||
// };
|
||||
// }
|
||||
|
||||
|
||||
// NOT NEEDED YET
|
||||
// Array forEach per ECMA standard https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/array/foreach
|
||||
// Production steps of ECMA-262, Edition 5, 15.4.4.18
|
||||
// Reference: http://es5.github.com/#x15.4.4.18
|
||||
// if ( !Array.prototype.forEach ) {
|
||||
//
|
||||
// Array.prototype.forEach = function( callback, thisArg ) {
|
||||
//
|
||||
// var T, k;
|
||||
//
|
||||
// if ( this == null ) {
|
||||
// throw new TypeError( " this is null or not defined" );
|
||||
// }
|
||||
//
|
||||
// // 1. Let O be the result of calling ToObject passing the |this| value as the argument.
|
||||
// var O = Object(this);
|
||||
//
|
||||
// // 2. Let lenValue be the result of calling the Get internal method of O with the argument "length".
|
||||
// // 3. Let len be ToUint32(lenValue).
|
||||
// var len = O.length >>> 0;
|
||||
//
|
||||
// // 4. If IsCallable(callback) is false, throw a TypeError exception.
|
||||
// // See: http://es5.github.com/#x9.11
|
||||
// if ( {}.toString.call(callback) != "[object Function]" ) {
|
||||
// throw new TypeError( callback + " is not a function" );
|
||||
// }
|
||||
//
|
||||
// // 5. If thisArg was supplied, let T be thisArg; else let T be undefined.
|
||||
// if ( thisArg ) {
|
||||
// T = thisArg;
|
||||
// }
|
||||
//
|
||||
// // 6. Let k be 0
|
||||
// k = 0;
|
||||
//
|
||||
// // 7. Repeat, while k < len
|
||||
// while( k < len ) {
|
||||
//
|
||||
// var kValue;
|
||||
//
|
||||
// // a. Let Pk be ToString(k).
|
||||
// // This is implicit for LHS operands of the in operator
|
||||
// // b. Let kPresent be the result of calling the HasProperty internal method of O with argument Pk.
|
||||
// // This step can be combined with c
|
||||
// // c. If kPresent is true, then
|
||||
// if ( k in O ) {
|
||||
//
|
||||
// // i. Let kValue be the result of calling the Get internal method of O with argument Pk.
|
||||
// kValue = O[ Pk ];
|
||||
//
|
||||
// // ii. Call the Call internal method of callback with T as the this value and
|
||||
// // argument list containing kValue, k, and O.
|
||||
// callback.call( T, kValue, k, O );
|
||||
// }
|
||||
// // d. Increase k by 1.
|
||||
// k++;
|
||||
// }
|
||||
// // 8. return undefined
|
||||
// };
|
||||
// }
|
||||
|
||||
|
||||
// NOT NEEDED YET
|
||||
// https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/map
|
||||
// Production steps of ECMA-262, Edition 5, 15.4.4.19
|
||||
// Reference: http://es5.github.com/#x15.4.4.19
|
||||
// if (!Array.prototype.map) {
|
||||
// Array.prototype.map = function(callback, thisArg) {
|
||||
//
|
||||
// var T, A, k;
|
||||
//
|
||||
// if (this == null) {
|
||||
// throw new TypeError(" this is null or not defined");
|
||||
// }
|
||||
//
|
||||
// // 1. Let O be the result of calling ToObject passing the |this| value as the argument.
|
||||
// var O = Object(this);
|
||||
//
|
||||
// // 2. Let lenValue be the result of calling the Get internal method of O with the argument "length".
|
||||
// // 3. Let len be ToUint32(lenValue).
|
||||
// var len = O.length >>> 0;
|
||||
//
|
||||
// // 4. If IsCallable(callback) is false, throw a TypeError exception.
|
||||
// // See: http://es5.github.com/#x9.11
|
||||
// if ({}.toString.call(callback) != "[object Function]") {
|
||||
// throw new TypeError(callback + " is not a function");
|
||||
// }
|
||||
//
|
||||
// // 5. If thisArg was supplied, let T be thisArg; else let T be undefined.
|
||||
// if (thisArg) {
|
||||
// T = thisArg;
|
||||
// }
|
||||
//
|
||||
// // 6. Let A be a new array created as if by the expression new Array(len) where Array is
|
||||
// // the standard built-in constructor with that name and len is the value of len.
|
||||
// A = new Array(len);
|
||||
//
|
||||
// // 7. Let k be 0
|
||||
// k = 0;
|
||||
//
|
||||
// // 8. Repeat, while k < len
|
||||
// while(k < len) {
|
||||
//
|
||||
// var kValue, mappedValue;
|
||||
//
|
||||
// // a. Let Pk be ToString(k).
|
||||
// // This is implicit for LHS operands of the in operator
|
||||
// // b. Let kPresent be the result of calling the HasProperty internal method of O with argument Pk.
|
||||
// // This step can be combined with c
|
||||
// // c. If kPresent is true, then
|
||||
// if (k in O) {
|
||||
//
|
||||
// // i. Let kValue be the result of calling the Get internal method of O with argument Pk.
|
||||
// kValue = O[ k ];
|
||||
//
|
||||
// // ii. Let mappedValue be the result of calling the Call internal method of callback
|
||||
// // with T as the this value and argument list containing kValue, k, and O.
|
||||
// mappedValue = callback.call(T, kValue, k, O);
|
||||
//
|
||||
// // iii. Call the DefineOwnProperty internal method of A with arguments
|
||||
// // Pk, Property Descriptor {Value: mappedValue, Writable: true, Enumerable: true, Configurable: true},
|
||||
// // and false.
|
||||
//
|
||||
// // In browsers that support Object.defineProperty, use the following:
|
||||
// // Object.defineProperty(A, Pk, { value: mappedValue, writable: true, enumerable: true, configurable: true });
|
||||
//
|
||||
// // For best browser support, use the following:
|
||||
// A[ k ] = mappedValue;
|
||||
// }
|
||||
// // d. Increase k by 1.
|
||||
// k++;
|
||||
// }
|
||||
//
|
||||
// // 9. return A
|
||||
// return A;
|
||||
// };
|
||||
// }
|
||||
+295
@@ -0,0 +1,295 @@
|
||||
// Event System (J.Resig - Secrets of a JS Ninja http://jsninja.com/ [Go read it, really])
|
||||
// (Book version isn't completely usable, so fixed some things and borrowed from jQuery where it's working)
|
||||
//
|
||||
// This should work very similarly to jQuery's events, however it's based off the book version which isn't as
|
||||
// robust as jquery's, so there's probably some differences.
|
||||
//
|
||||
// When you add an event listener using _V_.addEvent,
|
||||
// it stores the handler function in seperate cache object,
|
||||
// and adds a generic handler to the element's event,
|
||||
// along with a unique id (guid) to the element.
|
||||
|
||||
_V_.extend({
|
||||
|
||||
// Add an event listener to element
|
||||
// It stores the handler function in a separate cache object
|
||||
// and adds a generic handler to the element's event,
|
||||
// along with a unique id (guid) to the element.
|
||||
addEvent: function(elem, type, fn){
|
||||
var data = _V_.getData(elem), handlers;
|
||||
|
||||
// We only need to generate one handler per element
|
||||
if (data && !data.handler) {
|
||||
// Our new meta-handler that fixes the event object and the context
|
||||
data.handler = function(event){
|
||||
event = _V_.fixEvent(event);
|
||||
var handlers = _V_.getData(elem).events[event.type];
|
||||
// Go through and call all the real bound handlers
|
||||
if (handlers) {
|
||||
|
||||
// Copy handlers so if handlers are added/removed during the process it doesn't throw everything off.
|
||||
var handlersCopy = [];
|
||||
_V_.each(handlers, function(handler, i){
|
||||
handlersCopy[i] = handler;
|
||||
})
|
||||
|
||||
for (var i = 0, l = handlersCopy.length; i < l; i++) {
|
||||
handlersCopy[i].call(elem, event);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// We need a place to store all our event data
|
||||
if (!data.events) { data.events = {}; }
|
||||
|
||||
// And a place to store the handlers for this event type
|
||||
handlers = data.events[type];
|
||||
|
||||
if (!handlers) {
|
||||
handlers = data.events[ type ] = [];
|
||||
|
||||
// Attach our meta-handler to the element, since one doesn't exist
|
||||
if (document.addEventListener) {
|
||||
elem.addEventListener(type, data.handler, false);
|
||||
} else if (document.attachEvent) {
|
||||
elem.attachEvent("on" + type, data.handler);
|
||||
}
|
||||
}
|
||||
|
||||
if (!fn.guid) { fn.guid = _V_.guid++; }
|
||||
|
||||
handlers.push(fn);
|
||||
},
|
||||
|
||||
removeEvent: function(elem, type, fn) {
|
||||
var data = _V_.getData(elem), handlers;
|
||||
// If no events exist, nothing to unbind
|
||||
if (!data.events) { return; }
|
||||
|
||||
// Are we removing all bound events?
|
||||
if (!type) {
|
||||
for (type in data.events) {
|
||||
_V_.cleanUpEvents(elem, type);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// And a place to store the handlers for this event type
|
||||
handlers = data.events[type];
|
||||
|
||||
// If no handlers exist, nothing to unbind
|
||||
if (!handlers) { return; }
|
||||
|
||||
// See if we're only removing a single handler
|
||||
if (fn && fn.guid) {
|
||||
for (var i = 0; i < handlers.length; i++) {
|
||||
// We found a match (don't stop here, there could be a couple bound)
|
||||
if (handlers[i].guid === fn.guid) {
|
||||
// Remove the handler from the array of handlers
|
||||
handlers.splice(i--, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_V_.cleanUpEvents(elem, type);
|
||||
},
|
||||
|
||||
cleanUpEvents: function(elem, type) {
|
||||
var data = _V_.getData(elem);
|
||||
// Remove the events of a particular type if there are none left
|
||||
|
||||
if (data.events[type].length === 0) {
|
||||
delete data.events[type];
|
||||
|
||||
// Remove the meta-handler from the element
|
||||
if (document.removeEventListener) {
|
||||
elem.removeEventListener(type, data.handler, false);
|
||||
} else if (document.detachEvent) {
|
||||
elem.detachEvent("on" + type, data.handler);
|
||||
}
|
||||
}
|
||||
|
||||
// Remove the events object if there are no types left
|
||||
if (_V_.isEmpty(data.events)) {
|
||||
delete data.events;
|
||||
delete data.handler;
|
||||
}
|
||||
|
||||
// Finally remove the expando if there is no data left
|
||||
if (_V_.isEmpty(data)) {
|
||||
_V_.removeData(elem);
|
||||
}
|
||||
},
|
||||
|
||||
fixEvent: function(event) {
|
||||
if (event[_V_.expando]) { return event; }
|
||||
// store a copy of the original event object
|
||||
// and "clone" to set read-only properties
|
||||
var originalEvent = event;
|
||||
event = new _V_.Event(originalEvent);
|
||||
|
||||
for ( var i = _V_.Event.props.length, prop; i; ) {
|
||||
prop = _V_.Event.props[ --i ];
|
||||
event[prop] = originalEvent[prop];
|
||||
}
|
||||
|
||||
// Fix target property, if necessary
|
||||
if (!event.target) { event.target = event.srcElement || document; }
|
||||
|
||||
// check if target is a textnode (safari)
|
||||
if (event.target.nodeType === 3) { event.target = event.target.parentNode; }
|
||||
|
||||
// Add relatedTarget, if necessary
|
||||
if (!event.relatedTarget && event.fromElement) {
|
||||
event.relatedTarget = event.fromElement === event.target ? event.toElement : event.fromElement;
|
||||
}
|
||||
|
||||
// Calculate pageX/Y if missing and clientX/Y available
|
||||
if ( event.pageX == null && event.clientX != null ) {
|
||||
var eventDocument = event.target.ownerDocument || document,
|
||||
doc = eventDocument.documentElement,
|
||||
body = eventDocument.body;
|
||||
|
||||
event.pageX = event.clientX + (doc && doc.scrollLeft || body && body.scrollLeft || 0) - (doc && doc.clientLeft || body && body.clientLeft || 0);
|
||||
event.pageY = event.clientY + (doc && doc.scrollTop || body && body.scrollTop || 0) - (doc && doc.clientTop || body && body.clientTop || 0);
|
||||
}
|
||||
|
||||
// Add which for key events
|
||||
if (event.which == null && (event.charCode != null || event.keyCode != null)) {
|
||||
event.which = event.charCode != null ? event.charCode : event.keyCode;
|
||||
}
|
||||
|
||||
// Add metaKey to non-Mac browsers (use ctrl for PC's and Meta for Macs)
|
||||
if ( !event.metaKey && event.ctrlKey ) {
|
||||
event.metaKey = event.ctrlKey;
|
||||
}
|
||||
|
||||
// Add which for click: 1 === left; 2 === middle; 3 === right
|
||||
// Note: button is not normalized, so don't use it
|
||||
if ( !event.which && event.button !== undefined ) {
|
||||
event.which = (event.button & 1 ? 1 : ( event.button & 2 ? 3 : ( event.button & 4 ? 2 : 0 ) ));
|
||||
}
|
||||
|
||||
return event;
|
||||
},
|
||||
|
||||
triggerEvent: function(elem, event) {
|
||||
var data = _V_.getData(elem),
|
||||
parent = elem.parentNode || elem.ownerDocument,
|
||||
type = event.type || event,
|
||||
handler;
|
||||
|
||||
if (data) { handler = data.handler }
|
||||
|
||||
// Added in attion to book. Book code was broke.
|
||||
event = typeof event === "object" ?
|
||||
event[_V_.expando] ?
|
||||
event :
|
||||
new _V_.Event(type, event) :
|
||||
new _V_.Event(type);
|
||||
|
||||
event.type = type;
|
||||
if (handler) {
|
||||
handler.call(elem, event);
|
||||
}
|
||||
|
||||
// Clean up the event in case it is being reused
|
||||
event.result = undefined;
|
||||
event.target = elem;
|
||||
|
||||
// Bubble the event up the tree to the document,
|
||||
// Unless it's been explicitly stopped
|
||||
// if (parent && !event.isPropagationStopped()) {
|
||||
// _V_.triggerEvent(parent, event);
|
||||
//
|
||||
// // We're at the top document so trigger the default action
|
||||
// } else if (!parent && !event.isDefaultPrevented()) {
|
||||
// // log(type);
|
||||
// var targetData = _V_.getData(event.target);
|
||||
// // log(targetData);
|
||||
// var targetHandler = targetData.handler;
|
||||
// // log("2");
|
||||
// if (event.target[event.type]) {
|
||||
// // Temporarily disable the bound handler,
|
||||
// // don't want to execute it twice
|
||||
// if (targetHandler) {
|
||||
// targetData.handler = function(){};
|
||||
// }
|
||||
//
|
||||
// // Trigger the native event (click, focus, blur)
|
||||
// event.target[event.type]();
|
||||
//
|
||||
// // Restore the handler
|
||||
// if (targetHandler) {
|
||||
// targetData.handler = targetHandler;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
});
|
||||
|
||||
// Custom Event object for standardizing event objects between browsers.
|
||||
_V_.Event = function(src, props){
|
||||
// Event object
|
||||
if (src && src.type) {
|
||||
this.originalEvent = src;
|
||||
this.type = src.type;
|
||||
|
||||
// Events bubbling up the document may have been marked as prevented
|
||||
// by a handler lower down the tree; reflect the correct value.
|
||||
this.isDefaultPrevented = (src.defaultPrevented || src.returnValue === false ||
|
||||
src.getPreventDefault && src.getPreventDefault()) ? returnTrue : returnFalse;
|
||||
|
||||
// Event type
|
||||
} else {
|
||||
this.type = src;
|
||||
}
|
||||
|
||||
// Put explicitly provided properties onto the event object
|
||||
if (props) { _V_.merge(this, props); }
|
||||
|
||||
this.timeStamp = (new Date).getTime();
|
||||
|
||||
// Mark it as fixed
|
||||
this[_V_.expando] = true;
|
||||
};
|
||||
|
||||
_V_.Event.prototype = {
|
||||
preventDefault: function() {
|
||||
this.isDefaultPrevented = returnTrue;
|
||||
|
||||
var e = this.originalEvent;
|
||||
if (!e) { return; }
|
||||
|
||||
// if preventDefault exists run it on the original event
|
||||
if (e.preventDefault) {
|
||||
e.preventDefault();
|
||||
// otherwise set the returnValue property of the original event to false (IE)
|
||||
} else {
|
||||
e.returnValue = false;
|
||||
}
|
||||
},
|
||||
stopPropagation: function() {
|
||||
this.isPropagationStopped = returnTrue;
|
||||
|
||||
var e = this.originalEvent;
|
||||
if (!e) { return; }
|
||||
// if stopPropagation exists run it on the original event
|
||||
if (e.stopPropagation) { e.stopPropagation(); }
|
||||
// otherwise set the cancelBubble property of the original event to true (IE)
|
||||
e.cancelBubble = true;
|
||||
},
|
||||
stopImmediatePropagation: function() {
|
||||
this.isImmediatePropagationStopped = returnTrue;
|
||||
this.stopPropagation();
|
||||
},
|
||||
isDefaultPrevented: returnFalse,
|
||||
isPropagationStopped: returnFalse,
|
||||
isImmediatePropagationStopped: returnFalse
|
||||
};
|
||||
_V_.Event.props = "altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode layerX layerY metaKey newValue offsetX offsetY pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target toElement view wheelDelta which".split(" ");
|
||||
|
||||
function returnTrue(){ return true; }
|
||||
function returnFalse(){ return false; }
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
// Javascript JSON implementation
|
||||
// (Parse Method Only)
|
||||
// https://github.com/douglascrockford/JSON-js/blob/master/json2.js
|
||||
|
||||
var JSON;
|
||||
if (!JSON) { JSON = {}; }
|
||||
|
||||
(function(){
|
||||
var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g;
|
||||
|
||||
if (typeof JSON.parse !== 'function') {
|
||||
JSON.parse = function (text, reviver) {
|
||||
var j;
|
||||
|
||||
function walk(holder, key) {
|
||||
var k, v, value = holder[key];
|
||||
if (value && typeof value === 'object') {
|
||||
for (k in value) {
|
||||
if (Object.prototype.hasOwnProperty.call(value, k)) {
|
||||
v = walk(value, k);
|
||||
if (v !== undefined) {
|
||||
value[k] = v;
|
||||
} else {
|
||||
delete value[k];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return reviver.call(holder, key, value);
|
||||
}
|
||||
text = String(text);
|
||||
cx.lastIndex = 0;
|
||||
if (cx.test(text)) {
|
||||
text = text.replace(cx, function (a) {
|
||||
return '\\u' +
|
||||
('0000' + a.charCodeAt(0).toString(16)).slice(-4);
|
||||
});
|
||||
}
|
||||
|
||||
if (/^[\],:{}\s]*$/
|
||||
.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@')
|
||||
.replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']')
|
||||
.replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {
|
||||
|
||||
j = eval('(' + text + ')');
|
||||
|
||||
return typeof reviver === 'function' ?
|
||||
walk({'': j}, '') : j;
|
||||
}
|
||||
|
||||
throw new SyntaxError('JSON.parse');
|
||||
};
|
||||
}
|
||||
}());
|
||||
+325
@@ -0,0 +1,325 @@
|
||||
_V_.merge = function(obj1, obj2, safe){
|
||||
// Make sure second object exists
|
||||
if (!obj2) { obj2 = {}; };
|
||||
|
||||
for (var attrname in obj2){
|
||||
if (obj2.hasOwnProperty(attrname) && (!safe || !obj1.hasOwnProperty(attrname))) { obj1[attrname]=obj2[attrname]; }
|
||||
}
|
||||
return obj1;
|
||||
};
|
||||
_V_.extend = function(obj){ this.merge(this, obj, true); };
|
||||
|
||||
_V_.extend({
|
||||
tech: {}, // Holder for playback technology settings
|
||||
controlSets: {}, // Holder for control set definitions
|
||||
|
||||
// Device Checks
|
||||
isIE: function(){ return !+"\v1"; },
|
||||
isIPad: function(){ return navigator.userAgent.match(/iPad/i) !== null; },
|
||||
isIPhone: function(){ return navigator.userAgent.match(/iPhone/i) !== null; },
|
||||
isIOS: function(){ return VideoJS.isIPhone() || VideoJS.isIPad(); },
|
||||
iOSVersion: function() {
|
||||
var match = navigator.userAgent.match(/OS (\d+)_/i);
|
||||
if (match && match[1]) { return match[1]; }
|
||||
},
|
||||
isAndroid: function(){ return navigator.userAgent.match(/Android.*AppleWebKit/i) !== null; },
|
||||
androidVersion: function() {
|
||||
var match = navigator.userAgent.match(/Android (\d+)\./i);
|
||||
if (match && match[1]) { return match[1]; }
|
||||
},
|
||||
|
||||
testVid: document.createElement("video"),
|
||||
ua: navigator.userAgent,
|
||||
support: {},
|
||||
|
||||
each: function(arr, fn){
|
||||
if (!arr || arr.length === 0) { return; }
|
||||
for (var i=0,j=arr.length; i<j; i++) {
|
||||
fn.call(this, arr[i], i);
|
||||
}
|
||||
},
|
||||
|
||||
el: function(id){ return document.getElementById(id); },
|
||||
createElement: function(tagName, attributes){
|
||||
var el = document.createElement(tagName),
|
||||
attrname;
|
||||
for (attrname in attributes){
|
||||
if (attributes.hasOwnProperty(attrname)) {
|
||||
if (attrname.indexOf("-") !== -1) {
|
||||
el.setAttribute(attrname, attributes[attrname]);
|
||||
} else {
|
||||
el[attrname] = attributes[attrname];
|
||||
}
|
||||
}
|
||||
}
|
||||
return el;
|
||||
},
|
||||
|
||||
insertFirst: function(node, parent){
|
||||
if (parent.firstChild) {
|
||||
parent.insertBefore(node, parent.firstChild);
|
||||
} else {
|
||||
parent.appendChild(node);
|
||||
}
|
||||
},
|
||||
|
||||
addClass: function(element, classToAdd){
|
||||
if ((" "+element.className+" ").indexOf(" "+classToAdd+" ") == -1) {
|
||||
element.className = element.className === "" ? classToAdd : element.className + " " + classToAdd;
|
||||
}
|
||||
},
|
||||
|
||||
removeClass: function(element, classToRemove){
|
||||
if (element.className.indexOf(classToRemove) == -1) { return; }
|
||||
var classNames = element.className.split(" ");
|
||||
classNames.splice(classNames.indexOf(classToRemove),1);
|
||||
element.className = classNames.join(" ");
|
||||
},
|
||||
|
||||
remove: function(item, array){
|
||||
if (!array) return;
|
||||
var i = array.indexOf(item);
|
||||
if (i != -1) {
|
||||
return array.splice(i, 1)
|
||||
};
|
||||
},
|
||||
|
||||
// Attempt to block the ability to select text while dragging controls
|
||||
blockTextSelection: function(){
|
||||
document.body.focus();
|
||||
document.onselectstart = function () { return false; };
|
||||
},
|
||||
// Turn off text selection blocking
|
||||
unblockTextSelection: function(){ document.onselectstart = function () { return true; }; },
|
||||
|
||||
// Return seconds as H:MM:SS or M:SS
|
||||
// Supplying a guide (in seconds) will include enough leading zeros to cover the length of the guide
|
||||
formatTime: function(seconds, guide) {
|
||||
var guide = guide || seconds, // Default to using seconds as guide
|
||||
s = Math.floor(seconds % 60),
|
||||
m = Math.floor(seconds / 60 % 60),
|
||||
h = Math.floor(seconds / 3600),
|
||||
gm = Math.floor(guide / 60 % 60),
|
||||
gh = Math.floor(guide / 3600);
|
||||
|
||||
// Check if we need to show hours
|
||||
h = (h > 0 || gh > 0) ? h + ":" : "";
|
||||
|
||||
// If hours are showing, we may need to add a leading zero.
|
||||
// Always show at least one digit of minutes.
|
||||
m = (((h || gm >= 10) && m < 10) ? "0" + m : m) + ":";
|
||||
|
||||
// Check if leading zero is need for seconds
|
||||
s = (s < 10) ? "0" + s : s;
|
||||
|
||||
return h + m + s;
|
||||
},
|
||||
|
||||
capitalize: function(string){
|
||||
return string.charAt(0).toUpperCase() + string.slice(1);
|
||||
},
|
||||
|
||||
// Return the relative horizonal position of an event as a value from 0-1
|
||||
getRelativePosition: function(x, relativeElement){
|
||||
return Math.max(0, Math.min(1, (x - _V_.findPosX(relativeElement)) / relativeElement.offsetWidth));
|
||||
},
|
||||
|
||||
getComputedStyleValue: function(element, style){
|
||||
return window.getComputedStyle(element, null).getPropertyValue(style);
|
||||
},
|
||||
|
||||
trim: function(string){ return string.toString().replace(/^\s+/, "").replace(/\s+$/, ""); },
|
||||
round: function(num, dec) {
|
||||
if (!dec) { dec = 0; }
|
||||
return Math.round(num*Math.pow(10,dec))/Math.pow(10,dec);
|
||||
},
|
||||
|
||||
isEmpty: function(object) {
|
||||
for (var prop in object) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
},
|
||||
|
||||
// Mimic HTML5 TimeRange Spec.
|
||||
createTimeRange: function(start, end){
|
||||
return {
|
||||
length: 1,
|
||||
start: function() { return start; },
|
||||
end: function() { return end; }
|
||||
};
|
||||
},
|
||||
|
||||
/* Element Data Store. Allows for binding data to an element without putting it directly on the element.
|
||||
Ex. Event listneres are stored here.
|
||||
(also from jsninja.com)
|
||||
================================================================================ */
|
||||
cache: {}, // Where the data is stored
|
||||
guid: 1, // Unique ID for the element
|
||||
expando: "vdata" + (new Date).getTime(), // Unique attribute to store element's guid in
|
||||
|
||||
// Returns the cache object where data for the element is stored
|
||||
getData: function(elem){
|
||||
var id = elem[_V_.expando];
|
||||
if (!id) {
|
||||
id = elem[_V_.expando] = _V_.guid++;
|
||||
_V_.cache[id] = {};
|
||||
}
|
||||
return _V_.cache[id];
|
||||
},
|
||||
// Delete data for the element from the cache and the guid attr from element
|
||||
removeData: function(elem){
|
||||
var id = elem[_V_.expando];
|
||||
if (!id) { return; }
|
||||
// Remove all stored data
|
||||
delete _V_.cache[id];
|
||||
// Remove the expando property from the DOM node
|
||||
try {
|
||||
delete elem[_V_.expando];
|
||||
} catch(e) {
|
||||
if (elem.removeAttribute) {
|
||||
elem.removeAttribute(_V_.expando);
|
||||
} else {
|
||||
// IE doesn't appear to support removeAttribute on the document element
|
||||
elem[_V_.expando] = null;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/* Proxy (a.k.a Bind or Context). A simple method for changing the context of a function
|
||||
It also stores a unique id on the function so it can be easily removed from events
|
||||
================================================================================ */
|
||||
proxy: function(context, fn) {
|
||||
// Make sure the function has a unique ID
|
||||
if (!fn.guid) { fn.guid = _V_.guid++; }
|
||||
// Create the new function that changes the context
|
||||
var ret = function() {
|
||||
return fn.apply(context, arguments);
|
||||
};
|
||||
|
||||
// Give the new function the same ID
|
||||
// (so that they are equivalent and can be easily removed)
|
||||
ret.guid = fn.guid;
|
||||
|
||||
return ret;
|
||||
},
|
||||
|
||||
get: function(url, onSuccess, onError){
|
||||
// if (netscape.security.PrivilegeManager.enablePrivilege) {
|
||||
// netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
|
||||
// }
|
||||
|
||||
var local = (url.indexOf("file:") == 0 || (window.location.href.indexOf("file:") == 0 && url.indexOf("http:") == -1));
|
||||
|
||||
if (typeof XMLHttpRequest == "undefined") {
|
||||
XMLHttpRequest = function () {
|
||||
try { return new ActiveXObject("Msxml2.XMLHTTP.6.0"); } catch (e) {}
|
||||
try { return new ActiveXObject("Msxml2.XMLHTTP.3.0"); } catch (f) {}
|
||||
try { return new ActiveXObject("Msxml2.XMLHTTP"); } catch (g) {}
|
||||
throw new Error("This browser does not support XMLHttpRequest.");
|
||||
};
|
||||
}
|
||||
|
||||
var request = new XMLHttpRequest();
|
||||
|
||||
try {
|
||||
request.open("GET", url);
|
||||
} catch(e) {
|
||||
_V_.log("VideoJS XMLHttpRequest (open)", e);
|
||||
// onError(e);
|
||||
return false;
|
||||
}
|
||||
|
||||
request.onreadystatechange = _V_.proxy(this, function() {
|
||||
if (request.readyState == 4) {
|
||||
if (request.status == 200 || local && request.status == 0) {
|
||||
onSuccess(request.responseText);
|
||||
} else {
|
||||
if (onError) {
|
||||
onError();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
try {
|
||||
request.send();
|
||||
} catch(e) {
|
||||
_V_.log("VideoJS XMLHttpRequest (send)", e);
|
||||
if (onError) {
|
||||
onError(e);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/* Local Storage
|
||||
================================================================================ */
|
||||
setLocalStorage: function(key, value){
|
||||
// IE was throwing errors referencing the var anywhere without this
|
||||
var localStorage = localStorage || false;
|
||||
if (!localStorage) { return; }
|
||||
try {
|
||||
localStorage[key] = value;
|
||||
} catch(e) {
|
||||
if (e.code == 22 || e.code == 1014) { // Webkit == 22 / Firefox == 1014
|
||||
_V_.log("LocalStorage Full (VideoJS)", e);
|
||||
} else {
|
||||
_V_.log("LocalStorage Error (VideoJS)", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
// usage: log('inside coolFunc', this, arguments);
|
||||
// paulirish.com/2009/log-a-lightweight-wrapper-for-consolelog/
|
||||
_V_.log = function(){
|
||||
_V_.log.history = _V_.log.history || [];// store logs to an array for reference
|
||||
_V_.log.history.push(arguments);
|
||||
if(window.console) {
|
||||
arguments.callee = arguments.callee.caller;
|
||||
var newarr = [].slice.call(arguments);
|
||||
(typeof console.log === 'object' ? _V_.log.apply.call(console.log, console, newarr) : console.log.apply(console, newarr));
|
||||
}
|
||||
};
|
||||
|
||||
// make it safe to use console.log always
|
||||
(function(b){function c(){}for(var d="assert,count,debug,dir,dirxml,error,exception,group,groupCollapsed,groupEnd,info,log,timeStamp,profile,profileEnd,time,timeEnd,trace,warn".split(","),a;a=d.pop();){b[a]=b[a]||c}})((function(){try
|
||||
{console.log();return window.console;}catch(err){return window.console={};}})());
|
||||
|
||||
// Offset Left
|
||||
// getBoundingClientRect technique from John Resig http://ejohn.org/blog/getboundingclientrect-is-awesome/
|
||||
if ("getBoundingClientRect" in document.documentElement) {
|
||||
_V_.findPosX = function(el) {
|
||||
var box;
|
||||
|
||||
try {
|
||||
box = el.getBoundingClientRect();
|
||||
} catch(e) {}
|
||||
|
||||
if (!box) { return 0; }
|
||||
|
||||
var docEl = document.documentElement,
|
||||
body = document.body,
|
||||
clientLeft = docEl.clientLeft || body.clientLeft || 0,
|
||||
scrollLeft = window.pageXOffset || body.scrollLeft,
|
||||
left = box.left + scrollLeft - clientLeft;
|
||||
|
||||
return left;
|
||||
};
|
||||
} else {
|
||||
_V_.findPosX = function(el) {
|
||||
var curleft = el.offsetLeft;
|
||||
// _V_.log(obj.className, obj.offsetLeft)
|
||||
while(el = obj.offsetParent) {
|
||||
if (el.className.indexOf("video-js") == -1) {
|
||||
// _V_.log(el.offsetParent, "OFFSETLEFT", el.offsetLeft)
|
||||
// _V_.log("-webkit-full-screen", el.webkitMatchesSelector("-webkit-full-screen"));
|
||||
// _V_.log("-webkit-full-screen", el.querySelectorAll(".video-js:-webkit-full-screen"));
|
||||
} else {
|
||||
}
|
||||
curleft += el.offsetLeft;
|
||||
}
|
||||
return curleft;
|
||||
};
|
||||
}
|
||||
+764
@@ -0,0 +1,764 @@
|
||||
/* UI Component- Base class for all UI objects
|
||||
================================================================================ */
|
||||
_V_.Player = _V_.Component.extend({
|
||||
|
||||
init: function(tag, addOptions, ready){
|
||||
|
||||
this.tag = tag; // Store the original tag used to set options
|
||||
|
||||
var el = this.el = _V_.createElement("div"), // Div to contain video and controls
|
||||
options = this.options = {},
|
||||
width = options.width = tag.width,
|
||||
height = options.height = tag.height,
|
||||
|
||||
// Browsers default to 300x150 if there's no width/height or video size data.
|
||||
initWidth = width || 300,
|
||||
initHeight = height || 150;
|
||||
|
||||
// Make player findable on elements
|
||||
tag.player = el.player = this;
|
||||
|
||||
// Add callback to ready queue
|
||||
this.ready(ready);
|
||||
|
||||
// Wrap video tag in div (el/box) container
|
||||
tag.parentNode.insertBefore(el, tag);
|
||||
el.appendChild(tag); // Breaks iPhone, fixed in HTML5 setup.
|
||||
|
||||
// Give video tag properties to box
|
||||
el.id = this.id = tag.id; // ID will now reference box, not the video tag
|
||||
el.className = tag.className;
|
||||
// Update tag id/class for use as HTML5 playback tech
|
||||
tag.id += "_html5_api";
|
||||
tag.className = "vjs-tech";
|
||||
|
||||
// Make player easily findable by ID
|
||||
_V_.players[el.id] = this;
|
||||
|
||||
// Make box use width/height of tag, or default 300x150
|
||||
el.setAttribute("width", initWidth);
|
||||
el.setAttribute("height", initHeight);
|
||||
// Enforce with CSS since width/height attrs don't work on divs
|
||||
el.style.width = initWidth+"px";
|
||||
el.style.height = initHeight+"px";
|
||||
// Remove width/height attrs from tag so CSS can make it 100% width/height
|
||||
tag.removeAttribute("width");
|
||||
tag.removeAttribute("height");
|
||||
|
||||
// Set Options
|
||||
_V_.merge(options, _V_.options); // Copy Global Defaults
|
||||
_V_.merge(options, this.getVideoTagSettings()); // Override with Video Tag Options
|
||||
_V_.merge(options, addOptions); // Override/extend with options from setup call
|
||||
|
||||
// Store controls setting, and then remove immediately so native controls don't flash.
|
||||
tag.removeAttribute("controls");
|
||||
|
||||
// Poster will be handled by a manual <img>
|
||||
tag.removeAttribute("poster");
|
||||
|
||||
// Empty video tag sources and tracks so the built in player doesn't use them also.
|
||||
if (tag.hasChildNodes()) {
|
||||
for (var i=0,j=tag.childNodes;i<j.length;i++) {
|
||||
if (j[i].nodeName == "SOURCE" || j[i].nodeName == "TRACK") {
|
||||
tag.removeChild(j[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Holder for playback tech components
|
||||
this.techs = {};
|
||||
|
||||
// Cache for video property values.
|
||||
this.values = {};
|
||||
|
||||
this.addClass("vjs-paused");
|
||||
|
||||
this.addEvent("ended", this.onEnded);
|
||||
this.addEvent("play", this.onPlay);
|
||||
this.addEvent("pause", this.onPause);
|
||||
this.addEvent("error", this.onError);
|
||||
|
||||
// When the API is ready, loop through the components and add to the player.
|
||||
if (options.controls) {
|
||||
this.ready(function(){
|
||||
this.each(this.options.components, function(set){
|
||||
this.addComponent(set);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// If there are no sources when the player is initialized,
|
||||
// load the first supported playback technology.
|
||||
if (!options.sources || options.sources.length == 0) {
|
||||
for (var i=0,j=options.techOrder; i<j.length; i++) {
|
||||
var techName = j[i],
|
||||
tech = _V_[techName];
|
||||
|
||||
// Check if the browser supports this technology
|
||||
if (tech.isSupported()) {
|
||||
this.loadTech(techName);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Loop through playback technologies (HTML5, Flash) and check for support
|
||||
// Then load the best source.
|
||||
this.src(options.sources);
|
||||
}
|
||||
},
|
||||
|
||||
// Cache for video property values.
|
||||
values: {},
|
||||
|
||||
destroy: function(){
|
||||
// Ensure that tracking progress and time progress will stop and plater deleted
|
||||
this.stopTrackingProgress();
|
||||
this.stopTrackingCurrentTime();
|
||||
delete _V_.players[this.id]
|
||||
},
|
||||
|
||||
createElement: function(type, options){
|
||||
|
||||
},
|
||||
|
||||
getVideoTagSettings: function(){
|
||||
var options = {
|
||||
sources: [],
|
||||
tracks: []
|
||||
};
|
||||
|
||||
options.src = this.tag.src;
|
||||
options.controls = this.tag.getAttribute("controls") !== null;
|
||||
options.poster = this.tag.poster;
|
||||
options.preload = this.tag.preload;
|
||||
options.autoplay = this.tag.getAttribute("autoplay") !== null; // hasAttribute not IE <8 compatible
|
||||
options.loop = this.tag.getAttribute("loop") !== null;
|
||||
options.muted = this.tag.getAttribute("muted") !== null;
|
||||
|
||||
for (var c,i=0,j=this.tag.children;i<j.length;i++) {
|
||||
c = j[i];
|
||||
if (c.nodeName == "SOURCE") {
|
||||
options.sources.push({
|
||||
src: c.src,
|
||||
type: c.type,
|
||||
media: c.media,
|
||||
title: c.title
|
||||
});
|
||||
}
|
||||
if (c.nodeName == "TRACK") {
|
||||
options.tracks.push(new _V_.Track({
|
||||
src: c.getAttribute("src"),
|
||||
kind: c.getAttribute("kind"),
|
||||
srclang: c.getAttribute("srclang"),
|
||||
label: c.getAttribute("label"),
|
||||
'default': c.getAttribute("default") !== null,
|
||||
title: c.getAttribute("title")
|
||||
}, this));
|
||||
|
||||
}
|
||||
}
|
||||
return options;
|
||||
},
|
||||
|
||||
/* PLayback Technology (tech)
|
||||
================================================================================ */
|
||||
// Load/Create an instance of playback technlogy including element and API methods
|
||||
// And append playback element in player div.
|
||||
loadTech: function(techName, source){
|
||||
|
||||
// Pause and remove current playback technology
|
||||
if (this.tech) {
|
||||
this.unloadTech();
|
||||
|
||||
// If the first time loading, HTML5 tag will exist but won't be initialized
|
||||
// So we need to remove it if we're not loading HTML5
|
||||
} else if (techName != "html5" && this.tag) {
|
||||
this.el.removeChild(this.tag);
|
||||
this.tag = false;
|
||||
}
|
||||
|
||||
this.techName = techName;
|
||||
|
||||
// Turn off API access because we're loading a new tech that might load asynchronously
|
||||
this.isReady = false;
|
||||
|
||||
var techReady = function(){
|
||||
this.player.triggerReady();
|
||||
|
||||
// Manually track progress in cases where the browser/flash player doesn't report it.
|
||||
if (!this.support.progressEvent) {
|
||||
this.player.manualProgressOn();
|
||||
}
|
||||
|
||||
// Manually track timeudpates in cases where the browser/flash player doesn't report it.
|
||||
if (!this.support.timeupdateEvent) {
|
||||
this.player.manualTimeUpdatesOn();
|
||||
}
|
||||
}
|
||||
|
||||
// Grab tech-specific options from player options and add source and parent element to use.
|
||||
var techOptions = _V_.merge({ source: source, parentEl: this.el }, this.options[techName])
|
||||
|
||||
if (source) {
|
||||
if (source.src == this.values.src && this.values.currentTime > 0) {
|
||||
techOptions.startTime = this.values.currentTime;
|
||||
}
|
||||
|
||||
this.values.src = source.src;
|
||||
}
|
||||
|
||||
// Initialize tech instance
|
||||
this.tech = new _V_[techName](this, techOptions);
|
||||
this.tech.ready(techReady);
|
||||
},
|
||||
|
||||
unloadTech: function(){
|
||||
this.tech.destroy();
|
||||
|
||||
// Turn off any manual progress or timeupdate tracking
|
||||
if (this.manualProgress) { this.manualProgressOff(); }
|
||||
|
||||
if (this.manualTimeUpdates) { this.manualTimeUpdatesOff(); }
|
||||
|
||||
this.tech = false;
|
||||
},
|
||||
|
||||
// There's many issues around changing the size of a Flash (or other plugin) object.
|
||||
// First is a plugin reload issue in Firefox that has been around for 11 years: https://bugzilla.mozilla.org/show_bug.cgi?id=90268
|
||||
// Then with the new fullscreen API, Mozilla and webkit browsers will reload the flash object after going to fullscreen.
|
||||
// To get around this, we're unloading the tech, caching source and currentTime values, and reloading the tech once the plugin is resized.
|
||||
reloadTech: function(betweenFn){
|
||||
_V_.log("unloadingTech")
|
||||
this.unloadTech();
|
||||
_V_.log("unloadedTech")
|
||||
if (betweenFn) { betweenFn.call(); }
|
||||
_V_.log("LoadingTech")
|
||||
this.loadTech(this.techName, { src: this.values.src })
|
||||
_V_.log("loadedTech")
|
||||
},
|
||||
|
||||
/* Fallbacks for unsupported event types
|
||||
================================================================================ */
|
||||
// Manually trigger progress events based on changes to the buffered amount
|
||||
// Many flash players and older HTML5 browsers don't send progress or progress-like events
|
||||
manualProgressOn: function(){
|
||||
this.manualProgress = true;
|
||||
|
||||
// Trigger progress watching when a source begins loading
|
||||
this.trackProgress();
|
||||
|
||||
// Watch for a native progress event call on the tech element
|
||||
// In HTML5, some older versions don't support the progress event
|
||||
// So we're assuming they don't, and turning off manual progress if they do.
|
||||
this.tech.addEvent("progress", function(){
|
||||
|
||||
// Remove this listener from the element
|
||||
this.removeEvent("progress", arguments.callee);
|
||||
|
||||
// Update known progress support for this playback technology
|
||||
this.support.progressEvent = true;
|
||||
|
||||
// Turn off manual progress tracking
|
||||
this.player.manualProgressOff();
|
||||
});
|
||||
},
|
||||
|
||||
manualProgressOff: function(){
|
||||
this.manualProgress = false;
|
||||
this.stopTrackingProgress();
|
||||
},
|
||||
|
||||
trackProgress: function(){
|
||||
this.progressInterval = setInterval(_V_.proxy(this, function(){
|
||||
// Don't trigger unless buffered amount is greater than last time
|
||||
// log(this.values.bufferEnd, this.buffered().end(0), this.duration())
|
||||
/* TODO: update for multiple buffered regions */
|
||||
if (this.values.bufferEnd < this.buffered().end(0)) {
|
||||
this.triggerEvent("progress");
|
||||
} else if (this.bufferedPercent() == 1) {
|
||||
this.stopTrackingProgress();
|
||||
this.triggerEvent("progress"); // Last update
|
||||
}
|
||||
}), 500);
|
||||
},
|
||||
stopTrackingProgress: function(){ clearInterval(this.progressInterval); },
|
||||
|
||||
/* Time Tracking -------------------------------------------------------------- */
|
||||
manualTimeUpdatesOn: function(){
|
||||
this.manualTimeUpdates = true;
|
||||
|
||||
this.addEvent("play", this.trackCurrentTime);
|
||||
this.addEvent("pause", this.stopTrackingCurrentTime);
|
||||
// timeupdate is also called by .currentTime whenever current time is set
|
||||
|
||||
// Watch for native timeupdate event
|
||||
this.tech.addEvent("timeupdate", function(){
|
||||
|
||||
// Remove this listener from the element
|
||||
this.removeEvent("timeupdate", arguments.callee);
|
||||
|
||||
// Update known progress support for this playback technology
|
||||
this.support.timeupdateEvent = true;
|
||||
|
||||
// Turn off manual progress tracking
|
||||
this.player.manualTimeUpdatesOff();
|
||||
});
|
||||
},
|
||||
|
||||
manualTimeUpdatesOff: function(){
|
||||
this.manualTimeUpdates = false;
|
||||
this.stopTrackingCurrentTime();
|
||||
this.removeEvent("play", this.trackCurrentTime);
|
||||
this.removeEvent("pause", this.stopTrackingCurrentTime);
|
||||
},
|
||||
|
||||
trackCurrentTime: function(){
|
||||
if (this.currentTimeInterval) { this.stopTrackingCurrentTime(); }
|
||||
this.currentTimeInterval = setInterval(_V_.proxy(this, function(){
|
||||
this.triggerEvent("timeupdate");
|
||||
}), 250); // 42 = 24 fps // 250 is what Webkit uses // FF uses 15
|
||||
},
|
||||
|
||||
// Turn off play progress tracking (when paused or dragging)
|
||||
stopTrackingCurrentTime: function(){ clearInterval(this.currentTimeInterval); },
|
||||
|
||||
/* Player event handlers (how the player reacts to certain events)
|
||||
================================================================================ */
|
||||
onEnded: function(){
|
||||
if (this.options.loop) {
|
||||
this.currentTime(0);
|
||||
this.play();
|
||||
} else {
|
||||
this.pause();
|
||||
this.currentTime(0);
|
||||
this.pause();
|
||||
}
|
||||
},
|
||||
|
||||
onPlay: function(){
|
||||
_V_.removeClass(this.el, "vjs-paused");
|
||||
_V_.addClass(this.el, "vjs-playing");
|
||||
},
|
||||
|
||||
onPause: function(){
|
||||
_V_.removeClass(this.el, "vjs-playing");
|
||||
_V_.addClass(this.el, "vjs-paused");
|
||||
},
|
||||
|
||||
onError: function(e) {
|
||||
_V_.log("Video Error", e);
|
||||
},
|
||||
|
||||
/* Player API
|
||||
================================================================================ */
|
||||
|
||||
apiCall: function(method, arg){
|
||||
if (this.isReady) {
|
||||
return this.tech[method](arg);
|
||||
} else {
|
||||
_V_.log("The playback technology API is not ready yet. Use player.ready(myFunction)."+" ["+method+"]", arguments.callee.caller.arguments.callee.caller.arguments.callee.caller)
|
||||
return false;
|
||||
// throw new Error("The playback technology API is not ready yet. Use player.ready(myFunction)."+" ["+method+"]");
|
||||
}
|
||||
},
|
||||
|
||||
play: function(){
|
||||
this.apiCall("play"); return this;
|
||||
},
|
||||
pause: function(){
|
||||
this.apiCall("pause"); return this;
|
||||
},
|
||||
paused: function(){
|
||||
return this.apiCall("paused");
|
||||
},
|
||||
|
||||
currentTime: function(seconds){
|
||||
if (seconds !== undefined) {
|
||||
|
||||
// Cache the last set value for smoother scrubbing.
|
||||
this.values.lastSetCurrentTime = seconds;
|
||||
|
||||
this.apiCall("setCurrentTime", seconds);
|
||||
|
||||
if (this.manualTimeUpdates) {
|
||||
this.triggerEvent("timeupdate");
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
// Cache last currentTime and return
|
||||
return this.values.currentTime = this.apiCall("currentTime");
|
||||
},
|
||||
duration: function(){
|
||||
return this.apiCall("duration");
|
||||
},
|
||||
remainingTime: function(){
|
||||
return this.duration() - this.currentTime();
|
||||
},
|
||||
|
||||
buffered: function(){
|
||||
var buffered = this.apiCall("buffered"),
|
||||
start = 0, end = this.values.bufferEnd = this.values.bufferEnd || 0,
|
||||
timeRange;
|
||||
|
||||
if (buffered && buffered.length > 0 && buffered.end(0) !== end) {
|
||||
end = buffered.end(0);
|
||||
// Storing values allows them be overridden by setBufferedFromProgress
|
||||
this.values.bufferEnd = end;
|
||||
}
|
||||
|
||||
return _V_.createTimeRange(start, end);
|
||||
},
|
||||
|
||||
// Calculates amount of buffer is full
|
||||
bufferedPercent: function(){
|
||||
return (this.duration()) ? this.buffered().end(0) / this.duration() : 0;
|
||||
},
|
||||
|
||||
volume: function(percentAsDecimal){
|
||||
if (percentAsDecimal !== undefined) {
|
||||
var vol = Math.max(0, Math.min(1, parseFloat(percentAsDecimal))); // Force value to between 0 and 1
|
||||
this.values.volume = vol;
|
||||
this.apiCall("setVolume", vol);
|
||||
_V_.setLocalStorage("volume", vol);
|
||||
return this;
|
||||
}
|
||||
// if (this.values.volume) { return this.values.volume; }
|
||||
return this.apiCall("volume");
|
||||
},
|
||||
muted: function(muted){
|
||||
if (muted !== undefined) {
|
||||
this.apiCall("setMuted", muted);
|
||||
return this;
|
||||
}
|
||||
return this.apiCall("muted");
|
||||
},
|
||||
|
||||
width: function(width, skipListeners){
|
||||
if (width !== undefined) {
|
||||
this.el.width = width;
|
||||
this.el.style.width = width+"px";
|
||||
if (!skipListeners) { this.triggerEvent("resize"); }
|
||||
return this;
|
||||
}
|
||||
return parseInt(this.el.getAttribute("width"));
|
||||
},
|
||||
height: function(height){
|
||||
if (height !== undefined) {
|
||||
this.el.height = height;
|
||||
this.el.style.height = height+"px";
|
||||
this.triggerEvent("resize");
|
||||
return this;
|
||||
}
|
||||
return parseInt(this.el.getAttribute("height"));
|
||||
},
|
||||
size: function(width, height){
|
||||
// Skip resize listeners on width for optimization
|
||||
return this.width(width, true).height(height);
|
||||
},
|
||||
|
||||
supportsFullScreen: function(){ return this.apiCall("supportsFullScreen"); },
|
||||
|
||||
// Turn on fullscreen (or window) mode
|
||||
requestFullScreen: function(){
|
||||
var requestFullScreen = _V_.support.requestFullScreen;
|
||||
|
||||
// Check for browser element fullscreen support
|
||||
if (requestFullScreen) {
|
||||
// Flash and other plugins get reloaded when you take their parent to fullscreen.
|
||||
// To fix that we'll remove the tech, and reload it after the resize has finished.
|
||||
if (this.tech.support.fullscreenResize === false) {
|
||||
|
||||
this.pause();
|
||||
this.unloadTech();
|
||||
|
||||
_V_.addEvent(document, "keydown", _V_.proxy(this, function(e){
|
||||
_V_.log("asdf", e)
|
||||
}));
|
||||
|
||||
_V_.addEvent(document, requestFullScreen.eventName, this.proxy(function(){
|
||||
_V_.removeEvent(document, requestFullScreen.eventName, arguments.callee);
|
||||
this.loadTech(this.techName, { src: this.values.src });
|
||||
}));
|
||||
|
||||
this.el[requestFullScreen.requestFn]();
|
||||
|
||||
} else {
|
||||
this.el[requestFullScreen.requestFn]();
|
||||
}
|
||||
|
||||
} else if (this.tech.supportsFullScreen()) {
|
||||
this.apiCall("enterFullScreen");
|
||||
|
||||
} else {
|
||||
this.enterFullWindow();
|
||||
}
|
||||
|
||||
this.videoIsFullScreen = true;
|
||||
this.triggerEvent("fullscreenchange");
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
cancelFullScreen: function(){
|
||||
var requestFullScreen = _V_.support.requestFullScreen;
|
||||
|
||||
// Check for browser element fullscreen support
|
||||
if (requestFullScreen) {
|
||||
|
||||
// Flash and other plugins get reloaded when you take their parent to fullscreen.
|
||||
// To fix that we'll remove the tech, and reload it after the resize has finished.
|
||||
if (this.tech.support.fullscreenResize === false) {
|
||||
|
||||
this.pause();
|
||||
this.unloadTech();
|
||||
|
||||
_V_.addEvent(document, requestFullScreen.eventName, this.proxy(function(){
|
||||
_V_.removeEvent(document, requestFullScreen.eventName, arguments.callee);
|
||||
_V_.log("document fullscreeneventchange")
|
||||
this.loadTech(this.techName, { src: this.values.src })
|
||||
}));
|
||||
|
||||
document[requestFullScreen.cancelFn]();
|
||||
|
||||
} else {
|
||||
document[requestFullScreen.cancelFn]();
|
||||
}
|
||||
|
||||
} else if (this.tech.supportsFullScreen()) {
|
||||
this.apiCall("exitFullScreen");
|
||||
|
||||
} else {
|
||||
this.exitFullWindow();
|
||||
}
|
||||
|
||||
this.videoIsFullScreen = false;
|
||||
this.triggerEvent("fullscreenchange");
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
enterFullWindow: function(){
|
||||
this.videoIsFullScreen = true;
|
||||
|
||||
// Storing original doc overflow value to return to when fullscreen is off
|
||||
this.docOrigOverflow = document.documentElement.style.overflow;
|
||||
|
||||
// Add listener for esc key to exit fullscreen
|
||||
_V_.addEvent(document, "keydown", _V_.proxy(this, this.fullWindowOnEscKey));
|
||||
|
||||
// Hide any scroll bars
|
||||
document.documentElement.style.overflow = 'hidden';
|
||||
|
||||
// Apply fullscreen styles
|
||||
_V_.addClass(document.body, "vjs-full-window");
|
||||
_V_.addClass(this.el, "vjs-fullscreen");
|
||||
|
||||
this.triggerEvent("enterFullWindow");
|
||||
},
|
||||
|
||||
fullWindowOnEscKey: function(event){
|
||||
if (event.keyCode == 27) {
|
||||
this.cancelFullScreen();
|
||||
}
|
||||
},
|
||||
|
||||
exitFullWindow: function(){
|
||||
this.videoIsFullScreen = false;
|
||||
_V_.removeEvent(document, "keydown", this.fullWindowOnEscKey);
|
||||
|
||||
// Unhide scroll bars.
|
||||
document.documentElement.style.overflow = this.docOrigOverflow;
|
||||
|
||||
// Remove fullscreen styles
|
||||
_V_.removeClass(document.body, "vjs-full-window");
|
||||
_V_.removeClass(this.el, "vjs-fullscreen");
|
||||
|
||||
// Resize the box, controller, and poster to original sizes
|
||||
// this.positionAll();
|
||||
this.triggerEvent("exitFullWindow");
|
||||
},
|
||||
|
||||
// src is a pretty powerful function
|
||||
// If you pass it an array of source objects, it will find the best source to play and use that object.src
|
||||
// If the new source requires a new playback technology, it will switch to that.
|
||||
// If you pass it an object, it will set the source to object.src
|
||||
// If you pass it anything else (url string) it will set the video source to that
|
||||
src: function(source){
|
||||
// Case: Array of source objects to choose from and pick the best to play
|
||||
if (source instanceof Array) {
|
||||
|
||||
var sources = source;
|
||||
|
||||
techLoop: // Named loop for breaking both loops
|
||||
// Loop through each playback technology in the options order
|
||||
for (var i=0,j=this.options.techOrder;i<j.length;i++) {
|
||||
var techName = j[i],
|
||||
tech = _V_[techName];
|
||||
// tech = _V_.tech[techName];
|
||||
|
||||
// Check if the browser supports this technology
|
||||
if (tech.isSupported()) {
|
||||
|
||||
// Loop through each source object
|
||||
for (var a=0,b=sources;a<b.length;a++) {
|
||||
var source = b[a];
|
||||
|
||||
// Check if source can be played with this technology
|
||||
if (tech.canPlaySource.call(this, source)) {
|
||||
|
||||
// If this technology is already loaded, set source
|
||||
if (techName == this.currentTechName) {
|
||||
this.src(source); // Passing the source object
|
||||
|
||||
// Otherwise load this technology with chosen source
|
||||
} else {
|
||||
this.loadTech(techName, source);
|
||||
}
|
||||
|
||||
break techLoop; // Break both loops
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Case: Source object { src: "", type: "" ... }
|
||||
} else if (source instanceof Object) {
|
||||
if (_V_[this.techName].canPlaySource(source)) {
|
||||
this.src(source.src);
|
||||
} else {
|
||||
// Send through tech loop to check for a compatible technology.
|
||||
this.src([source]);
|
||||
}
|
||||
// Case: URL String (http://myvideo...)
|
||||
} else {
|
||||
// Cache for getting last set source
|
||||
this.values.src = source;
|
||||
|
||||
if (!this.isReady) {
|
||||
this.ready(function(){
|
||||
this.src(source);
|
||||
});
|
||||
} else {
|
||||
this.apiCall("src", source);
|
||||
if (this.options.preload == "auto") {
|
||||
this.load();
|
||||
}
|
||||
if (this.options.autoplay) {
|
||||
this.play();
|
||||
}
|
||||
}
|
||||
}
|
||||
return this;
|
||||
},
|
||||
|
||||
// Begin loading the src data
|
||||
load: function(){
|
||||
this.apiCall("load");
|
||||
return this;
|
||||
},
|
||||
currentSrc: function(){
|
||||
return this.apiCall("currentSrc");
|
||||
},
|
||||
|
||||
textTrackValue: function(kind, value){
|
||||
if (value !== undefined) {
|
||||
this.values[kind] = value;
|
||||
this.triggerEvent(kind+"update");
|
||||
return this;
|
||||
}
|
||||
return this.values[kind];
|
||||
},
|
||||
|
||||
// Attributes/Options
|
||||
preload: function(value){
|
||||
if (value !== undefined) {
|
||||
this.apiCall("setPreload", value);
|
||||
this.options.preload = value;
|
||||
return this;
|
||||
}
|
||||
return this.apiCall("preload", value);
|
||||
},
|
||||
autoplay: function(value){
|
||||
if (value !== undefined) {
|
||||
this.apiCall("setAutoplay", value);
|
||||
this.options.autoplay = value;
|
||||
return this;
|
||||
}
|
||||
return this.apiCall("autoplay", value);
|
||||
},
|
||||
loop: function(value){
|
||||
if (value !== undefined) {
|
||||
this.apiCall("setLoop", value);
|
||||
this.options.loop = value;
|
||||
return this;
|
||||
}
|
||||
return this.apiCall("loop", value);
|
||||
},
|
||||
|
||||
controls: function(){ return this.options.controls; },
|
||||
textTracks: function(){ return this.options.tracks; },
|
||||
poster: function(){ return this.apiCall("poster"); },
|
||||
|
||||
error: function(){ return this.apiCall("error"); },
|
||||
networkState: function(){ return this.apiCall("networkState"); },
|
||||
readyState: function(){ return this.apiCall("readyState"); },
|
||||
seeking: function(){ return this.apiCall("seeking"); },
|
||||
initialTime: function(){ return this.apiCall("initialTime"); },
|
||||
startOffsetTime: function(){ return this.apiCall("startOffsetTime"); },
|
||||
played: function(){ return this.apiCall("played"); },
|
||||
seekable: function(){ return this.apiCall("seekable"); },
|
||||
ended: function(){ return this.apiCall("ended"); },
|
||||
videoTracks: function(){ return this.apiCall("videoTracks"); },
|
||||
audioTracks: function(){ return this.apiCall("audioTracks"); },
|
||||
videoWidth: function(){ return this.apiCall("videoWidth"); },
|
||||
videoHeight: function(){ return this.apiCall("videoHeight"); },
|
||||
defaultPlaybackRate: function(){ return this.apiCall("defaultPlaybackRate"); },
|
||||
playbackRate: function(){ return this.apiCall("playbackRate"); },
|
||||
// mediaGroup: function(){ return this.apiCall("mediaGroup"); },
|
||||
// controller: function(){ return this.apiCall("controller"); },
|
||||
controls: function(){ return this.apiCall("controls"); },
|
||||
defaultMuted: function(){ return this.apiCall("defaultMuted"); }
|
||||
});
|
||||
|
||||
// RequestFullscreen API
|
||||
(function(){
|
||||
var requestFn,
|
||||
cancelFn,
|
||||
playerProto = _V_.Player.prototype;
|
||||
|
||||
// Current W3C Spec
|
||||
// http://dvcs.w3.org/hg/fullscreen/raw-file/tip/Overview.html#api
|
||||
// Mozilla Draft: https://wiki.mozilla.org/Gecko:FullScreenAPI#fullscreenchange_event
|
||||
if (document.cancelFullscreen !== undefined) {
|
||||
requestFn = "requestFullscreen";
|
||||
cancelFn = "exitFullscreen";
|
||||
eventName = "fullscreenchange";
|
||||
|
||||
// Webkit (Chrome/Safari) and Mozilla (Firefox) have working implementaitons
|
||||
// that use prefixes and vary slightly from the new W3C spec. Specifically, using 'exit' instead of 'cancel',
|
||||
// and lowercasing the 'S' in Fullscreen.
|
||||
// Other browsers don't have any hints of which version they might follow yet, so not going to try to predict by loopeing through all prefixes.
|
||||
} else {
|
||||
|
||||
_V_.each(["moz", "webkit"], function(prefix){
|
||||
|
||||
if (document[prefix + "CancelFullScreen"] !== undefined) {
|
||||
requestFn = prefix + "RequestFullScreen";
|
||||
cancelFn = prefix + "CancelFullScreen";
|
||||
eventName = prefix + "fullscreenchange";
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
if (requestFn) {
|
||||
_V_.support.requestFullScreen = {
|
||||
requestFn: requestFn,
|
||||
cancelFn: cancelFn,
|
||||
eventName: eventName
|
||||
};
|
||||
}
|
||||
|
||||
})();
|
||||
@@ -0,0 +1,4 @@
|
||||
_V_.addEvent(window, "load", function(){
|
||||
_V_.windowLoaded = true;
|
||||
});
|
||||
_V_.autoSetupTimeout();
|
||||
+451
@@ -0,0 +1,451 @@
|
||||
/* Playback Technology - Base class for playback technologies
|
||||
================================================================================ */
|
||||
_V_.PlaybackTech = _V_.Component.extend({
|
||||
init: function(player, options){
|
||||
// this._super(player, options);
|
||||
|
||||
// Make playback element clickable
|
||||
// _V_.addEvent(this.el, "click", _V_.proxy(this, _V_.PlayToggle.prototype.onClick));
|
||||
|
||||
// this.addEvent("click", this.proxy(this.onClick));
|
||||
|
||||
// player.triggerEvent("techready");
|
||||
},
|
||||
// destroy: function(){},
|
||||
// createElement: function(){},
|
||||
onClick: function(){
|
||||
if (this.player.options.controls) {
|
||||
_V_.PlayToggle.prototype.onClick.call(this);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Create placeholder methods for each that warn when a method isn't supported by the current playback technology
|
||||
_V_.apiMethods = "play,pause,paused,currentTime,setCurrentTime,duration,buffered,volume,setVolume,muted,setMuted,width,height,supportsFullScreen,enterFullScreen,src,load,currentSrc,preload,setPreload,autoplay,setAutoplay,loop,setLoop,error,networkState,readyState,seeking,initialTime,startOffsetTime,played,seekable,ended,videoTracks,audioTracks,videoWidth,videoHeight,textTracks,defaultPlaybackRate,playbackRate,mediaGroup,controller,controls,defaultMuted".split(",");
|
||||
_V_.each(_V_.apiMethods, function(methodName){
|
||||
_V_.PlaybackTech.prototype[methodName] = function(){
|
||||
throw new Error("The '"+method+"' method is not available on the playback technology's API");
|
||||
}
|
||||
});
|
||||
|
||||
/* HTML5 Playback Technology - Wrapper for HTML5 Media API
|
||||
================================================================================ */
|
||||
_V_.html5 = _V_.PlaybackTech.extend({
|
||||
|
||||
init: function(player, options, ready){
|
||||
this.player = player;
|
||||
this.el = this.createElement();
|
||||
this.ready(ready);
|
||||
|
||||
this.addEvent("click", this.proxy(this.onClick));
|
||||
|
||||
var source = options.source;
|
||||
|
||||
// If the element source is already set, we may have missed the loadstart event, and want to trigger it.
|
||||
// We don't want to set the source again and interrupt playback.
|
||||
if (source && this.el.currentSrc == source.src) {
|
||||
player.triggerEvent("loadstart");
|
||||
|
||||
// Otherwise set the source if one was provided.
|
||||
} else if (source) {
|
||||
this.el.src = source.src;
|
||||
}
|
||||
|
||||
// Chrome and Safari both have issues with autoplay.
|
||||
// In Safari (5.1.1), when we move the video element into the container div, autoplay doesn't work.
|
||||
// In Chrome (15), if you have autoplay + a poster + no controls, the video gets hidden (but audio plays)
|
||||
// This fixes both issues. Need to wait for API, so it updates displays correctly
|
||||
player.ready(function(){
|
||||
if (this.options.autoplay && this.paused()) {
|
||||
this.tag.poster = null; // Chrome Fix. Fixed in Chrome v16.
|
||||
this.play();
|
||||
}
|
||||
});
|
||||
|
||||
this.setupTriggers();
|
||||
|
||||
this.triggerReady();
|
||||
},
|
||||
|
||||
destroy: function(){
|
||||
this.player.tag = false;
|
||||
this.removeTriggers();
|
||||
this.el.parentNode.removeChild(this.el);
|
||||
},
|
||||
|
||||
createElement: function(){
|
||||
var html5 = _V_.html5,
|
||||
player = this.player,
|
||||
|
||||
// If possible, reuse original tag for HTML5 playback technology element
|
||||
el = player.tag,
|
||||
newEl;
|
||||
|
||||
// Check if this browser supports moving the element into the box.
|
||||
// On the iPhone video will break if you move the element,
|
||||
// So we have to create a brand new element.
|
||||
if (!el || this.support.movingElementInDOM === false) {
|
||||
|
||||
// If the original tag is still there, remove it.
|
||||
if (el) {
|
||||
player.el.removeChild(el);
|
||||
}
|
||||
|
||||
newEl = _V_.createElement("video", {
|
||||
id: el.id || player.el.id + "_html5_api",
|
||||
className: el.className || "vjs-tech"
|
||||
});
|
||||
|
||||
el = newEl;
|
||||
_V_.insertFirst(el, player.el);
|
||||
}
|
||||
|
||||
// Update tag settings, in case they were overridden
|
||||
_V_.each(["autoplay","preload","loop","muted"], function(attr){ // ,"poster"
|
||||
el[attr] = player.options[attr];
|
||||
}, this);
|
||||
|
||||
return el;
|
||||
},
|
||||
|
||||
// Make video events trigger player events
|
||||
// May seem verbose here, but makes other APIs possible.
|
||||
setupTriggers: function(){
|
||||
_V_.each.call(this, _V_.html5.events, function(type){
|
||||
_V_.addEvent(this.el, type, _V_.proxy(this.player, this.eventHandler));
|
||||
});
|
||||
},
|
||||
removeTriggers: function(){
|
||||
_V_.each.call(this, _V_.html5.events, function(type){
|
||||
_V_.removeEvent(this.el, type, _V_.proxy(this.player, this.eventHandler));
|
||||
});
|
||||
},
|
||||
eventHandler: function(e){
|
||||
e.stopPropagation();
|
||||
this.triggerEvent(e);
|
||||
},
|
||||
|
||||
play: function(){ this.el.play(); },
|
||||
pause: function(){ this.el.pause(); },
|
||||
paused: function(){ return this.el.paused; },
|
||||
|
||||
currentTime: function(){ return this.el.currentTime; },
|
||||
setCurrentTime: function(seconds){
|
||||
try {
|
||||
this.el.currentTime = seconds;
|
||||
} catch(e) {
|
||||
_V_.log(e, "Video isn't ready. (VideoJS)");
|
||||
// this.warning(VideoJS.warnings.videoNotReady);
|
||||
}
|
||||
},
|
||||
|
||||
duration: function(){ return this.el.duration || 0; },
|
||||
buffered: function(){ return this.el.buffered; },
|
||||
|
||||
volume: function(){ return this.el.volume; },
|
||||
setVolume: function(percentAsDecimal){ this.el.volume = percentAsDecimal; },
|
||||
muted: function(){ return this.el.muted; },
|
||||
setMuted: function(muted){ this.el.muted = muted },
|
||||
|
||||
width: function(){ return this.el.offsetWidth; },
|
||||
height: function(){ return this.el.offsetHeight; },
|
||||
|
||||
supportsFullScreen: function(){
|
||||
if (typeof this.el.webkitEnterFullScreen == 'function') {
|
||||
|
||||
// Seems to be broken in Chromium/Chrome && Safari in Leopard
|
||||
if (!navigator.userAgent.match("Chrome") && !navigator.userAgent.match("Mac OS X 10.5")) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
|
||||
enterFullScreen: function(){
|
||||
try {
|
||||
this.el.webkitEnterFullScreen();
|
||||
} catch (e) {
|
||||
if (e.code == 11) {
|
||||
// this.warning(VideoJS.warnings.videoNotReady);
|
||||
_V_.log("VideoJS: Video not ready.")
|
||||
}
|
||||
}
|
||||
},
|
||||
src: function(src){ this.el.src = src; },
|
||||
load: function(){ this.el.load(); },
|
||||
currentSrc: function(){ return this.el.currentSrc; },
|
||||
|
||||
preload: function(){ return this.el.preload; },
|
||||
setPreload: function(val){ this.el.preload = val; },
|
||||
autoplay: function(){ return this.el.autoplay; },
|
||||
setAutoplay: function(val){ this.el.autoplay = val; },
|
||||
loop: function(){ return this.el.loop; },
|
||||
setLoop: function(val){ this.el.loop = val; },
|
||||
|
||||
error: function(){ return this.el.error; },
|
||||
networkState: function(){ return this.el.networkState; },
|
||||
readyState: function(){ return this.el.readyState; },
|
||||
seeking: function(){ return this.el.seeking; },
|
||||
initialTime: function(){ return this.el.initialTime; },
|
||||
startOffsetTime: function(){ return this.el.startOffsetTime; },
|
||||
played: function(){ return this.el.played; },
|
||||
seekable: function(){ return this.el.seekable; },
|
||||
ended: function(){ return this.el.ended; },
|
||||
videoTracks: function(){ return this.el.videoTracks; },
|
||||
audioTracks: function(){ return this.el.audioTracks; },
|
||||
videoWidth: function(){ return this.el.videoWidth; },
|
||||
videoHeight: function(){ return this.el.videoHeight; },
|
||||
textTracks: function(){ return this.el.textTracks; },
|
||||
defaultPlaybackRate: function(){ return this.el.defaultPlaybackRate; },
|
||||
playbackRate: function(){ return this.el.playbackRate; },
|
||||
mediaGroup: function(){ return this.el.mediaGroup; },
|
||||
controller: function(){ return this.el.controller; },
|
||||
controls: function(){ return this.player.options.controls; },
|
||||
defaultMuted: function(){ return this.el.defaultMuted; }
|
||||
});
|
||||
|
||||
/* HTML5 Support Testing -------------------------------------------------------- */
|
||||
|
||||
_V_.html5.isSupported = function(){
|
||||
return !!document.createElement("video").canPlayType;
|
||||
};
|
||||
|
||||
_V_.html5.canPlaySource = function(srcObj){
|
||||
return !!document.createElement("video").canPlayType(srcObj.type);
|
||||
// TODO: Check Type
|
||||
// If no Type, check ext
|
||||
// Check Media Type
|
||||
};
|
||||
|
||||
// List of all HTML5 events (various uses).
|
||||
_V_.html5.events = "loadstart,suspend,abort,error,emptied,stalled,loadedmetadata,loadeddata,canplay,canplaythrough,playing,waiting,seeking,seeked,ended,durationchange,timeupdate,progress,play,pause,ratechange,volumechange".split(",");
|
||||
|
||||
/* HTML5 Device Fixes ---------------------------------------------------------- */
|
||||
|
||||
_V_.html5.prototype.support = {
|
||||
|
||||
// Support for tech specific full screen. (webkitEnterFullScreen, not requestFullscreen)
|
||||
// http://developer.apple.com/library/safari/#documentation/AudioVideo/Reference/HTMLVideoElementClassReference/HTMLVideoElement/HTMLVideoElement.html
|
||||
// Seems to be broken in Chromium/Chrome && Safari in Leopard
|
||||
fullscreen: (typeof _V_.testVid.webkitEnterFullScreen !== undefined) ? (!_V_.ua.match("Chrome") && !_V_.ua.match("Mac OS X 10.5") ? true : false) : false,
|
||||
|
||||
// In iOS, if you move a video element in the DOM, it breaks video playback.
|
||||
movingElementInDOM: !_V_.isIOS()
|
||||
|
||||
};
|
||||
|
||||
// Android
|
||||
if (_V_.isAndroid()) {
|
||||
|
||||
// Override Android 2.2 and less canPlayType method which is broken
|
||||
if (_V_.androidVersion() < 3) {
|
||||
document.createElement("video").constructor.prototype.canPlayType = function(type){
|
||||
return (type && type.toLowerCase().indexOf("video/mp4") != -1) ? "maybe" : "";
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* VideoJS-SWF - Custom Flash Player with HTML5-ish API
|
||||
================================================================================ */
|
||||
_V_.flash = _V_.PlaybackTech.extend({
|
||||
|
||||
init: function(player, options){
|
||||
this.player = player;
|
||||
|
||||
var source = options.source,
|
||||
parentEl = options.parentEl,
|
||||
placeHolder = this.el = _V_.createElement("div", { id: parentEl.id + "_temp_flash" }),
|
||||
objId = player.el.id+"_flash_api",
|
||||
playerOptions = player.options;
|
||||
|
||||
flashVars = _V_.merge({
|
||||
|
||||
// SWF Callback Functions
|
||||
readyFunction: "_V_.flash.onSWFReady",
|
||||
eventProxyFunction: "_V_.flash.onSWFEvent",
|
||||
errorEventProxyFunction: "_V_.flash.onSWFErrorEvent",
|
||||
|
||||
// Player Settings
|
||||
autoplay: playerOptions.autoplay,
|
||||
preload: playerOptions.preload,
|
||||
loop: playerOptions.loop,
|
||||
muted: playerOptions.muted
|
||||
|
||||
}, options.flashVars),
|
||||
|
||||
params = _V_.merge({
|
||||
allowScriptAccess: "always",
|
||||
wmode: "opaque",
|
||||
bgcolor: "#000000"
|
||||
}, options.params),
|
||||
|
||||
attributes = _V_.merge({
|
||||
id: objId,
|
||||
name: objId,
|
||||
'class': 'vjs-tech'
|
||||
}, options.attributes);
|
||||
|
||||
|
||||
// EDIT: Trying to just us a manual <img> for poster.
|
||||
// if (playerOptions.poster) {
|
||||
// flashVars.poster = playerOptions.poster;
|
||||
// }
|
||||
|
||||
// If source was supplied pass as a flash var.
|
||||
if (source) {
|
||||
flashVars.src = source.src;
|
||||
}
|
||||
|
||||
// Add to box.
|
||||
_V_.insertFirst(placeHolder, parentEl);
|
||||
|
||||
if (options.startTime) {
|
||||
this.ready(function(){
|
||||
this.load();
|
||||
this.play();
|
||||
this.currentTime(options.startTime);
|
||||
});
|
||||
}
|
||||
|
||||
swfobject.embedSWF(options.swf, placeHolder.id, "480", "270", "9.0.124", "", flashVars, params, attributes);
|
||||
},
|
||||
|
||||
destroy: function(){
|
||||
this.el.parentNode.removeChild(this.el);
|
||||
},
|
||||
|
||||
// setupTriggers: function(){}, // Using global onSWFEvent func to distribute events
|
||||
|
||||
play: function(){ this.el.vjs_play(); },
|
||||
pause: function(){ this.el.vjs_pause(); },
|
||||
src: function(src){
|
||||
this.el.vjs_src(src);
|
||||
|
||||
// Currently the SWF doesn't autoplay if you load a source later.
|
||||
// e.g. Load player w/ no source, wait 2s, set src.
|
||||
if (this.player.autoplay) {
|
||||
var tech = this;
|
||||
setTimeout(function(){ tech.play(); }, 0);
|
||||
}
|
||||
},
|
||||
load: function(){ this.el.vjs_load(); },
|
||||
poster: function(){ this.el.vjs_getProperty("poster"); },
|
||||
|
||||
buffered: function(){
|
||||
return _V_.createTimeRange(0, this.el.vjs_getProperty("buffered"));
|
||||
},
|
||||
|
||||
supportsFullScreen: function(){
|
||||
return false; // Flash does not allow fullscreen through javascript
|
||||
},
|
||||
enterFullScreen: function(){
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
// Create setters and getters for attributes
|
||||
(function(){
|
||||
var api = _V_.flash.prototype,
|
||||
readWrite = "preload,currentTime,defaultPlaybackRate,playbackRate,autoplay,loop,mediaGroup,controller,controls,volume,muted,defaultMuted".split(","),
|
||||
readOnly = "error,currentSrc,networkState,readyState,seeking,initialTime,duration,startOffsetTime,paused,played,seekable,ended,videoTracks,audioTracks,videoWidth,videoHeight,textTracks".split(","),
|
||||
callOnly = "load,play,pause".split(",");
|
||||
// Overridden: buffered
|
||||
|
||||
createSetter = function(attr){
|
||||
var attrUpper = attr.charAt(0).toUpperCase() + attr.slice(1);
|
||||
api["set"+attrUpper] = function(val){ return this.el.vjs_setProperty(attr, val); };
|
||||
},
|
||||
|
||||
createGetter = function(attr){
|
||||
api[attr] = function(){ return this.el.vjs_getProperty(attr); };
|
||||
};
|
||||
|
||||
// Create getter and setters for all read/write attributes
|
||||
_V_.each(readWrite, function(attr){
|
||||
createGetter(attr);
|
||||
createSetter(attr);
|
||||
});
|
||||
|
||||
// Create getters for read-only attributes
|
||||
_V_.each(readOnly, function(attr){
|
||||
createGetter(attr);
|
||||
});
|
||||
})();
|
||||
|
||||
/* Flash Support Testing -------------------------------------------------------- */
|
||||
|
||||
_V_.flash.isSupported = function(){
|
||||
return swfobject.hasFlashPlayerVersion("10");
|
||||
};
|
||||
|
||||
_V_.flash.canPlaySource = function(srcObj){
|
||||
if (srcObj.type in _V_.flash.prototype.support.formats) { return "maybe"; }
|
||||
};
|
||||
|
||||
_V_.flash.prototype.support = {
|
||||
formats: {
|
||||
"video/flv": "FLV",
|
||||
"video/x-flv": "FLV",
|
||||
"video/mp4": "MP4",
|
||||
"video/m4v": "MP4"
|
||||
},
|
||||
|
||||
// Optional events that we can manually mimic with timers
|
||||
progressEvent: false,
|
||||
timeupdateEvent: false,
|
||||
|
||||
// Resizing plugins using request fullscreen reloads the plugin
|
||||
fullscreenResize: false,
|
||||
|
||||
// Resizing plugins in Firefox always reloads the plugin (e.g. full window mode)
|
||||
parentResize: !(_V_.ua.match("Firefox"))
|
||||
};
|
||||
|
||||
_V_.flash.onSWFReady = function(currSwf){
|
||||
|
||||
var el = _V_.el(currSwf);
|
||||
|
||||
// Get player from box
|
||||
// On firefox reloads, el might already have a player
|
||||
var player = el.player || el.parentNode.player,
|
||||
tech = player.tech;
|
||||
|
||||
// Reference player on tech element
|
||||
el.player = player;
|
||||
|
||||
// Update reference to playback technology element
|
||||
tech.el = el;
|
||||
|
||||
// Now that the element is ready, make a click on the swf play the video
|
||||
tech.addEvent("click", tech.onClick);
|
||||
|
||||
_V_.flash.checkReady(tech);
|
||||
};
|
||||
|
||||
// The SWF isn't alwasy ready when it says it is. Sometimes the API functions still need to be added to the object.
|
||||
// If it's not ready, we set a timeout to check again shortly.
|
||||
_V_.flash.checkReady = function(tech){
|
||||
if (tech.el.vjs_getProperty) {
|
||||
tech.triggerReady();
|
||||
} else {
|
||||
setTimeout(function(){
|
||||
_V_.flash.checkReady(tech);
|
||||
}, 50);
|
||||
}
|
||||
};
|
||||
|
||||
_V_.flash.onSWFEvent = function(swfID, eventName, other){
|
||||
try {
|
||||
var player = _V_.el(swfID).player;
|
||||
if (player && player.techName == "flash") {
|
||||
player.triggerEvent(eventName);
|
||||
}
|
||||
} catch(err) {
|
||||
_V_.log(err);
|
||||
}
|
||||
};
|
||||
|
||||
_V_.flash.onSWFErrorEvent = function(swfID, eventName){
|
||||
_V_.log("Flash Error", eventName);
|
||||
};
|
||||
+132
@@ -0,0 +1,132 @@
|
||||
_V_.Track = function(attributes, player){
|
||||
// Store reference to the parent player
|
||||
this.player = player;
|
||||
|
||||
this.src = attributes.src;
|
||||
this.kind = attributes.kind;
|
||||
this.srclang = attributes.srclang;
|
||||
this.label = attributes.label;
|
||||
this["default"] = attributes["default"]; // 'default' is reserved-ish
|
||||
this.title = attributes.title;
|
||||
|
||||
this.cues = [];
|
||||
this.currentCue = false;
|
||||
this.lastCueIndex = 0;
|
||||
|
||||
// Update current cue on timeupdate
|
||||
player.addEvent("timeupdate", _V_.proxy(this, this.update));
|
||||
|
||||
// Reset cue time on media end
|
||||
player.addEvent("ended", _V_.proxy(this, function() { this.lastCueIndex = 0; }));
|
||||
|
||||
// Load Track File
|
||||
_V_.get(attributes.src, _V_.proxy(this, this.parseCues));
|
||||
};
|
||||
|
||||
_V_.Track.prototype = {
|
||||
|
||||
parseCues: function(srcContent) {
|
||||
var cue, time, text,
|
||||
lines = srcContent.split("\n"),
|
||||
line = "";
|
||||
|
||||
for (var i=0; i<lines.length; i++) {
|
||||
line = _V_.trim(lines[i]); // Trim whitespace and linebreaks
|
||||
if (line) { // Loop until a line with content
|
||||
|
||||
// First line - Number
|
||||
cue = {
|
||||
id: line, // Cue Number
|
||||
index: this.cues.length // Position in Array
|
||||
};
|
||||
|
||||
// Second line - Time
|
||||
line = _V_.trim(lines[++i]);
|
||||
time = line.split(" --> ");
|
||||
cue.startTime = this.parseCueTime(time[0]);
|
||||
cue.endTime = this.parseCueTime(time[1]);
|
||||
|
||||
// Additional lines - Cue Text
|
||||
text = [];
|
||||
for (var j=i; j<lines.length; j++) { // Loop until a blank line or end of lines
|
||||
line = _V_.trim(lines[++i]);
|
||||
if (!line) { break; }
|
||||
text.push(line);
|
||||
}
|
||||
cue.text = text.join('<br/>');
|
||||
|
||||
// Add this cue
|
||||
this.cues.push(cue);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
parseCueTime: function(timeText) {
|
||||
var parts = timeText.split(':'),
|
||||
time = 0;
|
||||
// hours => seconds
|
||||
time += parseFloat(parts[0])*60*60;
|
||||
// minutes => seconds
|
||||
time += parseFloat(parts[1])*60;
|
||||
// get seconds
|
||||
var seconds = parts[2].split(/\.|,/); // Either . or ,
|
||||
time += parseFloat(seconds[0]);
|
||||
// add miliseconds
|
||||
ms = parseFloat(seconds[1]);
|
||||
if (ms) { time += ms/1000; }
|
||||
return time;
|
||||
},
|
||||
|
||||
update: function(){
|
||||
// Assuming all cues are in order by time, and do not overlap
|
||||
if (this.cues && this.cues.length > 0) {
|
||||
var time = this.player.currentTime();
|
||||
// If current cue should stay showing, don't do anything. Otherwise, find new cue.
|
||||
if (!this.currentCue || this.currentCue.startTime >= time || this.currentCue.endTime < time) {
|
||||
var newSubIndex = false,
|
||||
// Loop in reverse if lastCue is after current time (optimization)
|
||||
// Meaning the user is scrubbing in reverse or rewinding
|
||||
reverse = (this.cues[this.lastCueIndex].startTime > time),
|
||||
// If reverse, step back 1 becase we know it's not the lastCue
|
||||
i = this.lastCueIndex - (reverse ? 1 : 0);
|
||||
while (true) { // Loop until broken
|
||||
if (reverse) { // Looping in reverse
|
||||
// Stop if no more, or this cue ends before the current time (no earlier cues should apply)
|
||||
if (i < 0 || this.cues[i].endTime < time) { break; }
|
||||
// End is greater than time, so if start is less, show this cue
|
||||
if (this.cues[i].startTime < time) {
|
||||
newSubIndex = i;
|
||||
break;
|
||||
}
|
||||
i--;
|
||||
} else { // Looping forward
|
||||
// Stop if no more, or this cue starts after time (no later cues should apply)
|
||||
if (i >= this.cues.length || this.cues[i].startTime > time) { break; }
|
||||
// Start is less than time, so if end is later, show this cue
|
||||
if (this.cues[i].endTime > time) {
|
||||
newSubIndex = i;
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
// Set or clear current cue
|
||||
if (newSubIndex !== false) {
|
||||
this.currentCue = this.cues[newSubIndex];
|
||||
this.lastCueIndex = newSubIndex;
|
||||
this.updatePlayer(this.currentCue.text);
|
||||
} else if (this.currentCue) {
|
||||
this.currentCue = false;
|
||||
this.updatePlayer("");
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
// Update the stored value for the current track kind
|
||||
// and trigger an event to update all text track displays.
|
||||
updatePlayer: function(text){
|
||||
this.player.textTrackValue(this.kind, text);
|
||||
}
|
||||
};
|
||||
Diff do arquivo suprimido porque uma ou mais linhas são muito longas
@@ -0,0 +1,20 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>VideoJS | HTML5 Video Player</title>
|
||||
|
||||
<link href="video-js.css" rel="stylesheet" type="text/css">
|
||||
|
||||
<!-- video.js must be in the <head> for older IEs to work. -->
|
||||
<script src="video.js"></script>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<video id="example_video_1" class="video-js vjs-default-skin" controls width="640" height="264" data-setup='{"techOrder":["youtube","html5"]}'>
|
||||
<source src="http://www.youtube.com/watch?v=YjaZNYSt7o0" type='video/youtube'>
|
||||
</video>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -0,0 +1,147 @@
|
||||
// Flowplayer API Connector
|
||||
VideoJS.tech.youtube = {
|
||||
name: "YouTube",
|
||||
|
||||
supported: function(){
|
||||
// Flash Player 8 or higher
|
||||
return true;
|
||||
},
|
||||
canPlaySource: function(sourceObj){
|
||||
return sourceObj.type == "video/youtube";
|
||||
},
|
||||
supports: {
|
||||
format: {},
|
||||
event: {
|
||||
progress: false,
|
||||
timeupdate: false
|
||||
}
|
||||
},
|
||||
init: function(sourceObj){
|
||||
var player = this,
|
||||
placeHolder = _V_.createElement("div", { id: player.box.id + "_temp_ytswf" }),
|
||||
objId = player.box.id+"_youtube_api";
|
||||
|
||||
flashvars = {
|
||||
},
|
||||
|
||||
params = {
|
||||
allowScriptAccess: "always",
|
||||
wmode: "opaque",
|
||||
bgcolor: "#000000"
|
||||
},
|
||||
|
||||
attributes = {
|
||||
id: objId,
|
||||
name: objId,
|
||||
'class': 'vjs-tech'
|
||||
};
|
||||
|
||||
this.addEvent("techready", function(){
|
||||
var url = sourceObj.src;
|
||||
|
||||
if (url.indexOf("http://") == 0) {
|
||||
// Get Youtube ID from URL
|
||||
url = url.match(/v=([^&]+)/)[1];
|
||||
}
|
||||
this.tels.youtube.cueVideoById(url);
|
||||
});
|
||||
|
||||
player.box.appendChild(placeHolder);
|
||||
|
||||
swfobject.embedSWF("http://www.youtube.com/apiplayer?" +
|
||||
"version=3&enablejsapi=1&playerapiid=" + objId,
|
||||
placeHolder.id, "480", "295", "9", null, null, params, attributes);
|
||||
},
|
||||
stateChange: function(id, state){
|
||||
var player = _V_(id);
|
||||
|
||||
if (state == 0) {
|
||||
player.triggerEvent("ended");
|
||||
} else if (state == 1) {
|
||||
player.triggerEvent("play");
|
||||
player.triggerEvent("playing");
|
||||
} else if (state == 2) {
|
||||
player.triggerEvent("pause");
|
||||
}
|
||||
},
|
||||
|
||||
error: function(id, errorCode){
|
||||
_V_.log(id, errorCode);
|
||||
},
|
||||
|
||||
api: {
|
||||
setupTriggers: function(){
|
||||
this.tels.youtube.addEventListener("onStateChange",
|
||||
"(function(state){ _V_.tech.youtube.stateChange('"+this.id+"',state); })");
|
||||
|
||||
this.tels.youtube.addEventListener("onError",
|
||||
"(function(errorCode){ _V_.tech.youtube.error('"+this.id+"',errorCode); })");
|
||||
|
||||
},
|
||||
|
||||
play: function(){ this.tels.youtube.playVideo(); },
|
||||
pause: function(){ this.tels.youtube.pauseVideo(); },
|
||||
paused: function(){
|
||||
return this.tels.youtube.getPlayerState() !== 1; // More accurate than isPaused
|
||||
},
|
||||
|
||||
currentTime: function(){ return this.tels.youtube.getCurrentTime(); },
|
||||
setCurrentTime: function(seconds){
|
||||
// False blocks seek-ahead.
|
||||
this.tels.youtube.seekTo(seconds, true);
|
||||
},
|
||||
|
||||
duration: function(){
|
||||
return this.tels.youtube.getDuration();
|
||||
},
|
||||
|
||||
buffered: function(){
|
||||
var percent = this.tels.youtube.getVideoBytesLoaded() / this.tels.youtube.getVideoBytesTotal(),
|
||||
seconds = this.duration() * percent;
|
||||
return _V_.createTimeRange(0, seconds);
|
||||
},
|
||||
|
||||
volume: function(){ return _V_.round(this.tels.youtube.getVolume() / 100, 2); },
|
||||
setVolume: function(percentAsDecimal){
|
||||
this.tels.youtube.setVolume(parseInt(percentAsDecimal * 100));
|
||||
|
||||
// Youtube Doesn't support VolumeChange Events
|
||||
this.triggerEvent("volumechange");
|
||||
},
|
||||
muted: function(){ return this.tels.youtube.isMuted(); },
|
||||
setMuted: function(bool){
|
||||
if (bool) {
|
||||
this.tels.youtube.mute()
|
||||
} else {
|
||||
this.tels.youtube.unMute()
|
||||
}
|
||||
},
|
||||
|
||||
supportsFullScreen: function(){
|
||||
return false; // Flash does not allow fullscreen through javascript
|
||||
// Maybe at click listener, and say "click screen".
|
||||
},
|
||||
enterFullScreen: function(){ this.tels.flowplayer.api.toggleFullscreen(); },
|
||||
|
||||
src: function(src){
|
||||
this.tels.youtube.cueVideoById(src);
|
||||
},
|
||||
load: function(){
|
||||
// Youtube will autoload?
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// YouTube Defined Player Ready Callback
|
||||
window.onYouTubePlayerReady = function(playerId) {
|
||||
var el = _V_.el(playerId),
|
||||
player = el.parentNode.player; // Get player from box
|
||||
|
||||
el.player = player;
|
||||
|
||||
// Update reference to playback technology element
|
||||
player.tels.youtube = el;
|
||||
|
||||
player.triggerEvent("techready");
|
||||
}
|
||||
|
||||
Arquivo executável
+7
@@ -0,0 +1,7 @@
|
||||
.project
|
||||
*~
|
||||
*.diff
|
||||
*.patch
|
||||
.DS_Store
|
||||
.settings
|
||||
|
||||
Arquivo executável
+27
@@ -0,0 +1,27 @@
|
||||
[QUnit](http://docs.jquery.com/QUnit) - A JavaScript Unit Testing framework.
|
||||
================================
|
||||
|
||||
QUnit is a powerful, easy-to-use, JavaScript test suite. It's used by the jQuery
|
||||
project to test its code and plugins but is capable of testing any generic
|
||||
JavaScript code (and even capable of testing JavaScript code on the server-side).
|
||||
|
||||
QUnit is especially useful for regression testing: Whenever a bug is reported,
|
||||
write a test that asserts the existence of that particular bug. Then fix it and
|
||||
commit both. Every time you work on the code again, run the tests. If the bug
|
||||
comes up again - a regression - you'll spot it immediately and know how to fix
|
||||
it, because you know what code you just changed.
|
||||
|
||||
Having good unit test coverage makes safe refactoring easy and cheap. You can
|
||||
run the tests after each small refactoring step and always know what change
|
||||
broke something.
|
||||
|
||||
QUnit is similar to other unit testing frameworks like JUnit, but makes use of
|
||||
the features JavaScript provides and helps with testing code in the browser, eg.
|
||||
with it's stop/start facilities for testing asynchronous code.
|
||||
|
||||
If you are interested in helping developing QUnit, you are in the right place.
|
||||
For related discussions, visit the
|
||||
[QUnit and Testing forum](http://forum.jquery.com/qunit-and-testing).
|
||||
|
||||
Planning for a qunitjs.com site and other testing tools related work now happens
|
||||
on the [jQuery Testing Team planning wiki](http://jquerytesting.pbworks.com/w/page/41556026/FrontPage).
|
||||
Arquivo executável
+16
@@ -0,0 +1,16 @@
|
||||
Canvas - A QUnit Addon For Testing Canvas Rendering
|
||||
================================
|
||||
|
||||
This addon for QUnit adds a pixelEqual method that allows you to assert
|
||||
individual pixel values in a given canvas.
|
||||
|
||||
Usage:
|
||||
|
||||
pixelEqual(canvas, x, y, r, g, b, a, message)
|
||||
|
||||
Where:
|
||||
|
||||
* canvas: Reference to a canvas element
|
||||
* x, y: Coordinates of the pixel to test
|
||||
* r, g, b, a: The color and opacity value of the pixel that you except
|
||||
* message: Optional message, same as for other assertions
|
||||
Arquivo executável
+76
@@ -0,0 +1,76 @@
|
||||
test("Canvas pixels", function () {
|
||||
var canvas = document.getElementById('qunit-canvas'), context;
|
||||
try {
|
||||
context = canvas.getContext('2d');
|
||||
} catch(e) {
|
||||
// propably no canvas support, just exit
|
||||
return;
|
||||
}
|
||||
context.fillStyle = 'rgba(0, 0, 0, 0)';
|
||||
context.fillRect(0, 0, 5, 5);
|
||||
QUnit.pixelEqual(canvas, 0, 0, 0, 0, 0, 0);
|
||||
context.clearRect(0,0,5,5);
|
||||
context.fillStyle = 'rgba(255, 0, 0, 0)';
|
||||
context.fillRect(0, 0, 5, 5);
|
||||
QUnit.pixelEqual(canvas, 0, 0, 0, 0, 0, 0);
|
||||
context.clearRect(0,0,5,5);
|
||||
context.fillStyle = 'rgba(0, 255, 0, 0)';
|
||||
context.fillRect(0, 0, 5, 5);
|
||||
QUnit.pixelEqual(canvas, 0, 0, 0, 0, 0, 0);
|
||||
context.clearRect(0,0,5,5);
|
||||
context.fillStyle = 'rgba(0, 0, 255, 0)';
|
||||
context.fillRect(0, 0, 5, 5);
|
||||
QUnit.pixelEqual(canvas, 0, 0, 0, 0, 0, 0);
|
||||
context.clearRect(0,0,5,5);
|
||||
|
||||
context.fillStyle = 'rgba(0, 0, 0, 0.5)';
|
||||
context.fillRect(0, 0, 5, 5);
|
||||
QUnit.pixelEqual(canvas, 0, 0, 0, 0, 0, 127);
|
||||
context.clearRect(0,0,5,5);
|
||||
context.fillStyle = 'rgba(255, 0, 0, 0.5)';
|
||||
context.fillRect(0, 0, 5, 5);
|
||||
QUnit.pixelEqual(canvas, 0, 0, 255, 0, 0, 127);
|
||||
context.clearRect(0,0,5,5);
|
||||
context.fillStyle = 'rgba(0, 255, 0, 0.5)';
|
||||
context.fillRect(0, 0, 5, 5);
|
||||
QUnit.pixelEqual(canvas, 0, 0, 0, 255, 0, 127);
|
||||
context.clearRect(0,0,5,5);
|
||||
context.fillStyle = 'rgba(0, 0, 255, 0.5)';
|
||||
context.fillRect(0, 0, 5, 5);
|
||||
QUnit.pixelEqual(canvas, 0, 0, 0, 0, 255, 127);
|
||||
context.clearRect(0,0,5,5);
|
||||
|
||||
context.fillStyle = 'rgba(0, 0, 0, 0.5)';
|
||||
context.fillRect(0, 0, 5, 5);
|
||||
QUnit.pixelEqual(canvas, 2, 2, 0, 0, 0, 127);
|
||||
context.clearRect(0,0,5,5);
|
||||
context.fillStyle = 'rgba(255, 0, 0, 0.5)';
|
||||
context.fillRect(0, 0, 5, 5);
|
||||
QUnit.pixelEqual(canvas, 2, 2, 255, 0, 0, 127);
|
||||
context.clearRect(0,0,5,5);
|
||||
context.fillStyle = 'rgba(0, 255, 0, 0.5)';
|
||||
context.fillRect(0, 0, 5, 5);
|
||||
QUnit.pixelEqual(canvas, 2, 2, 0, 255, 0, 127);
|
||||
context.clearRect(0,0,5,5);
|
||||
context.fillStyle = 'rgba(0, 0, 255, 0.5)';
|
||||
context.fillRect(0, 0, 5, 5);
|
||||
QUnit.pixelEqual(canvas, 2, 2, 0, 0, 255, 127);
|
||||
context.clearRect(0,0,5,5);
|
||||
|
||||
context.fillStyle = 'rgba(0, 0, 0, 1)';
|
||||
context.fillRect(0, 0, 5, 5);
|
||||
QUnit.pixelEqual(canvas, 4, 4, 0, 0, 0, 255);
|
||||
context.clearRect(0,0,5,5);
|
||||
context.fillStyle = 'rgba(255, 0, 0, 1)';
|
||||
context.fillRect(0, 0, 5, 5);
|
||||
QUnit.pixelEqual(canvas, 4, 4, 255, 0, 0, 255);
|
||||
context.clearRect(0,0,5,5);
|
||||
context.fillStyle = 'rgba(0, 255, 0, 1)';
|
||||
context.fillRect(0, 0, 5, 5);
|
||||
QUnit.pixelEqual(canvas, 4, 4, 0, 255, 0, 255);
|
||||
context.clearRect(0,0,5,5);
|
||||
context.fillStyle = 'rgba(0, 0, 255, 1)';
|
||||
context.fillRect(0, 0, 5, 5);
|
||||
QUnit.pixelEqual(canvas, 4, 4, 0, 0, 255, 255);
|
||||
context.clearRect(0,0,5,5);
|
||||
});
|
||||
Arquivo executável
+19
@@ -0,0 +1,19 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<title>QUnit Test Suite - Canvas Addon</title>
|
||||
<link rel="stylesheet" href="../../qunit/qunit.css" type="text/css" media="screen">
|
||||
<script type="text/javascript" src="../../qunit/qunit.js"></script>
|
||||
<script type="text/javascript" src="qunit-canvas.js"></script>
|
||||
<script type="text/javascript" src="canvas-test.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1 id="qunit-header">QUnit Test Suite - Canvas Addon</h1>
|
||||
<h2 id="qunit-banner"></h2>
|
||||
<div id="qunit-testrunner-toolbar"></div>
|
||||
<h2 id="qunit-userAgent"></h2>
|
||||
<ol id="qunit-tests"></ol>
|
||||
<canvas id="qunit-canvas" width="5" height="5"></canvas>
|
||||
</body>
|
||||
</html>
|
||||
Arquivo executável
+6
@@ -0,0 +1,6 @@
|
||||
QUnit.extend( QUnit, {
|
||||
pixelEqual: function(canvas, x, y, r, g, b, a, message) {
|
||||
var actual = Array.prototype.slice.apply(canvas.getContext('2d').getImageData(x, y, 1, 1).data), expected = [r, g, b, a];
|
||||
QUnit.push(QUnit.equiv(actual, expected), actual, expected, message);
|
||||
}
|
||||
});
|
||||
Arquivo executável
+17
@@ -0,0 +1,17 @@
|
||||
Close-Enough - A QUnit Addon For Number Approximations
|
||||
================================
|
||||
|
||||
This addon for QUnit adds close and notClose assertion methods, to test that
|
||||
numbers are close enough (or different enough) from an expected number, with
|
||||
a specified accuracy.
|
||||
|
||||
Usage:
|
||||
|
||||
close(actual, expected, maxDifference, message)
|
||||
notClose(actual, expected, minDifference, message)
|
||||
|
||||
Where:
|
||||
|
||||
* maxDifference: the maximum inclusive difference allowed between the actual and expected numbers
|
||||
* minDifference: the minimum exclusive difference allowed between the actual and expected numbers
|
||||
* actual, expected, message: The usual
|
||||
Arquivo executável
+37
@@ -0,0 +1,37 @@
|
||||
test("Close Numbers", function () {
|
||||
|
||||
QUnit.close(7, 7, 0);
|
||||
QUnit.close(7, 7.1, 0.1);
|
||||
QUnit.close(7, 7.1, 0.2);
|
||||
|
||||
QUnit.close(3.141, Math.PI, 0.001);
|
||||
QUnit.close(3.1, Math.PI, 0.1);
|
||||
|
||||
var halfPi = Math.PI / 2;
|
||||
QUnit.close(halfPi, 1.57, 0.001);
|
||||
|
||||
var sqrt2 = Math.sqrt(2);
|
||||
QUnit.close(sqrt2, 1.4142, 0.0001);
|
||||
|
||||
QUnit.close(Infinity, Infinity, 1);
|
||||
|
||||
});
|
||||
|
||||
test("Distant Numbers", function () {
|
||||
|
||||
QUnit.notClose(6, 7, 0);
|
||||
QUnit.notClose(7, 7.2, 0.1);
|
||||
QUnit.notClose(7, 7.2, 0.19999999999);
|
||||
|
||||
QUnit.notClose(3.141, Math.PI, 0.0001);
|
||||
QUnit.notClose(3.1, Math.PI, 0.001);
|
||||
|
||||
var halfPi = Math.PI / 2;
|
||||
QUnit.notClose(halfPi, 1.57, 0.0001);
|
||||
|
||||
var sqrt2 = Math.sqrt(2);
|
||||
QUnit.notClose(sqrt2, 1.4142, 0.00001);
|
||||
|
||||
QUnit.notClose(Infinity, -Infinity, 5);
|
||||
|
||||
});
|
||||
Arquivo executável
+18
@@ -0,0 +1,18 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<title>QUnit Test Suite - Close Enough Addon</title>
|
||||
<link rel="stylesheet" href="../../qunit/qunit.css" type="text/css" media="screen">
|
||||
<script type="text/javascript" src="../../qunit/qunit.js"></script>
|
||||
<script type="text/javascript" src="qunit-close-enough.js"></script>
|
||||
<script type="text/javascript" src="close-enough-test.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1 id="qunit-header">QUnit Test Suite - Close Enough</h1>
|
||||
<h2 id="qunit-banner"></h2>
|
||||
<div id="qunit-testrunner-toolbar"></div>
|
||||
<h2 id="qunit-userAgent"></h2>
|
||||
<ol id="qunit-tests"></ol>
|
||||
</body>
|
||||
</html>
|
||||
Arquivo executável
+32
@@ -0,0 +1,32 @@
|
||||
QUnit.extend( QUnit, {
|
||||
/**
|
||||
* Checks that the first two arguments are equal, or are numbers close enough to be considered equal
|
||||
* based on a specified maximum allowable difference.
|
||||
*
|
||||
* @example close(3.141, Math.PI, 0.001);
|
||||
*
|
||||
* @param Number actual
|
||||
* @param Number expected
|
||||
* @param Number maxDifference (the maximum inclusive difference allowed between the actual and expected numbers)
|
||||
* @param String message (optional)
|
||||
*/
|
||||
close: function(actual, expected, maxDifference, message) {
|
||||
var passes = (actual === expected) || Math.abs(actual - expected) <= maxDifference;
|
||||
QUnit.push(passes, actual, expected, message);
|
||||
},
|
||||
|
||||
/**
|
||||
* Checks that the first two arguments are numbers with differences greater than the specified
|
||||
* minimum difference.
|
||||
*
|
||||
* @example notClose(3.1, Math.PI, 0.001);
|
||||
*
|
||||
* @param Number actual
|
||||
* @param Number expected
|
||||
* @param Number minDifference (the minimum exclusive difference allowed between the actual and expected numbers)
|
||||
* @param String message (optional)
|
||||
*/
|
||||
notClose: function(actual, expected, minDifference, message) {
|
||||
QUnit.push(Math.abs(actual - expected) > minDifference, actual, expected, message);
|
||||
}
|
||||
});
|
||||
Arquivo executável
+7
@@ -0,0 +1,7 @@
|
||||
Composite - A QUnit Addon For Running Multiple Test Files
|
||||
================================
|
||||
|
||||
Composite is a QUnit addon that, when handed an array of files, will
|
||||
open each of those files inside of an iframe, run the tests and
|
||||
display the results as a single suite of QUnit tests.
|
||||
|
||||
Arquivo executável
+33
@@ -0,0 +1,33 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<title>QUnit SubsuiteRunner Test Suite</title>
|
||||
|
||||
<link rel="stylesheet" href="../../qunit/qunit.css" type="text/css" media="screen">
|
||||
<link rel="stylesheet" href="qunit-composite.css">
|
||||
<script src="../../qunit/qunit.js"></script>
|
||||
<script src="qunit-composite.js"></script>
|
||||
|
||||
<script>
|
||||
QUnit.testSuites([
|
||||
"../../test/index.html",
|
||||
"../canvas/canvas.html",
|
||||
"../close-enough/close-enough.html",
|
||||
"../step/step.html",
|
||||
"composite-test.html"
|
||||
]);
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1 id="qunit-header">QUnit SubsuiteRunner Test Suite</h1>
|
||||
<h2 id="qunit-banner"></h2>
|
||||
<div id="qunit-testrunner-toolbar"></div>
|
||||
<h2 id="qunit-userAgent"></h2>
|
||||
<ol id="qunit-tests"></ol>
|
||||
<div id="qunit-fixture">
|
||||
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
Arquivo executável
+20
@@ -0,0 +1,20 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<title>QUnit Core Test Suite</title>
|
||||
<link rel="stylesheet" href="../../qunit/qunit.css" type="text/css" media="screen">
|
||||
<script src="../../qunit/qunit.js"></script>
|
||||
|
||||
<script src="qunit-composite.js"></script>
|
||||
<script src="composite-test.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1 id="qunit-header">QUnit Core Test Suite</h1>
|
||||
<h2 id="qunit-banner"></h2>
|
||||
<div id="qunit-testrunner-toolbar"></div>
|
||||
<h2 id="qunit-userAgent"></h2>
|
||||
<ol id="qunit-tests"></ol>
|
||||
<div id="qunit-fixture">test markup</div>
|
||||
</body>
|
||||
</html>
|
||||
Arquivo executável
+159
@@ -0,0 +1,159 @@
|
||||
module( "testSuites tests", (function(){
|
||||
var asyncTest = QUnit.asyncTest,
|
||||
runSuite = QUnit.runSuite;
|
||||
|
||||
return {
|
||||
setup: function(){
|
||||
//proxy asyncTest and runSuite
|
||||
QUnit.asyncTest = window.asyncTest = function( name, callback ){
|
||||
ok( true, "asyncTestCalled for each suite" );
|
||||
callback(); //don't acutally create tests, just call callback
|
||||
};
|
||||
QUnit.runSuite = window.runSuite = function(){
|
||||
ok( true, "runSuite called for each suite" );
|
||||
};
|
||||
//ensure that subsuite's done doesn't run
|
||||
this.oldDone = QUnit.done;
|
||||
},
|
||||
teardown: function(){
|
||||
//restore
|
||||
QUnit.asyncTest = window.asyncTest = asyncTest;
|
||||
QUnit.runSuite = window.runSuite = runSuite;
|
||||
QUnit.done = this.oldDone;
|
||||
}
|
||||
};
|
||||
})());
|
||||
|
||||
test( "proper number of asyncTest and runSuite calls", function(){
|
||||
expect( 6 );
|
||||
QUnit.testSuites( ["one.html", "two.html", "three.html"] );
|
||||
});
|
||||
|
||||
test( "done callback changed", function(){
|
||||
QUnit.testSuites( ["dummy.html"] );
|
||||
notEqual( this.oldDone, QUnit.done, "done callback should be set" );
|
||||
});
|
||||
|
||||
module( "testStart tests", (function(){
|
||||
var id = QUnit.id;
|
||||
return {
|
||||
setup: function(){
|
||||
//proxy id
|
||||
var fakeElem = this.fakeElem = document.createElement( "div" );
|
||||
|
||||
QUnit.id = function(){
|
||||
return fakeElem;
|
||||
}
|
||||
},
|
||||
teardown: function(){
|
||||
QUnit.id = id;
|
||||
}
|
||||
};
|
||||
})());
|
||||
|
||||
test( "running message printed", function(){
|
||||
var hello = "hello world",
|
||||
expected = "Running " + hello + "...<br> ";
|
||||
QUnit.testStart( {name: hello} );
|
||||
equal( this.fakeElem.innerHTML, expected, "innerHTML was set correctly by testStart" );
|
||||
});
|
||||
|
||||
module( "testDone tests", (function(){
|
||||
var id = QUnit.id;
|
||||
return {
|
||||
setup: function(){
|
||||
//proxy id
|
||||
var fakeElem = this.fakeElem = document.createElement( "div" );
|
||||
fakeElem.appendChild( document.createElement( "ol" ) );
|
||||
fakeElem.appendChild( document.createElement( "ol" ) );
|
||||
QUnit.id = function(){
|
||||
return fakeElem;
|
||||
}
|
||||
},
|
||||
teardown: function(){
|
||||
QUnit.id = id;
|
||||
}
|
||||
};
|
||||
})());
|
||||
|
||||
test( "test expansions are hidden", function(){
|
||||
QUnit.testDone();
|
||||
equal( this.fakeElem.children[0].style.display, "none", "first ol display is none" );
|
||||
equal( this.fakeElem.children[1].style.display, "none", "second ol display is none" );
|
||||
});
|
||||
|
||||
test( "non-ol elements aren't hidden", function(){
|
||||
this.fakeElem.appendChild( document.createElement( "span" ) );
|
||||
|
||||
QUnit.testDone();
|
||||
notEqual( this.fakeElem.children[2].style.display, "none", "first ol display is none" );
|
||||
});
|
||||
|
||||
module( "runSuite tests", (function(){
|
||||
var getElementsByTagName = document.getElementsByTagName,
|
||||
createElement = document.createElement,
|
||||
runSuite = QUnit.runSuite;
|
||||
|
||||
return {
|
||||
setup: function(){
|
||||
//proxy getElementsByTagName and createElement
|
||||
var setAttributeCall = this.setAttributeCall = {},
|
||||
appendChildCall = this.appendChildCall = {called: 0},
|
||||
iframeLoad = this.iframeLoad = {},
|
||||
iframeQUnitObject = this.iframeQUnitObject = {},
|
||||
fakeElement = {
|
||||
appendChild: function(){appendChildCall.called++},
|
||||
setAttribute: function(){setAttributeCall.args = arguments},
|
||||
addEventListener: function( type, callback ){iframeLoad.callback = callback;},
|
||||
contentWindow: {QUnit: iframeQUnitObject},
|
||||
className: "",
|
||||
};
|
||||
|
||||
document.getElementsByTagName = function(){
|
||||
return [fakeElement];
|
||||
};
|
||||
document.createElement = function(){
|
||||
return fakeElement;
|
||||
}
|
||||
|
||||
},
|
||||
teardown: function(){
|
||||
document.getElementsByTagName = getElementsByTagName;
|
||||
document.createElement = createElement;
|
||||
//must restore even though we didn't proxy; the runner overwrites upon first call
|
||||
QUnit.runSuite = runSuite;
|
||||
}
|
||||
};
|
||||
})());
|
||||
|
||||
test( "runSuite different after first run", function(){
|
||||
var before = QUnit.runSuite,
|
||||
after;
|
||||
QUnit.runSuite();
|
||||
after = QUnit.runSuite;
|
||||
notEqual( before, after, "runSuite changed after initial run" );
|
||||
});
|
||||
|
||||
test( "iframe only created once", function(){
|
||||
QUnit.runSuite();
|
||||
equal( this.appendChildCall.called, 1, "append child called once" );
|
||||
QUnit.runSuite();
|
||||
equal( this.appendChildCall.called, 1, "append child only ever called once" );
|
||||
});
|
||||
|
||||
test( "iframe's QUnit object is modified when iframe source loads", function(){
|
||||
var before = this.iframeQUnitObject,
|
||||
after;
|
||||
QUnit.runSuite();
|
||||
this.iframeLoad.callback();
|
||||
notEqual( before, after, "iframe's qunit object is modified upon load");
|
||||
});
|
||||
|
||||
test( "iframe src set to suite passed", function(){
|
||||
var pages = ["testing.html", "subsuiteRunner.html"];
|
||||
QUnit.runSuite( pages[0] );
|
||||
equal( this.setAttributeCall.args[0], "src", "src attribute set" );
|
||||
equal( this.setAttributeCall.args[1], pages[0], "src attribute set" );
|
||||
QUnit.runSuite( pages[1] );
|
||||
equal( this.setAttributeCall.args[1], pages[1], "src attribute set" );
|
||||
});
|
||||
Arquivo executável
+19
@@ -0,0 +1,19 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<title>QUnit Core Test Suite</title>
|
||||
<link rel="stylesheet" href="../../qunit/qunit.css" type="text/css" media="screen">
|
||||
<script src="../../qunit/qunit.js"></script>
|
||||
|
||||
<script src="../../test/test.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1 id="qunit-header">QUnit Core Test Suite</h1>
|
||||
<h2 id="qunit-banner"></h2>
|
||||
<div id="qunit-testrunner-toolbar"></div>
|
||||
<h2 id="qunit-userAgent"></h2>
|
||||
<ol id="qunit-tests"></ol>
|
||||
<div id="qunit-fixture">test markup</div>
|
||||
</body>
|
||||
</html>
|
||||
Arquivo executável
+19
@@ -0,0 +1,19 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<title>QUnit Same Test Suite</title>
|
||||
<link rel="stylesheet" href="../../qunit/qunit.css" type="text/css" media="screen">
|
||||
<script src="../../qunit/qunit.js"></script>
|
||||
|
||||
<script src="../../test/same.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1 id="qunit-header">QUnit Same Test Suite</h1>
|
||||
<h2 id="qunit-banner"></h2>
|
||||
<div id="qunit-testrunner-toolbar"></div>
|
||||
<h2 id="qunit-userAgent"></h2>
|
||||
<ol id="qunit-tests"></ol>
|
||||
<div id="qunit-fixture">test markup</div>
|
||||
</body>
|
||||
</html>
|
||||
Arquivo executável
+35
@@ -0,0 +1,35 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<title>Composite</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Composite</h1>
|
||||
<h3>A QUnit Addon For Running Multiple Test Files</h3>
|
||||
<p>Composite is a QUnit addon that, when handed an array of
|
||||
files, will open each of those files inside of an iframe, run
|
||||
the tests and display the results as a single suite of QUnit
|
||||
tests.</p>
|
||||
<h4>Using Composite</h4>
|
||||
<p>To use Composite, setup a standard QUnit html page as you
|
||||
would with other QUnit tests. Remember to include composite.js
|
||||
and composite.css. Then, inside of either an external js file,
|
||||
or a script block call the only new method that Composite
|
||||
exposes, QUnit.testSuites().</p><p>QUnit.testSuites() is
|
||||
passed an array of test files to run as follows:</p>
|
||||
<pre>
|
||||
QUnit.testSuites([
|
||||
"test-file-1.html",
|
||||
"test-file-2.html",
|
||||
"test-file-3.html"
|
||||
]);
|
||||
</pre>
|
||||
<h4>Tests</h4>
|
||||
<p>Composite has tests of it's own.</p>
|
||||
<p>
|
||||
<a href="composite-test.html">Composite Test</a>: A suite which tests the implementation of composite.<br>
|
||||
<a href="composite-demo-test.html">Composite Demo</a>: A suite which demoes how Compisite is bootstrapped and run.
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
||||
Arquivo executável
+13
@@ -0,0 +1,13 @@
|
||||
iframe.qunit-subsuite{
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
border-width: 1px 0 0;
|
||||
height: 45%;
|
||||
width: 100%;
|
||||
|
||||
background: #fff;
|
||||
}
|
||||
Arquivo executável
+82
@@ -0,0 +1,82 @@
|
||||
(function( QUnit ) {
|
||||
|
||||
var subsuiteFrame;
|
||||
|
||||
QUnit.extend( QUnit, {
|
||||
testSuites: function( suites ) {
|
||||
for ( var i = 0; i < suites.length; i++ ) {
|
||||
(function( suite ) {
|
||||
asyncTest( suite, function() {
|
||||
QUnit.runSuite( suite );
|
||||
});
|
||||
}( suites[i] ) );
|
||||
}
|
||||
QUnit.done = function() {
|
||||
subsuiteFrame.style.display = "none";
|
||||
};
|
||||
},
|
||||
|
||||
testStart: function( data ) {
|
||||
// update the test status to show which test suite is running
|
||||
QUnit.id( "qunit-testresult" ).innerHTML = "Running " + data.name + "...<br> ";
|
||||
},
|
||||
|
||||
testDone: function() {
|
||||
var current = QUnit.id( this.config.current.id ),
|
||||
children = current.children;
|
||||
|
||||
// undo the auto-expansion of failed tests
|
||||
for ( var i = 0; i < children.length; i++ ) {
|
||||
if ( children[i].nodeName === "OL" ) {
|
||||
children[i].style.display = "none";
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
runSuite: function( suite ) {
|
||||
var body = document.getElementsByTagName( "body" )[0],
|
||||
iframe = subsuiteFrame = document.createElement( "iframe" ),
|
||||
iframeWin;
|
||||
|
||||
iframe.className = "qunit-subsuite";
|
||||
body.appendChild( iframe );
|
||||
|
||||
function onIframeLoad() {
|
||||
var module, test,
|
||||
count = 0;
|
||||
|
||||
QUnit.extend( iframeWin.QUnit, {
|
||||
moduleStart: function( data ) {
|
||||
// capture module name for messages
|
||||
module = data.name;
|
||||
},
|
||||
|
||||
testStart: function( data ) {
|
||||
// capture test name for messages
|
||||
test = data.name;
|
||||
},
|
||||
|
||||
log: function( data ) {
|
||||
// pass all test details through to the main page
|
||||
var message = module + ": " + test + ": " + data.message;
|
||||
expect( ++count );
|
||||
QUnit.push( data.result, data.actual, data.expected, message );
|
||||
},
|
||||
|
||||
done: function() {
|
||||
// start the wrapper test from the main page
|
||||
start();
|
||||
}
|
||||
});
|
||||
}
|
||||
QUnit.addEvent( iframe, "load", onIframeLoad );
|
||||
|
||||
iframeWin = iframe.contentWindow;
|
||||
iframe.setAttribute( "src", suite );
|
||||
|
||||
this.runSuite = function( suite ) {
|
||||
iframe.setAttribute( "src", suite );
|
||||
};
|
||||
}
|
||||
});
|
||||
}( QUnit ) );
|
||||
Arquivo executável
+18
@@ -0,0 +1,18 @@
|
||||
QUnit.step() - A QUnit Addon For Testing execution in order
|
||||
============================================================
|
||||
|
||||
This addon for QUnit adds a step method that allows you to assert
|
||||
the proper sequence in which the code should execute.
|
||||
|
||||
Example:
|
||||
|
||||
test("example test", function () {
|
||||
function x() {
|
||||
QUnit.step(2, "function y should be called first");
|
||||
}
|
||||
function y() {
|
||||
QUnit.step(1);
|
||||
}
|
||||
y();
|
||||
x();
|
||||
});
|
||||
Arquivo executável
+25
@@ -0,0 +1,25 @@
|
||||
QUnit.extend( QUnit, {
|
||||
|
||||
/**
|
||||
* Check the sequence/order
|
||||
*
|
||||
* @example step(1); setTimeout(function () { step(3); }, 100); step(2);
|
||||
* @param Number expected The excepted step within the test()
|
||||
* @param String message (optional)
|
||||
*/
|
||||
step: function (expected, message) {
|
||||
this.config.current.step++; // increment internal step counter.
|
||||
if (typeof message == "undefined") {
|
||||
message = "step " + expected;
|
||||
}
|
||||
var actual = this.config.current.step;
|
||||
QUnit.push(QUnit.equiv(actual, expected), actual, expected, message);
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Reset the step counter for every test()
|
||||
*/
|
||||
QUnit.testStart(function () {
|
||||
this.config.current.step = 0;
|
||||
});
|
||||
Arquivo executável
+13
@@ -0,0 +1,13 @@
|
||||
module('Step Addon');
|
||||
test("step", 3, function () {
|
||||
QUnit.step(1, "step starts at 1");
|
||||
setTimeout(function () {
|
||||
start();
|
||||
QUnit.step(3);
|
||||
}, 100);
|
||||
QUnit.step(2, "before the setTimeout callback is run");
|
||||
stop();
|
||||
});
|
||||
test("step counter", 1, function () {
|
||||
QUnit.step(1, "each test has its own step counter");
|
||||
});
|
||||
Arquivo executável
+19
@@ -0,0 +1,19 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<title>QUnit Test Suite - Step Addon</title>
|
||||
<link rel="stylesheet" href="../../qunit/qunit.css" type="text/css" media="screen">
|
||||
<script type="text/javascript" src="../../qunit/qunit.js"></script>
|
||||
<script type="text/javascript" src="qunit-step.js"></script>
|
||||
<script type="text/javascript" src="step-test.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1 id="qunit-header">QUnit Test Suite - Step Addon</h1>
|
||||
<h2 id="qunit-banner"></h2>
|
||||
<div id="qunit-testrunner-toolbar"></div>
|
||||
<h2 id="qunit-userAgent"></h2>
|
||||
<ol id="qunit-tests"></ol>
|
||||
<canvas id="qunit-canvas" width="5" height="5"></canvas>
|
||||
</body>
|
||||
</html>
|
||||
Arquivo executável
+27
@@ -0,0 +1,27 @@
|
||||
{
|
||||
"name": "qunit",
|
||||
"author": "The jQuery Project",
|
||||
"contributors": [
|
||||
{
|
||||
"name": "John Resig",
|
||||
"email": "jeresig@gmail.com",
|
||||
"url": "http://ejohn.org/"
|
||||
},
|
||||
{
|
||||
"name": "Jörn Zaefferer",
|
||||
"email": "joern.zaefferer@googlemail.com",
|
||||
"url": "http://bassistance.de/"
|
||||
}],
|
||||
"url": "http://docs.jquery.com/QUnit",
|
||||
"repositories" : [{
|
||||
"type": "git",
|
||||
"url": "https://github.com/jquery/qunit.git"
|
||||
}],
|
||||
"license": {
|
||||
"name": "MIT",
|
||||
"url": "http://www.opensource.org/licenses/mit-license.php"
|
||||
},
|
||||
"description": "An easy-to-use JavaScript Unit Testing framework.",
|
||||
"keywords": [ "testing", "unit", "jquery" ],
|
||||
"main": "qunit/qunit.js"
|
||||
}
|
||||
Arquivo executável
+226
@@ -0,0 +1,226 @@
|
||||
/**
|
||||
* QUnit - A JavaScript Unit Testing Framework
|
||||
*
|
||||
* http://docs.jquery.com/QUnit
|
||||
*
|
||||
* Copyright (c) 2011 John Resig, Jörn Zaefferer
|
||||
* Dual licensed under the MIT (MIT-LICENSE.txt)
|
||||
* or GPL (GPL-LICENSE.txt) licenses.
|
||||
*/
|
||||
|
||||
/** Font Family and Sizes */
|
||||
|
||||
#qunit-tests, #qunit-header, #qunit-banner, #qunit-testrunner-toolbar, #qunit-userAgent, #qunit-testresult {
|
||||
font-family: "Helvetica Neue Light", "HelveticaNeue-Light", "Helvetica Neue", Calibri, Helvetica, Arial, sans-serif;
|
||||
}
|
||||
|
||||
#qunit-testrunner-toolbar, #qunit-userAgent, #qunit-testresult, #qunit-tests li { font-size: small; }
|
||||
#qunit-tests { font-size: smaller; }
|
||||
|
||||
|
||||
/** Resets */
|
||||
|
||||
#qunit-tests, #qunit-tests ol, #qunit-header, #qunit-banner, #qunit-userAgent, #qunit-testresult {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
|
||||
/** Header */
|
||||
|
||||
#qunit-header {
|
||||
padding: 0.5em 0 0.5em 1em;
|
||||
|
||||
color: #8699a4;
|
||||
background-color: #0d3349;
|
||||
|
||||
font-size: 1.5em;
|
||||
line-height: 1em;
|
||||
font-weight: normal;
|
||||
|
||||
border-radius: 15px 15px 0 0;
|
||||
-moz-border-radius: 15px 15px 0 0;
|
||||
-webkit-border-top-right-radius: 15px;
|
||||
-webkit-border-top-left-radius: 15px;
|
||||
}
|
||||
|
||||
#qunit-header a {
|
||||
text-decoration: none;
|
||||
color: #c2ccd1;
|
||||
}
|
||||
|
||||
#qunit-header a:hover,
|
||||
#qunit-header a:focus {
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
#qunit-banner {
|
||||
height: 5px;
|
||||
}
|
||||
|
||||
#qunit-testrunner-toolbar {
|
||||
padding: 0.5em 0 0.5em 2em;
|
||||
color: #5E740B;
|
||||
background-color: #eee;
|
||||
}
|
||||
|
||||
#qunit-userAgent {
|
||||
padding: 0.5em 0 0.5em 2.5em;
|
||||
background-color: #2b81af;
|
||||
color: #fff;
|
||||
text-shadow: rgba(0, 0, 0, 0.5) 2px 2px 1px;
|
||||
}
|
||||
|
||||
|
||||
/** Tests: Pass/Fail */
|
||||
|
||||
#qunit-tests {
|
||||
list-style-position: inside;
|
||||
}
|
||||
|
||||
#qunit-tests li {
|
||||
padding: 0.4em 0.5em 0.4em 2.5em;
|
||||
border-bottom: 1px solid #fff;
|
||||
list-style-position: inside;
|
||||
}
|
||||
|
||||
#qunit-tests.hidepass li.pass, #qunit-tests.hidepass li.running {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#qunit-tests li strong {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
#qunit-tests li a {
|
||||
padding: 0.5em;
|
||||
color: #c2ccd1;
|
||||
text-decoration: none;
|
||||
}
|
||||
#qunit-tests li a:hover,
|
||||
#qunit-tests li a:focus {
|
||||
color: #000;
|
||||
}
|
||||
|
||||
#qunit-tests ol {
|
||||
margin-top: 0.5em;
|
||||
padding: 0.5em;
|
||||
|
||||
background-color: #fff;
|
||||
|
||||
border-radius: 15px;
|
||||
-moz-border-radius: 15px;
|
||||
-webkit-border-radius: 15px;
|
||||
|
||||
box-shadow: inset 0px 2px 13px #999;
|
||||
-moz-box-shadow: inset 0px 2px 13px #999;
|
||||
-webkit-box-shadow: inset 0px 2px 13px #999;
|
||||
}
|
||||
|
||||
#qunit-tests table {
|
||||
border-collapse: collapse;
|
||||
margin-top: .2em;
|
||||
}
|
||||
|
||||
#qunit-tests th {
|
||||
text-align: right;
|
||||
vertical-align: top;
|
||||
padding: 0 .5em 0 0;
|
||||
}
|
||||
|
||||
#qunit-tests td {
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
#qunit-tests pre {
|
||||
margin: 0;
|
||||
white-space: pre-wrap;
|
||||
word-wrap: break-word;
|
||||
}
|
||||
|
||||
#qunit-tests del {
|
||||
background-color: #e0f2be;
|
||||
color: #374e0c;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
#qunit-tests ins {
|
||||
background-color: #ffcaca;
|
||||
color: #500;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
/*** Test Counts */
|
||||
|
||||
#qunit-tests b.counts { color: black; }
|
||||
#qunit-tests b.passed { color: #5E740B; }
|
||||
#qunit-tests b.failed { color: #710909; }
|
||||
|
||||
#qunit-tests li li {
|
||||
margin: 0.5em;
|
||||
padding: 0.4em 0.5em 0.4em 0.5em;
|
||||
background-color: #fff;
|
||||
border-bottom: none;
|
||||
list-style-position: inside;
|
||||
}
|
||||
|
||||
/*** Passing Styles */
|
||||
|
||||
#qunit-tests li li.pass {
|
||||
color: #5E740B;
|
||||
background-color: #fff;
|
||||
border-left: 26px solid #C6E746;
|
||||
}
|
||||
|
||||
#qunit-tests .pass { color: #528CE0; background-color: #D2E0E6; }
|
||||
#qunit-tests .pass .test-name { color: #366097; }
|
||||
|
||||
#qunit-tests .pass .test-actual,
|
||||
#qunit-tests .pass .test-expected { color: #999999; }
|
||||
|
||||
#qunit-banner.qunit-pass { background-color: #C6E746; }
|
||||
|
||||
/*** Failing Styles */
|
||||
|
||||
#qunit-tests li li.fail {
|
||||
color: #710909;
|
||||
background-color: #fff;
|
||||
border-left: 26px solid #EE5757;
|
||||
white-space: pre;
|
||||
}
|
||||
|
||||
#qunit-tests > li:last-child {
|
||||
border-radius: 0 0 15px 15px;
|
||||
-moz-border-radius: 0 0 15px 15px;
|
||||
-webkit-border-bottom-right-radius: 15px;
|
||||
-webkit-border-bottom-left-radius: 15px;
|
||||
}
|
||||
|
||||
#qunit-tests .fail { color: #000000; background-color: #EE5757; }
|
||||
#qunit-tests .fail .test-name,
|
||||
#qunit-tests .fail .module-name { color: #000000; }
|
||||
|
||||
#qunit-tests .fail .test-actual { color: #EE5757; }
|
||||
#qunit-tests .fail .test-expected { color: green; }
|
||||
|
||||
#qunit-banner.qunit-fail { background-color: #EE5757; }
|
||||
|
||||
|
||||
/** Result */
|
||||
|
||||
#qunit-testresult {
|
||||
padding: 0.5em 0.5em 0.5em 2.5em;
|
||||
|
||||
color: #2b81af;
|
||||
background-color: #D2E0E6;
|
||||
|
||||
border-bottom: 1px solid white;
|
||||
}
|
||||
|
||||
/** Fixture */
|
||||
|
||||
#qunit-fixture {
|
||||
position: absolute;
|
||||
top: -10000px;
|
||||
left: -10000px;
|
||||
}
|
||||
Arquivo executável
+1552
Diferenças do arquivo suprimidas por serem muito extensas
Carregar Diff
Arquivo executável
+24
@@ -0,0 +1,24 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>QUnit Test Suite</title>
|
||||
<link rel="stylesheet" href="../qunit/qunit.css" type="text/css" media="screen">
|
||||
<script type="text/javascript" src="../qunit/qunit.js"></script>
|
||||
<script type="text/javascript" src="test.js"></script>
|
||||
<script type="text/javascript" src="same.js"></script>
|
||||
<script>
|
||||
var logs = ["begin", "testStart", "testDone", "log", "moduleStart", "moduleDone", "done"];
|
||||
for (var i = 0; i < logs.length; i++) {
|
||||
(function() {
|
||||
var log = logs[i];
|
||||
QUnit[log] = function() {
|
||||
console.log(log, arguments);
|
||||
};
|
||||
})();
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="qunit-fixture">test markup</div>
|
||||
</body>
|
||||
</html>
|
||||
Arquivo executável
+19
@@ -0,0 +1,19 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<title>QUnit Test Suite</title>
|
||||
<link rel="stylesheet" href="../qunit/qunit.css" type="text/css" media="screen">
|
||||
<script type="text/javascript" src="../qunit/qunit.js"></script>
|
||||
<script type="text/javascript" src="test.js"></script>
|
||||
<script type="text/javascript" src="same.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1 id="qunit-header">QUnit Test Suite</h1>
|
||||
<h2 id="qunit-banner"></h2>
|
||||
<div id="qunit-testrunner-toolbar"></div>
|
||||
<h2 id="qunit-userAgent"></h2>
|
||||
<ol id="qunit-tests"></ol>
|
||||
<div id="qunit-fixture">test markup</div>
|
||||
</body>
|
||||
</html>
|
||||
Arquivo executável
+17
@@ -0,0 +1,17 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>QUnit Test Suite</title>
|
||||
<link rel="stylesheet" href="../qunit/qunit.css" type="text/css" media="screen">
|
||||
<script type="text/javascript" src="../qunit/qunit.js"></script>
|
||||
<script type="text/javascript" src="logs.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1 id="qunit-header">QUnit Test Suite</h1>
|
||||
<h2 id="qunit-banner"></h2>
|
||||
<div id="qunit-testrunner-toolbar"></div>
|
||||
<h2 id="qunit-userAgent"></h2>
|
||||
<ol id="qunit-tests"></ol>
|
||||
<div id="qunit-fixture">test markup</div>
|
||||
</body>
|
||||
</html>
|
||||
Alguns arquivos não foram exibidos porque demasiados arquivos foram alterados neste diff Mostrar Mais
Referência em uma Nova Issue
Bloquear um usuário