Comparar commits

..

105 Commits

Autor SHA1 Mensagem Data
Steve Heffernan c6153f7556 Merge branch 'hotfix/docs-url-fix' into stable 2012-01-12 16:35:16 -08:00
Steve Heffernan 11a75fe74f Adding line to CHANGELOG: Fixed wrong URL for CDN in docs 2012-01-12 16:35:16 -08:00
Steve Heffernan 8a5f667159 Bumping version to 3.0.6. 2012-01-12 16:35:03 -08:00
Steve Heffernan a2651b9ab5 Fixed wrong url for CDN 2012-01-12 16:34:34 -08:00
Steve Heffernan 2dc3de9de1 Merge branch 'hotfix/event-layer-x-deprecation-fix' into stable 2012-01-12 15:44:51 -08:00
Steve Heffernan d1824d7c28 Adding line to CHANGELOG: Removed deprecated event.layerX and layerY 2012-01-12 15:44:51 -08:00
Steve Heffernan a9c9722647 Bumping version to 3.0.5. 2012-01-12 15:44:34 -08:00
Steve Heffernan 534fb39e89 Removed event.layerX and layerY which weren't used and were throwing deprecation warnings. 2012-01-12 15:41:30 -08:00
Steve Heffernan ff2d59fcf8 Merge branch 'hotfix/undefined-source-fix' into stable 2012-01-12 14:30:14 -08:00
Steve Heffernan 855f513d5f Adding line to CHANGELOG: Fixing an undefined source when no sources exist on load 2012-01-12 14:30:14 -08:00
Steve Heffernan 62bb873ddd Bumping version to 3.0.4. 2012-01-12 14:29:46 -08:00
Raymond Cohen 55ac829fb1 If there are no sources when the player is initialized, loadTech is called with an undefined source.
It would then error on source.src
2012-01-12 14:26:27 -08:00
Steve Heffernan 6def502496 Merge branch 'hotfix/doc-change' into stable 2012-01-12 13:30:59 -08:00
Steve Heffernan dff355dda9 Adding line to CHANGELOG: Added line to docs to test zenflow 2012-01-12 13:30:59 -08:00
Steve Heffernan 1d65860227 Bumping version to 3.0.3. 2012-01-12 13:29:23 -08:00
Steve Heffernan ee740c619f Added description of events. 2012-01-12 13:05:06 -08:00
Steve Heffernan a1a0e351c1 Set up zenflow workflow management config. 2012-01-12 12:59:53 -08:00
Steve Heffernan 44b02529ba Poster was wrongly removed from setup change. Fixed.
Upated docs.
2012-01-10 15:52:20 -08:00
Steve Heffernan a83433f655 Updated options docs.
Full URL to flash SWF.
2012-01-10 13:15:49 -08:00
Steve Heffernan d80e3e328a Updated version number. 2012-01-10 10:10:07 -08:00
Steve Heffernan 166bd0b44f Fixed an offset width bug with IE that was causing player to break. 2012-01-09 16:28:26 -08:00
Steve Heffernan 7b7c8a497f Updated skins doc 2012-01-09 13:32:10 -08:00
Steve Heffernan 42c9e43736 Removed beta references 2012-01-09 12:38:43 -08:00
Steve Heffernan 90956059f6 Updated to newest version of Flash player. Preparing for final release. 2012-01-09 12:18:08 -08:00
Steve Heffernan ab07612c05 Updated playback tech docs 2012-01-09 10:05:19 -08:00
Steve Heffernan 7ef5b15ae2 Updated api and setup docs 2012-01-05 23:25:09 -08:00
Steve Heffernan 9678c7717f Added manual poster image to get around flash cross domain issues.
Starting controls hidden.
Making tech elements clickable.
2012-01-02 16:57:17 -08:00
Steve Heffernan 8dd38fc747 Updated flash player 2012-01-02 15:37:37 -08:00
Steve Heffernan 242ff4c68b Fixed tech switching.
Fixed an issue where bigplaybutton was throwing an error when not preloading.
Fixed a bufferring issue when tech switching.
2012-01-02 13:02:04 -08:00
Steve Heffernan 38cc63c530 Merge branch 'master' of github.com:zencoder/video-js 2012-01-02 10:16:42 -08:00
Steve Heffernan 41b93513a2 Updated docs for site. Add 'projects' to gitignore. 2012-01-02 10:14:51 -08:00
Heff 359cde31c2 Merge pull request #111 from mchristopher/master
Maintain license block
2011-12-27 14:52:28 -08:00
Michael Christopher 1fba4f4b88 Added ! to first line of license block so YCompress doesn't strip it out 2011-12-27 16:50:32 -06:00
Steve Heffernan 16f6c229f3 Merge branch 'master' of github.com:zencoder/video-js 2011-12-21 18:16:12 -08:00
Steve Heffernan accdfcb02c Cleaned up spinner code. 2011-12-21 18:15:47 -08:00
Heff ee1a7dae99 Merge pull request #106 from tremby/master
Fix #105
2011-12-21 18:13:03 -08:00
Heff b31eba988b Merge pull request #103 from rkyrychuk/patch-3
Auto rewind on big button play click
2011-12-21 18:10:19 -08:00
Heff 20b36faf11 Merge pull request #102 from rkyrychuk/patch-2
Ensure that tracking progress and time progress will stop after destroy
2011-12-21 18:07:50 -08:00
Steve Heffernan 82142e2f54 Added loading spinner code from ZenJosh. 2011-12-21 17:59:36 -08:00
Bart Nagel 1c18578466 automatically create dist subdirectory 2011-12-16 01:06:00 -08:00
Bart Nagel 0e81c6b059 fixed cue search algorithm bug 2011-12-16 00:52:15 -08:00
rkyrychuk 99fa329bc5 Auto rewind on big button play click 2011-12-15 23:58:35 +02:00
rkyrychuk f13a2bf733 Ensure that tracking progress and time progress will stop and player deleted after calling destroy method 2011-12-15 23:17:10 +02:00
Steve Heffernan 6945be3d6e Updated volume display to automically set itself. 2011-12-08 17:33:44 -08:00
Steve Heffernan d1fb95ecbf Fixed another issue with passing vars to flash 2011-12-07 22:12:36 -08:00
Steve Heffernan 176eb1f559 Fixed an error with updating tech support. 2011-12-07 22:04:54 -08:00
Steve Heffernan 8babbb412c Cleaned up tech name 2011-12-07 22:02:40 -08:00
Steve Heffernan f4e68d1a47 Fix flashvar name 2011-12-07 21:41:28 -08:00
Steve Heffernan e0516a4c83 Added ability to pass options to flash fallback. 2011-12-07 21:29:21 -08:00
Steve Heffernan 1972528df7 Changed h5swf name to just Flash for ease of use. And lowercased tech object names. 2011-12-07 21:03:12 -08:00
Steve Heffernan 39f7bead50 Updated compare page. 2011-12-07 16:44:21 -08:00
Steve Heffernan e4f6bbb0b2 Optimized slider controls.
Fixed issue with fullscreen progress bar tracking (offset left wasn't working in new fullscreen)
2011-12-05 11:28:18 -08:00
Steve Heffernan afc9369849 Merge branch 'master' of github.com:zencoder/video-js
Conflicts:
	src/player.js
	src/tech.js
2011-12-01 16:52:23 -08:00
Steve Heffernan 325084c6a1 Updated swf code to auto play on new src. 2011-12-01 16:48:06 -08:00
Heff 2f99215f8d Merge pull request #98 from ZenJosh/master
Refactored fullscreen logic
2011-12-01 16:47:55 -08:00
Josh Pickett d90cee588a Removed try catch from requestFullScreen 2011-12-01 16:35:13 -08:00
Josh Pickett 00a38f76a7 Refactored fullscreen logic 2011-12-01 16:29:52 -08:00
Steve Heffernan b329dfd107 Merge branch 'master' of github.com:zencoder/video-js 2011-12-01 16:17:40 -08:00
Heff 11286190fa Merge pull request #97 from ZenJosh/master
Fixed Firefox/IE9 fullWindow bug
2011-12-01 16:17:28 -08:00
Josh Pickett 05d7a81885 Fixed Firefox/IE9 fullWindow bug 2011-12-01 16:07:19 -08:00
Josh Pickett 1dd70d1c77 Merge branch 'master' of http://github.com/zencoder/video-js 2011-12-01 15:47:53 -08:00
Steve Heffernan 437566740f Merge branch 'master' of github.com:zencoder/video-js 2011-12-01 15:47:52 -08:00
Steve Heffernan 7e747e95ab Updated swf object to newest version.
Optimizing player for later loaded sources.
2011-12-01 15:47:12 -08:00
Heff de6230644e Merge pull request #96 from ZenJosh/master
Added fullscreen controls to supported browsers
2011-12-01 15:46:32 -08:00
Josh Pickett 08aa73ccf6 Added fullscreen with controls to supported browsers 2011-12-01 15:38:15 -08:00
Josh Pickett 2607e82aaf Native fullscreen with controls added for supported browsers 2011-12-01 15:24:34 -08:00
Steve Heffernan ec145f6d4d Fixed an issue with ajax errors 2011-11-30 14:05:28 -08:00
Steve Heffernan 78a3b16e9c Cleaned up dev.html.example 2011-11-30 13:34:33 -08:00
Steve Heffernan 58cf933091 Updated readme to talk about dev.html 2011-11-30 13:27:21 -08:00
Steve Heffernan f8fc9a8d7b Renamed to dev.html.example 2011-11-30 13:14:39 -08:00
Steve Heffernan 5f4369e188 Added dev.html to gitignore 2011-11-30 13:13:35 -08:00
Steve Heffernan 4593421adb Removing dev.html and adding dev_example.html to allow for testing without pushing changes to dev.html 2011-11-30 13:12:28 -08:00
Steve Heffernan f0154eeab7 Added support for loading the player first and then setting the source later.
Fixed iOS loading issue.
2011-11-30 13:06:32 -08:00
Steve Heffernan 1e284827d7 Modified some comments 2011-11-30 11:53:08 -08:00
Steve Heffernan 3e99e630ea Added gitignore 2011-11-29 19:36:50 -08:00
Steve Heffernan 0c7334c861 Fixed some IE comma errors. Made ajax error clearer. Fixed a setup issue. 2011-11-29 16:39:43 -08:00
Steve Heffernan 82d55c45e7 Updated error with updating tech support 2011-11-29 12:12:13 -08:00
Steve Heffernan 7538241008 MAJOR REFACTOR: Restrcutured code into class-based components. Setup and configuring should still work the same, but controls and tech elements are now sub-classes for Component, which builds elements and applies event behaviors.
Removed demo source code from repository root. Was receiving pull requests for the release files instead of source files. This makes it more clear where to make changes.

Merge branch 'master' of github.com:zencoder/video-js

Conflicts:
	dev/src/api.js
2011-11-29 11:42:28 -08:00
Steve Heffernan 6193e01004 MAJOR REFACTOR: Restrcutured code into class-based components. Setup and configuring should still work the same, but controls and tech elements are now sub-classes for Component, which builds elements and applies event behaviors.
Removed demo source code from repository root. Was receiving pull requests for the release files instead of source files. This makes it more clear where to make changes.

Merge branch 'ui'

Conflicts:
	dev/flash/VideoJS.swf
2011-11-29 11:41:42 -08:00
Steve Heffernan ef321a8072 MAJOR REFACTOR: Restrcutured code into class-based components. Setup and configuring should still work the same, but controls and tech elements are now sub-classes for Component, which builds elements and applies event behaviors.
Removed demo source code from repository root. Was receiving pull requests for the release files instead of source files. This makes it more clear where to make changes.
2011-11-29 11:40:05 -08:00
Heff e5a44eef58 Merge pull request #92 from stevecochrane/master
Fixed a bug in api.js that would cause a JavaScript error when entering fullscreen, in HTML5 mode, for browsers that support fullscreen (Safari)
2011-11-29 10:48:42 -08:00
Steve Heffernan 5488570745 Update flash player 2011-11-21 19:44:39 -08:00
Steve Heffernan a314c0a242 Attempting new UI organization. 2011-11-21 17:19:31 -08:00
Steve Cochrane 53e1d0eb65 Fixed a bug with an enterFullScreen API call which was using a non-existant 'api()' method, when it should have been 'apiCall()'. This caused a JavaScript error which would break fullscreen in HTML5 mode for browsers that support it (Safari). 2011-11-21 14:35:58 -08:00
Steve Heffernan 193172498c Added fix for h5swf Flash version checking. (Issue 90)
Added fix for iPhone move in dom var. (Issue 84)
2011-11-18 15:53:00 -08:00
Steve Heffernan 7da9bdd073 Added licence info back to top of script. 2011-11-18 14:37:55 -08:00
Steve Heffernan df3718cd55 Updated to new version of SWF 2011-11-17 16:54:02 -08:00
Steve Heffernan c5a22081b4 Removed dist version. Minor changes/optimizations. 2011-11-17 16:28:49 -08:00
Steve Heffernan 3fc71d098d Added ready callback to setup.
Moved _V_.players storing to init.
2011-11-15 18:04:39 -08:00
Steve Heffernan 34c187cd9a Updated init script to allow for controls attribute to be false. 2011-11-15 13:27:37 -08:00
Steve Heffernan 3243b01e6c Added autoplay fix for Safari.
Added CSS updated to src files.
2011-11-14 17:32:10 -08:00
Steve Heffernan cc27d630c6 Merge branch 'master' of github.com:zencoder/video-js 2011-11-14 16:54:22 -08:00
Heff db0033ebe5 Merge pull request #81 from kristerkari/master
Simplify CSS gradient syntax & Drop units from zero values
2011-11-14 11:53:48 -08:00
Krister Kari c2b43903ab Simplify CSS gradient syntax 2011-10-14 23:03:33 +03:00
Krister Kari 2ea9c99f34 Drop units from zero values 2011-10-14 22:16:04 +03:00
Steve Heffernan 449c7014fb Merge branch 'master' of github.com:zencoder/video-js 2011-10-03 16:01:38 -07:00
Heff 6d59836b76 Merge pull request #79 from argami/master
Totally forgot to add the modification to src
2011-10-03 15:35:58 -07:00
Gamaliel A. Toro Herrera e703e1591e - combine_sources.sh last line didn't execute some character in the previous one removed
- re-generated video.js on the main
2011-10-03 22:56:12 +02:00
Gamaliel A. Toro Herrera c4f87649e4 - added technology order (source and dist) if everything fails last option flash 2011-10-03 21:20:09 +02:00
Steve Heffernan 6cccf594ad Added tagging notes 2011-10-03 11:12:21 -07:00
Steve Heffernan df41661f47 Moved youtube test file. 2011-10-03 10:32:07 -07:00
Steve Heffernan 3daa81f87e Merge branch 'master' of github.com:zencoder/video-js 2011-10-03 10:30:48 -07:00
Steve Heffernan 4f60eb896c Added YouTube support at video hack day SF. 2011-10-03 10:25:02 -07:00
Heff ee7318f6ae Merge pull request #78 from argami/master
New version is using flash all the time (sorry, was testing and forgot to switch back)
2011-10-03 10:24:08 -07:00
Gamaliel A. Toro Herrera d7aa9f9558 - change order of technologies to check first html5 over flash 2011-10-03 17:38:13 +02:00
113 arquivos alterados com 3622 adições e 6343 exclusões
+5
Ver Arquivo
@@ -0,0 +1,5 @@
.DS_Store
dist/*
dev.html
projects
.zenflow-log
+10
Ver Arquivo
@@ -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
+18
Ver Arquivo
@@ -0,0 +1,18 @@
--------------------------------------------------------------------------------
^ 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
---- 3.0.5 / 2012-01-12 / event-layer-x-deprecation-fix ------------------------
* Removed deprecated event.layerX and layerY
---- 3.0.6 / 2012-01-12 / docs-url-fix -----------------------------------------
* Fixed wrong URL for CDN in docs
Ver Arquivo
+15 -138
Ver Arquivo
@@ -2,6 +2,21 @@ 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:
@@ -13,141 +28,3 @@ Version 3 is almost a complete rewrite of the previous versions of VideoJS. New
- No more embedding of Flash fallback within the video tag HTML.
---
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. 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 VideoJS 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 VideoJS:
1. The 'data-setup' Atrribute tells VideoJS 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 VideoJS 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 for more advanced uses.
Coming Next
-----------
- Stable Release
Changelog
---------
3.0b
- Complete rewrite in progress
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
+4
Ver Arquivo
@@ -0,0 +1,4 @@
---
major: 3
patch: 6
minor: 0
Arquivo executável
+48
Ver Arquivo
@@ -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
+28
Ver Arquivo
@@ -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.
+153
Ver Arquivo
@@ -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
+5 -4
Ver Arquivo
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html>
<head>
<title>VideoJS | HTML5 Video Player</title>
<title>Video.js | HTML5 Video Player</title>
<link href="video-js.css" rel="stylesheet" type="text/css">
@@ -13,9 +13,10 @@
<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'>
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>
+7
Ver Arquivo
@@ -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; }
+75
Ver Arquivo
@@ -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>
+27 -12
Ver Arquivo
@@ -1,18 +1,22 @@
$(function(){
var tech, i,
techList = ["html5","h5swf","flowplayer"],
props = "error,currentSrc,networkState,buffered,readyState,seeking,initialTime,duration,startOffsetTime,paused,played,seekable,ended,videoWidth,videoHeight,textTracks,preload,currentTime,playbackRate,autoplay,loop,controls,volume,muted,defaultMuted".split(","),
_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();
var player = _V_("vid"+(i+1), { "techOrder":[tech] });
player = _V_("vid"+(i+1), { "techOrder":[tech] });
_V_.each(_V_.html5Events, function(evt){
player.addEvent(evt, _V_.proxy(tech, function(evt){
_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();
@@ -26,9 +30,9 @@ $(function(){
}));
});
var propTable = $("#"+tech+"_props");
var propTable = $("#"+tname+"_props");
_V_.each(props, function(prop){
propTable.append("<tr><th>"+prop+"</th><td id='"+tech+prop+"' class='data'></td></tr>")
propTable.append("<tr><th>"+prop+"</th><td id='"+tname+prop+"' class='data'></td></tr>")
});
setInterval(_V_.proxy(player, function(){
@@ -42,12 +46,23 @@ $(function(){
if (result === null) result = "<span class='undefined'>null</span>";
if (result === undefined) result = "<span class='undefined'>undefined</span>";
if (typeof result.start == "function") {
result = (result.length > 0) ? "s:"+result.start(0)+" e:"+result.end(0) : "-";
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.currentTechName+prop).html(result);
$("#"+this.techName+prop).html(result);
}));
}), 500);
Ver Arquivo

Antes

Largura:  |  Altura:  |  Tamanho: 85 KiB

Depois

Largura:  |  Altura:  |  Tamanho: 85 KiB

Arquivo binário não exibido.

Depois

Largura:  |  Altura:  |  Tamanho: 3.5 KiB

+160 -62
Ver Arquivo
@@ -1,4 +1,4 @@
/*
/*
VideoJS Default Styles (http://videojs.com)
Version 3.0
@@ -11,17 +11,22 @@ REQUIRED STYLES (be careful overriding)
** 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;
.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 {
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 */
}
@@ -29,11 +34,23 @@ body.vjs-full-window {
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;
}
/* Subtiles Style */
/* 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)
/* 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. */
@@ -43,7 +60,8 @@ so you can upgrade to newer versions easier. You can remove all these styles by
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: block; /* Start hidden */
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;
@@ -52,7 +70,7 @@ so you can upgrade to newer versions easier. You can remove all these styles by
/* 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, left top, left bottom, color-stop(50%,#242424), color-stop(50%,#1f1f1f), color-stop(100%,#171717)); /* Chrome,Safari4+ */
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+ */
@@ -105,33 +123,33 @@ so you can upgrade to newer versions easier. You can remove all these styles by
.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; background: #666; cursor: pointer !important;
.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: #333;
background: -moz-linear-gradient(top, #333 0%, #666 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#333), color-stop(100%,#666));
background: -webkit-linear-gradient(top, #333 0%,#666 100%);
background: -o-linear-gradient(top, #333 0%,#666 100%);
background: -ms-linear-gradient(top, #333 0%,#666 100%);
background: linear-gradient(top, #333 0%,#666 100%);
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; background: #fff;
.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: #ffffff;
background: -moz-linear-gradient(top, #ffffff 0%, #cccccc 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#ffffff), color-stop(100%,#cccccc));
background: -webkit-linear-gradient(top, #ffffff 0%,#cccccc 100%);
background: -o-linear-gradient(top, #ffffff 0%,#cccccc 100%);
background: -ms-linear-gradient(top, #ffffff 0%,#cccccc 100%);
background: linear-gradient(top, #ffffff 0%,#cccccc 100%);
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 {
.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;
@@ -149,12 +167,13 @@ so you can upgrade to newer versions easier. You can remove all these styles by
/* CSS Gradient */
background: #333;
background: -moz-linear-gradient(top, #333 0%, #222 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#222), color-stop(100%,#333));
background: -webkit-linear-gradient(top, #222 0%,#333 100%);
background: -o-linear-gradient(top, #333 0%,#222 100%);
background: -ms-linear-gradient(top, #333 0%,#222 100%);
background: linear-gradient(top, #333 0%,#222 100%);
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);*/
@@ -169,12 +188,12 @@ so you can upgrade to newer versions easier. You can remove all these styles by
/* CSS Gradient */
background: #111;
background: -moz-linear-gradient(top, #111 0%, #262626 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#111), color-stop(100%,#262626));
background: -webkit-linear-gradient(top, #111 0%,#262626 100%);
background: -o-linear-gradient(top, #111 0%,#262626 100%);
background: -ms-linear-gradient(top, #111 0%,#262626 100%);
background: linear-gradient(top, #111 0%,#262626 100%);
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 */
@@ -186,18 +205,18 @@ so you can upgrade to newer versions easier. You can remove all these styles by
}
.vjs-default-skin .vjs-play-progress {
/* CSS Gradient. */
/* CSS Gradient. */
background: #fff; /* Old browsers */
background: -moz-linear-gradient(top, #fff 0%, #d6d6d6 50%, #fff 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#fff), color-stop(50%,#d6d6d6), color-stop(100%,#fff));
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, left top, left bottom, color-stop(0%,#efefef), color-stop(50%,#f5f5f5), color-stop(50%,#dbdbdb), color-stop(100%,#f1f1f1));
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%);
@@ -209,25 +228,25 @@ so you can upgrade to newer versions easier. You can remove all these styles by
/* CSS Gradient */
background: #666;
background: -moz-linear-gradient(top, #666 0%, #333 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#666), color-stop(100%,#333));
background: -webkit-linear-gradient(top, #666 0%,#333 100%);
background: -o-linear-gradient(top, #666 0%,#333 100%);
background: -ms-linear-gradient(top, #666 0%,#333 100%);
background: linear-gradient(top, #666 0%,#333 100%);
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;
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') 0px -50px;
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: 0px 2px 4px 0px #000; -moz-box-shadow: 0px 2px 4px 0px #000; box-shadow: 0px 2px 4px 0px #000;
-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
-------------------------------------------------------------------------------- */
@@ -241,14 +260,14 @@ so you can upgrade to newer versions easier. You can remove all these styles by
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 0%, #333 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#222), color-stop(100%,#333));
background: -webkit-linear-gradient(top, #222 0%,#333 100%);
background: -o-linear-gradient(top, #333 0%,#222 100%);
background: -ms-linear-gradient(top, #333 0%,#222 100%);
background: linear-gradient(top, #333 0%,#222 100%);
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);*/
@@ -284,7 +303,7 @@ so you can upgrade to newer versions easier. You can remove all these styles by
background: #454545;
background: -moz-linear-gradient(top, #454545 0%, #232323 50%, #161616 50%, #3f3f3f 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#454545), color-stop(50%,#232323), color-stop(50%,#161616), color-stop(100%,#3f3f3f));
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%);
@@ -296,7 +315,7 @@ so you can upgrade to newer versions easier. You can remove all these styles by
}
.vjs-default-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;
-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 {
@@ -304,4 +323,83 @@ so you can upgrade to newer versions easier. You can remove all these styles by
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; }

Antes

Largura:  |  Altura:  |  Tamanho: 7.3 KiB

Depois

Largura:  |  Altura:  |  Tamanho: 7.3 KiB

+53
Ver Arquivo
@@ -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>
+17
Ver Arquivo
@@ -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
-36
Ver Arquivo
@@ -1,36 +0,0 @@
#! /bin/csh
# Combines Source Files. In terminal, sh combine_sources.sh
# It will put a new video.js file under dist/
cat ../src/_begin.js > ../dist/video.js
cat ../src/core.js >> ../dist/video.js
cat ../src/api.js >> ../dist/video.js
cat ../src/lib.js >> ../dist/video.js
cat ../src/log.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/tracks.js >> ../dist/video.js
cat ../src/tech/html5.js >> ../dist/video.js
cat ../src/tech/flowplayer.js >> ../dist/video.js
# h5swf temporarily requires swfobject
cat ../src/tech/h5swf.js >> ../dist/video.js
cat ../flash/swfobject.js >> ../dist/video.js
cat ../src/behaviors/behaviors.js >> ../dist/video.js
cat ../src/behaviors/seekBar.js >> ../dist/video.js
cat ../src/behaviors/texttrackdisplays.js >> ../dist/video.js
cat ../src/behaviors/volume.js >> ../dist/video.js
cat ../src/controls/bar.js >> ../dist/video.js
cat ../src/controls/bigPlay.js >> ../dist/video.js
cat ../src/controls/subtitlesBox.js >> ../dist/video.js
cat ../src/autoload.js >> ../dist/video.js
cat ../src/_end.js >> ../dist/video.js
-6
Ver Arquivo
@@ -1,6 +0,0 @@
body { font-size: 11px; font-family: 'Helvetica Neue', helvetica, arial; }
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; }
-102
Ver Arquivo
@@ -1,102 +0,0 @@
<!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" type="text/javascript" charset="utf-8"></script>
<script src="../src/lib.js" type="text/javascript" charset="utf-8"></script>
<script src="../src/ecma.js" type="text/javascript" charset="utf-8"></script>
<script src="../src/json.js" type="text/javascript" charset="utf-8"></script>
<script src="../src/api.js" type="text/javascript" charset="utf-8"></script>
<script src="../src/events.js" type="text/javascript" charset="utf-8"></script>
<script src="../src/tracks.js" type="text/javascript" charset="utf-8"></script>
<script src="../src/behaviors/behaviors.js" type="text/javascript" charset="utf-8"></script>
<script src="../src/behaviors/seekBar.js" type="text/javascript" charset="utf-8"></script>
<script src="../src/behaviors/volume.js" type="text/javascript" charset="utf-8"></script>
<script src="../src/behaviors/texttrackdisplays.js" type="text/javascript" charset="utf-8"></script>
<script src="../src/controls/bigPlay.js" type="text/javascript" charset="utf-8"></script>
<script src="../src/controls/bar.js" type="text/javascript" charset="utf-8"></script>
<script src="../src/controls/subtitlesBox.js" type="text/javascript" charset="utf-8"></script>
<script src="../src/tech/html5.js" type="text/javascript" charset="utf-8"></script>
<script src="../src/tech/flowplayer.js" type="text/javascript" charset="utf-8"></script>
<script src="../src/autoload.js" type="text/javascript" charset="utf-8"></script>
<script src="../src/log.js" type="text/javascript" charset="utf-8"></script>
<script src="../src/tech/h5swf.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script type="text/javascript" src="../flash/swfobject.js"></script>
<link rel="stylesheet" href="compare.css" type="text/css">
<script type="text/javascript" src="compare.js"></script>
</head>
<body>
<table border="0" cellspacing="5" cellpadding="5">
<tr><th colspan="2">HTML5</th><th colspan="2">H5Swf</th><th colspan="2">Flowplayer</th></tr>
<tr>
<td colspan="2">
<video id="vid1" class="video-js vjs-default-skin" preload="auto" width="480" height="198">
<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" preload="auto" width="480" height="198">
<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="vid3" class="video-js vjs-default-skin" preload="auto" width="480" height="198">
<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="h5swf_props" border="0" cellspacing="0" cellpadding="0"></table>
</td>
<td class="info-col">
<div id="h5swf_events"></div>
</td>
<td class="info-col">
<table id="flowplayer_props" border="0" cellspacing="0" cellpadding="0"></table>
</td>
<td class="info-col">
<div id="flowplayer_events"></div>
</td>
</tr>
</table>
</body>
</html>
-62
Ver Arquivo
@@ -1,62 +0,0 @@
<!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="dist/video.js"></script> -->
<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/log.js"></script>
<script src="src/api.js"></script>
<script src="src/events.js"></script>
<script src="src/tracks.js"></script>
<script src="src/behaviors/behaviors.js"></script>
<script src="src/behaviors/seekBar.js"></script>
<script src="src/behaviors/volume.js"></script>
<script src="src/behaviors/texttrackdisplays.js"></script>
<script src="src/controls/bigPlay.js"></script>
<script src="src/controls/bar.js"></script>
<script src="src/controls/subtitlesBox.js"></script>
<script src="src/tech/html5.js"></script>
<script src="src/tech/flowplayer.js"></script>
<script src="src/tech/h5swf.js"></script>
<script src="src/autoload.js"></script>
<script type="text/javascript" src="flash/swfobject.js"></script>
</head>
<body>
<video id="vid1" class="video-js vjs-default-skin" controls preload="none" width="640" height="264" data-setup='{"example_option":true}' poster="http://video-js.zencoder.com/oceans-clip.png">
<!-- <source src="http://pseudo01.hddn.com/vod/demo.flowplayervod/flowplayer-700.flv" type='video/flv'> -->
<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://stg.video.howcookingworks.com/video/posts/e110d95f6770c62e8d3ba52ff221e7f7907683ac266939/e110d95f6770c62e8d3ba52ff221e7f7907683ac266939_high.webm" type='video/webm'> -->
<source src="http://video-js.zencoder.com/oceans-clip.ogv" type='video/ogg; codecs="theora, vorbis"'>
<!-- <track kind="subtitles" src="http://videojs.com/subtitles/demo-subtitles.srt" srclang="en-US" label="English"></track> -->
<!-- <track kind="subtitles" src="demo-subtitles.srt" srclang="en-US" label="English"></track> -->
</video>
<script>
// vid = document.getElementById("vid2");
</script>
</body>
</html>
Arquivo binário não exibido.
Diff do arquivo suprimido porque uma ou mais linhas são muito longas
Ver Arquivo
+13
Ver Arquivo
@@ -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')
-4
Ver Arquivo
@@ -1,4 +0,0 @@
// Self-executing function to prevent global vars and help with minification
;(function(window, undefined){
var document = window.document;
-294
Ver Arquivo
@@ -1,294 +0,0 @@
/* Player API
================================================================================ */
VideoJS.fn.extend({
apiCall: function(method, arg){
if (this.isReady) {
if (this.api[method]) {
return this.api[method].call(this, arg);
} else {
throw new Error("The '"+method+"' method is not available on the playback technology's API");
}
} else {
throw new Error("The playback technology API is not ready yet. Use player.ready(myFunction).");
}
},
/* Listener types: play, pause, timeupdate, bufferedupdate, ended, volumechange, error */
addEvent: function(type, fn){
return _V_.addEvent(this.box, type, _V_.proxy(this, fn));
},
removeEvent: function(type, fn){
return _V_.removeEvent(this.box, type, fn);
},
triggerEvent: function(type, e){
return _V_.triggerEvent(this.box, type, e);
},
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) {
this.values.currentTime = seconds; // Cache the last set value for smoother scrubbing.
this.apiCall("setCurrentTime", seconds);
if (this.manualTimeUpdates) { this.triggerEvent("timeupdate"); }
return this;
}
return 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);
this.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.box.width = width;
this.box.style.width = width+"px";
if (!skipListeners) { this.triggerEvent("resize"); }
return this;
}
return parseInt(this.box.getAttribute("width"));
},
height: function(height){
if (height !== undefined) {
this.box.height = height;
this.box.style.height = height+"px";
this.triggerEvent("resize");
return this;
}
return parseInt(this.box.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
enterFullScreen: function(){
if (false && this.supportsFullScreen()) {
this.api("enterFullScreen");
} else {
this.enterFullWindow();
}
this.triggerEvent("enterFullScreen");
return this;
},
exitFullScreen: function(){
if (true || !this.supportsFullScreen()) {
this.exitFullWindow();
}
this.triggerEvent("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_.addEvent(document, "keydown", _V_.proxy(this, this.fullscreenOnEscKey));
// Add listener for a window resize
_V_.addEvent(window, "resize", _V_.proxy(this, this.fullscreenOnWindowResize));
// Hide any scroll bars
document.documentElement.style.overflow = 'hidden';
// Apply fullscreen styles
_V_.addClass(document.body, "vjs-full-window");
_V_.addClass(this.box, "vjs-fullscreen");
this.triggerEvent("enterFullWindow");
},
exitFullWindow: function(){
this.videoIsFullScreen = false;
_V_.removeEvent(document, "keydown", this.fullscreenOnEscKey);
_V_.removeEvent(window, "resize", this.fullscreenOnWindowResize);
// Unhide scroll bars.
document.documentElement.style.overflow = this.docOrigOverflow;
// Remove fullscreen styles
_V_.removeClass(document.body, "vjs-full-window");
_V_.removeClass(this.box, "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) {
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_.tech[techName];
// Check if the browser supports this technology
if (tech.supported()) {
// Loop through each source object
for (var a=0,b=this.options.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) {
this.src(source.src);
// Case: URL String (http://myvideo...)
} else {
this.apiCall("src", source);
this.load();
}
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; },
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"); }
});
-37
Ver Arquivo
@@ -1,37 +0,0 @@
_V_.loadPlayers = function(){
var vids = document.getElementsByTagName("video"),
options, vid;
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) {
// Check if this video has already been set up by video.js.
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.
VideoJS.players[vid.id] = new VideoJS(vid, options);
}
}
// If getAttribute isn't defined, we need to wait for the DOM.
} else {
_V_.loadPlayerTimeout(1);
break;
}
}
} else {
_V_.loadPlayerTimeout(1);
}
};
_V_.loadPlayerTimeout = function(wait){
setTimeout(_V_.loadPlayers, wait);
};
_V_.loadPlayerTimeout(1); // Let vjs javascript finish executing
-310
Ver Arquivo
@@ -1,310 +0,0 @@
/* Box Behaviors - The primary container element
================================================================================ */
VideoJS.fn.newBehavior("box",
function(element){
_V_.addClass(element, "vjs-paused");
this.addEvent("play", this.boxOnVideoPlay);
this.addEvent("pause", this.boxOnVideoPause);
},
function(){},
{
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");
}
}
);
/* Playback Technology Element Behaviors
================================================================================ */
VideoJS.fn.newBehavior("tech",
function(element){
_V_.addEvent(element, "click", _V_.proxy(this, this.onPlayToggleClick));
},
function(element){
_V_.removeEvent(element, "click", this.onPlayToggleClick);
},
{}
);
/* Control Bar Behaviors
================================================================================ */
VideoJS.fn.newBehavior("controlBar",
function(element){
if (!this.bels.controlBars) {
this.bels.controlBars = [];
// this.addEvent("mouseover", this.showControlBars);
// this.addEvent("mouseout", this.hideControlBars);
}
this.bels.controlBars.push(element);
},
function(element){},
{
showControlBars: function(){
this.each(this.bels.controlBars, function(bar){
bar.style.opacity = 1;
// bar.style.display = "block";
});
},
hideControlBars: function(){
this.each(this.bels.controlBars, function(bar){
bar.style.opacity = 0;
// bar.style.display = "none";
});
}
}
);
/* PlayToggle, PlayButton, PauseButton Behaviors
================================================================================ */
// Play Toggle
VideoJS.fn.newBehavior("playToggle", function(element){
if (!this.bels.playToggles) {
this.bels.playToggles = [];
this.addEvent("play", this.playTogglesOnPlay);
this.addEvent("pause", this.playTogglesOnPause);
}
this.bels.playToggles.push(element);
_V_.addEvent(element, "click", _V_.proxy(this, this.onPlayToggleClick));
_V_.addEvent(element, "focus", _V_.proxy(this, this.onPlayToggleFocus));
_V_.addEvent(element, "blur", _V_.proxy(this, this.onPlayToggleBlur));
},
function(){},
{
onPlayToggleClick: function(event){
if (this.paused()) {
this.play();
} else {
this.pause();
}
},
playTogglesOnPlay: function(event){
this.each(this.bels.playToggles, function(toggle){
_V_.removeClass(toggle, "vjs-paused");
_V_.addClass(toggle, "vjs-playing");
});
},
playTogglesOnPause: function(event){
this.each(this.bels.playToggles, function(toggle){
_V_.removeClass(toggle, "vjs-playing");
_V_.addClass(toggle, "vjs-paused");
});
},
onPlayToggleFocus: function(event){
_V_.addEvent(document, "keyup", _V_.proxy(this, this.onPlayToggleKey));
},
onPlayToggleKey: function(event){
if (event.which == 32 || event.which == 13) {
event.preventDefault();
this.onPlayToggleClick();
}
},
onPlayToggleBlur: function(event){
_V_.removeEvent(document, "keyup", _V_.proxy(this, this.onPlayToggleKey));
}
}
);
// Play
VideoJS.fn.newBehavior("playButton", function(element){
_V_.addEvent(element, "click", _V_.proxy(this, this.onPlayButtonClick));
},
function(){},
{
onPlayButtonClick: function(event){ this.play(); }
}
);
// Pause
VideoJS.fn.newBehavior("pauseButton", function(element){
_V_.addEvent(element, "click", _V_.proxy(this, this.onPauseButtonClick));
},
function(){},
{
onPauseButtonClick: function(event){ this.pause(); }
}
);
/* Current Time Display Behaviors
================================================================================ */
VideoJS.fn.newBehavior("currentTimeDisplay", function(element){
if (!this.bels.currentTimeDisplays) {
this.bels.currentTimeDisplays = [];
this.addEvent("timeupdate", this.updateCurrentTimeDisplays);
}
this.bels.currentTimeDisplays.push(element);
},
function(){},
{
// 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.bels.currentTimeDisplays, function(dis){
dis.innerHTML = _V_.formatTime(time, this.duration());
});
}
}
);
/* Duration Display Behaviors
================================================================================ */
VideoJS.fn.newBehavior("durationDisplay", function(element){
if (!this.bels.durationDisplays) {
this.bels.durationDisplays = [];
this.addEvent("timeupdate", this.updateDurationDisplays);
}
this.bels.durationDisplays.push(element);
},
function(){},
{
updateDurationDisplays: function(){
this.each(this.bels.durationDisplays, function(dis){
if (this.duration()) { dis.innerHTML = _V_.formatTime(this.duration()); }
});
}
}
);
/* Duration Display Behaviors
================================================================================ */
VideoJS.fn.newBehavior("remainingTimeDisplay", function(element){
if (!this.bels.remainingTimeDisplays) {
this.bels.remainingTimeDisplays = [];
this.addEvent("timeupdate", this.updateRemainingTimeDisplays);
}
this.bels.remainingTimeDisplays.push(element);
},
function(){},
{
updateRemainingTimeDisplays: function(){
this.each(this.bels.remainingTimeDisplays, function(dis){
if (this.duration()) { dis.innerHTML = "-"+_V_.formatTime(this.remainingTime()); }
});
}
}
);
/* Time Left (remaining) Display Behaviors
================================================================================ */
VideoJS.fn.newBehavior("timeLeftDisplay", function(element){
if (!this.bels.timeLeftDisplays) {
this.bels.timeLeftDisplays = [];
this.addEvent("timeupdate", this.updateTimeLeftDisplays);
}
this.bels.timeLeftDisplays.push(element);
},
function(){
this.removeEvent("timeupdate", this.updateTimeLeftDisplays);
delete this.bels.timeLeftDisplays;
},
{
updateTimeLeftDisplays: function(){
// Allows for smooth scrubbing, when player can't keep up.
var time = (this.scrubbing) ? this.values.currentTime : this.currentTime();
this.each(this.bels.timeLeftDisplays, function(dis){
dis.innerHTML = "-" + _V_.formatTime(this.duration() - time);
});
}
}
);
/* Volume Scrubber Behaviors
================================================================================ */
VideoJS.fn.newBehavior("volumeScrubber", function(element){
// Binding with element as 'this' so the progress holder element can be retrieved in IE.
// IE doesn't support the currentTarget event attr.
var player = this;
_V_.addEvent(element, "mousedown", _V_.proxy(element, function(e){
player.onVolumeScrubberMouseDown(e, this);
}));
},
function(){},
{
// 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_.addEvent(document, "mousemove", _V_.proxy(this, this.onVolumeScrubberMouseMove));
_V_.addEvent(document, "mouseup", _V_.proxy(this, this.onVolumeScrubberMouseUp));
},
onVolumeScrubberMouseMove: function(event){
this.setVolumeWithScrubber(event);
},
onVolumeScrubberMouseUp: function(event){
this.setVolumeWithScrubber(event);
_V_.unblockTextSelection();
_V_.removeEvent(document, "mousemove", this.onVolumeScrubberMouseMove, false);
_V_.removeEvent(document, "mouseup", this.onVolumeScrubberMouseUp, false);
},
setVolumeWithScrubber: function(event){
var newVol = _V_.getRelativePosition(event.pageX, this.currentScrubber);
this.volume(newVol);
}
}
);
/* Volume Display Behaviors
================================================================================ */
VideoJS.fn.newBehavior("volumeDisplay", function(element){
if (!this.bels.volumeDisplays) {
this.bels.volumeDisplays = [];
this.addEvent("volumechange", this.updateVolumeDisplays);
}
this.bels.volumeDisplays.push(element);
this.updateVolumeDisplay(element); // Set the display to the initial volume
},
function(){},
{
// Update the volume control display
// Unique to these default controls. Uses borders to create the look of bars.
updateVolumeDisplays: function(){
if (!this.bels.volumeDisplays) { return; }
this.each(this.bels.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");
}
});
}
}
);
/* Fullscreen Toggle Behaviors
================================================================================ */
VideoJS.fn.newBehavior("fullscreenToggle", function(element){
_V_.addEvent(element, "click", _V_.proxy(this, this.onFullscreenToggleClick));
},
function(){},
{
// 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();
}
}
}
);
-213
Ver Arquivo
@@ -1,213 +0,0 @@
/* Seek Bar Behaviors (Current Time Scrubber)
================================================================================ */
VideoJS.fn.newBehavior("seekBar",
function(element){
if (!this.bels.seekBars) {
this.bels.seekBars = [];
this.addEvent("timeupdate", this.updateSeekBars);
}
this.bels.seekBars.push(element);
// Get and store related child objects (progress bar & handle)
var data = _V_.getData(element);
this.each(element.childNodes, function(c){
if (c.className) {
if (c.className.indexOf("seek-handle") != -1) {
data.seekHandle = c;
} else if (c.className.indexOf("play-progress") != -1) {
data.playProgress = c;
}
}
});
// Binding with element as 'this' so the progress holder element can be retrieved in IE.
// IE doesn't support the currentTarget event attr.
var player = this;
_V_.addEvent(element, "mousedown", _V_.proxy(element, function(event){
player.onSeekBarMouseDown(event, this);
}));
_V_.addEvent(element, "focus", _V_.proxy(this, this.onSeekBarFocus));
_V_.addEvent(element, "blur", _V_.proxy(this, this.onSeekBarBlur));
},
function(){},
{
// Adjust the play position when the user drags on the progress bar
onSeekBarMouseDown: function(event, currentTarget){
event.preventDefault();
_V_.blockTextSelection();
this.currSeekBar = currentTarget;
this.currHandle = _V_.getData(currentTarget).seekHandle || false;
this.scrubbing = true;
this.videoWasPlaying = !this.paused();
this.pause();
this.setCurrentTimeWithScrubber(event);
_V_.addEvent(document, "mousemove", _V_.proxy(this, this.onSeekBarMouseMove));
_V_.addEvent(document, "mouseup", _V_.proxy(this, this.onSeekBarMouseUp));
},
onSeekBarMouseMove: function(event){ // Removeable
this.setCurrentTimeWithScrubber(event);
},
onSeekBarMouseUp: function(event){ // Removeable
_V_.unblockTextSelection();
_V_.removeEvent(document, "mousemove", this.onSeekBarMouseMove, false);
_V_.removeEvent(document, "mouseup", this.onSeekBarMouseUp, false);
this.scrubbing = false;
if (this.videoWasPlaying) {
this.play();
}
},
setCurrentTimeWithScrubber: function(event){
var bar = this.currSeekBar,
barX = _V_.findPosX(bar),
barW = bar.offsetWidth,
handle = this.currHandle,
handleW = (handle) ? handle.offsetWidth : 0;
// Adjusted X and Width, so handle doesn't go outside the bar
barAX = barX + (handleW / 2),
barAW = barW - handleW,
// Percent that the click is through the adjusted area
percent = Math.max(0, Math.min(1, (event.pageX - barAX) / barAW)),
// Percent translated to pixels
percentPix = percent * barAW,
// Percent translated to seconds
newTime = percent * this.duration();
// Don't let video end while scrubbing.
if (newTime == this.duration()) { newTime = newTime - 0.1; }
// Set new time (tell player to seek to new time)
this.currentTime(newTime);
},
getSeekBarAdjustedWidth: function(bar, handle){
var bar = this.currSeekBar,
barX = _V_.findPosX(bar),
barW = bar.offsetWidth,
handle = this.currHandle,
handleW = (handle) ? handle.offsetWidth : 0;
// Adjusted X and Width, so handle doesn't go outside the bar
barAX = barX + (handleW / 2),
barAW = barW - handleW;
},
updateSeekBars: function(){
// If scrubbing, use the cached currentTime value for speed
var progress = /* (this.scrubbing) ? this.scrubTime / this.duration() : */ this.currentTime() / this.duration();
// Protect against no duration and other division issues
if (isNaN(progress)) { progress = 0; }
this.each(this.bels.seekBars, function(bar){
var barData = _V_.getData(bar),
barX = _V_.findPosX(bar),
barW = bar.offsetWidth,
handle = barData.seekHandle,
progBar = barData.playProgress,
handleW = (handle) ? handle.offsetWidth : 0;
// Adjusted X and Width, so handle doesn't go outside the bar
barAX = barX + (handleW / 2),
barAW = barW - handleW;
// Percent that the click is through the adjusted area
// percent = Math.max(0, Math.min(1, (event.pageX - barAX) / barAW)),
// Percent translated to pixels
// percentPix = percent * barAW,
// Percent translated to seconds
// newTime = percent * this.duration();
progBarProgress = _V_.round(progress * barAW + handleW / 2) + "px";
if (progBar && progBar.style) { progBar.style.width = progBarProgress; }
handle.style.left = _V_.round(progress * barAW)+"px";
});
// Update bar length
// this.each(this.bels.playProgressBars, function(bar){
// if (bar.style) { bar.style.width = _V_.round(progress * 100, 2) + "%"; }
// });
// Move Handle
},
onSeekBarFocus: function(event){
_V_.addEvent(document, "keyup", _V_.proxy(this, this.onSeekBarKey));
},
onSeekBarKey: function(event){
if (event.which == 37) {
event.preventDefault();
this.currentTime(this.currentTime() - 1);
} else if (event.which == 39) {
event.preventDefault();
this.currentTime(this.currentTime() + 1);
}
},
onSeekBarBlur: function(event){
_V_.removeEvent(document, "keyup", _V_.proxy(this, this.onSeekBarKey));
}
}
);
/* Seek Handle Behaviors
================================================================================ */
VideoJS.fn.newBehavior("seekHandle",
function(element){
if (!this.bels.seekHandles) { this.bels.seekHandles = []; }
this.bels.seekHandles.push(element);
// Store references between seekbar and seekhandle
_V_.getData(element).seekBar = element.parentNode;
_V_.getData(element.parentNode).seekHandle = element;
},
function(){},
{}
);
/* Play Progress Bar Behaviors
================================================================================ */
VideoJS.fn.newBehavior("playProgressBar",
function(element){
if (!this.bels.playProgressBars) {
this.bels.playProgressBars = [];
this.addEvent("timeupdate", this.updatePlayProgressBars);
}
this.bels.playProgressBars.push(element);
},
function(){
// Remove
},
{
// Ajust the play progress bar's width based on the current play time
updatePlayProgressBars: function(){
// If scrubbing, use the cached currentTime value for speed
var progress = (this.scrubbing) ? this.values.currentTime / this.duration() : this.currentTime() / this.duration();
// Protect against no duration and other division issues
if (isNaN(progress)) { progress = 0; }
// Update bar length
this.each(this.bels.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.bels.loadProgressBars) { this.bels.loadProgressBars = []; }
this.bels.loadProgressBars.push(element);
this.addEvent("progress", this.updateLoadProgressBars);
},
function(){},
{
updateLoadProgressBars: function(event){
// log("updating progress bars", this.bufferedPercent());
this.each(this.bels.loadProgressBars, function(bar){
if (bar.style) { bar.style.width = _V_.round(this.bufferedPercent() * 100, 2) + "%"; }
});
}
}
);
-43
Ver Arquivo
@@ -1,43 +0,0 @@
/* 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.
_V_.each(["subtitles", "captions", "chapters", "descriptions"], function(type){
var add, remove,
name = type+"Display",
plural = name+"s",
updateFuncName = "update"+plural,
funcs = {};
// Add the behavior to an element
add = function(element){
if (!this.bels[plural]) {
this.bels[plural] = [];
this.addEvent(type+"update", this[updateFuncName]);
}
this.bels[plural].push(element);
};
// Remove the behavior from an element
remove = function(element){
if (this.bels[plural]) {
_V_.remove(element, this.bels[plural]);
if (this.bels[plural].length == 0) {
this.removeEvent(type+"update", this[updateFuncName]);
delete this.bels[plural];
}
}
};
// Addional needed funcitons (added directly to player)
funcs[updateFuncName] = function(){
var val = this.textTrackValue(type);
this.each(this.bels[plural], function(display){
display.innerHTML = val;
});
};
VideoJS.fn.newBehavior(name, add, remove, funcs);
});
-177
Ver Arquivo
@@ -1,177 +0,0 @@
/* Volume Behaviors
================================================================================ */
/* Seek Bar Behaviors (Current Time Scrubber)
================================================================================ */
VideoJS.fn.newBehavior("volumeBar",
function(element){
if (!this.bels.volumeBars) {
this.bels.volumeBars = [];
this.addEvent("volumechange", this.updateVolumeBars);
}
this.bels.volumeBars.push(element);
// Get and store related child objects (level & handle)
var data = _V_.getData(element);
this.each(element.childNodes, function(c){
if (c.className) {
if (c.className.indexOf("volume-handle") != -1) {
data.volumeHandle = c;
} else if (c.className.indexOf("volume-level") != -1) {
data.volumeLevel = c;
}
}
});
// Binding with element as 'this' so the holder element can be retrieved in IE.
// IE doesn't support the currentTarget event attr.
var player = this;
_V_.addEvent(element, "mousedown", _V_.proxy(element, function(event){
player.onVolumeBarMouseDown(event, this);
}));
// _V_.addEvent(element, "focus", _V_.proxy(this, this.onVolumeBarFocus));
// _V_.addEvent(element, "blur", _V_.proxy(this, this.onVolumeBarBlur));
},
function(){},
{
// Adjust the play position when the user drags on the progress bar
onVolumeBarMouseDown: function(event, currentTarget){
event.preventDefault();
_V_.blockTextSelection();
this.currVolumeBar = currentTarget;
this.currHandle = _V_.getData(currentTarget).volumeHandle || false;
this.setVolumeWithSlider(event);
_V_.addEvent(document, "mousemove", _V_.proxy(this, this.onVolumeBarMouseMove));
_V_.addEvent(document, "mouseup", _V_.proxy(this, this.onVolumeBarMouseUp));
},
onVolumeBarMouseMove: function(event){ // Removeable
this.setVolumeWithSlider(event);
},
onVolumeBarMouseUp: function(event){ // Removeable
_V_.unblockTextSelection();
_V_.removeEvent(document, "mousemove", this.onVolumeBarMouseMove, false);
_V_.removeEvent(document, "mouseup", this.onVolumeBarMouseUp, false);
},
setVolumeWithSlider: function(event){
var bar = this.currVolumeBar,
barX = _V_.findPosX(bar),
barW = bar.offsetWidth,
handle = this.currHandle,
handleW = (handle) ? handle.offsetWidth : 0;
// Adjusted X and Width, so handle doesn't go outside the bar
barAX = barX + (handleW / 2),
barAW = barW - handleW,
// Percent that the click is through the adjusted area
percent = Math.max(0, Math.min(1, (event.pageX - barAX) / barAW)),
// Percent translated to pixels
percentPix = percent * barAW,
// Percent translated to seconds
newTime = percent * this.duration();
this.volume(percent);
},
updateVolumeBars: function(){
var vol = this.volume();
this.each(this.bels.volumeBars, function(bar){
var barData = _V_.getData(bar),
barX = _V_.findPosX(bar),
barW = bar.offsetWidth,
handle = barData.volumeHandle,
progBar = barData.volumeLevel,
handleW = (handle) ? handle.offsetWidth : 0;
// Adjusted X and Width, so handle doesn't go outside the bar
barAX = barX + (handleW / 2),
barAW = barW - handleW;
// Percent that the click is through the adjusted area
// percent = Math.max(0, Math.min(1, (event.pageX - barAX) / barAW)),
// Percent translated to pixels
// percentPix = percent * barAW,
// Percent translated to seconds
// newTime = percent * this.duration();
progBarProgress = _V_.round(vol * barAW + handleW / 2) + "px";
if (progBar && progBar.style) { progBar.style.width = progBarProgress; }
handle.style.left = _V_.round(vol * barAW)+"px";
});
// Update bar length
// this.each(this.bels.playProgressBars, function(bar){
// if (bar.style) { bar.style.width = _V_.round(progress * 100, 2) + "%"; }
// });
// Move Handle
}// ,
// onVolumeBarFocus: function(event){
// _V_.addEvent(document, "keyup", _V_.proxy(this, this.onVolumeBarKey));
// },
// onVolumeBarKey: function(event){
// if (event.which == 37) {
// event.preventDefault();
// this.currentTime(this.currentTime() - 1);
// } else if (event.which == 39) {
// event.preventDefault();
// this.currentTime(this.currentTime() + 1);
// }
// },
// onVolumeBarBlur: function(event){
// _V_.removeEvent(document, "keyup", _V_.proxy(this, this.onVolumeBarKey));
// }
}
);
/* Mute Toggle
================================================================================ */
VideoJS.fn.newBehavior("muteToggle", function(element){
if (!this.bels.muteToggles) {
this.bels.muteToggles = [];
this.addEvent("volumechange", this.muteTogglesOnVolumeChange);
}
this.bels.muteToggles.push(element);
_V_.addEvent(element, "click", _V_.proxy(this, this.onMuteToggleClick));
// _V_.addEvent(element, "focus", _V_.proxy(this, this.onMuteToggleFocus));
// _V_.addEvent(element, "blur", _V_.proxy(this, this.onMuteToggleBlur));
},
function(){},
{
onMuteToggleClick: function(event){
this.muted( this.muted() ? false : true );
},
muteTogglesOnVolumeChange: function(event){
var vol = this.volume(),
level = 3;
if (vol == 0 || this.muted()) {
level = 0;
} else if (vol < 0.33) {
level = 1;
} else if (vol < 0.67) {
level = 2;
}
this.each(this.bels.muteToggles, function(toggle){
/* TODO improve muted icon classes */
_V_.each([0,1,2,3], function(i){
_V_.removeClass(toggle, "vjs-vol-"+i);
});
_V_.addClass(toggle, "vjs-vol-"+level);
});
}//,
// onMuteToggleFocus: function(event){
// _V_.addEvent(document, "keyup", _V_.proxy(this, this.onMuteToggleKey));
// },
// onMuteToggleKey: function(event){
// if (event.which == 32 || event.which == 13) {
// event.preventDefault();
// this.onMuteToggleClick();
// }
// },
// onMuteToggleBlur: function(event){
// _V_.removeEvent(document, "keyup", _V_.proxy(this, this.onMuteToggleKey));
// }
}
);
-153
Ver Arquivo
@@ -1,153 +0,0 @@
_V_.controlSets.bar = {
options: {},
add: function(){
/* See controls/controls.html to see the HTML this creates. */
// Create a reference to the controls elements
var bar = this.cels.bar = {};
// Control Bar Main Div ("main")
bar.main = _V_.createElement("div", { className: "vjs-controls" });
// Add the controls to the video's container
this.box.appendChild(bar.main);
this.addBehavior(bar.main, "controlBar");
// Play Control
bar.playControl = _V_.createElement("div", {
className: "vjs-play-control vjs-control",
innerHTML: '<div><span class="vjs-control-text">Play</span></div>',
role: "button", tabIndex: 0
});
bar.main.appendChild(bar.playControl);
this.addBehavior(bar.playControl, "playToggle");
/* Time -------------------------------------------------------------- */
// Time Display
bar.currentTime = _V_.createElement("div", {
className: "vjs-current-time vjs-time-controls vjs-control"
});
bar.currentTimeDisplay = _V_.createElement("span", {
className: "vjs-current-time-display",
innerHTML: '0:00'
});
// Put display inside div, inside control div, to follow control scheme.
bar.currentTime.appendChild(_V_.createElement("div").appendChild(bar.currentTimeDisplay));
bar.main.appendChild(bar.currentTime);
this.addBehavior(bar.currentTimeDisplay, "currentTimeDisplay");
// Time Separator (Not used in main skin, but still available, and could be used as a 'spare element')
bar.timeDivider = _V_.createElement("div", {
className: "vjs-time-divider",
innerHTML: '<div><span>/</span></div>'
});
bar.main.appendChild(bar.timeDivider);
// Duration Display
bar.duration = _V_.createElement("div", {
className: "vjs-duration vjs-time-controls vjs-control"
});
bar.durationDisplay = _V_.createElement("span", {
className: "vjs-duration-display",
innerHTML: '0:00'
});
// Put display inside div, inside control div, to follow control scheme.
bar.duration.appendChild(_V_.createElement("div").appendChild(bar.durationDisplay));
bar.main.appendChild(bar.duration);
this.addBehavior(bar.durationDisplay, "durationDisplay");
// Duration Display
bar.remainingTime = _V_.createElement("div", {
className: "vjs-remaining-time vjs-time-controls vjs-control"
});
bar.remainingTimeDisplay = _V_.createElement("span", {
className: "vjs-remaining-time-display",
innerHTML: '-0:00'
});
// Put display inside div, inside control div, to follow control scheme.
bar.remainingTime.appendChild(_V_.createElement("div").appendChild(bar.remainingTimeDisplay));
bar.main.appendChild(bar.remainingTime);
this.addBehavior(bar.remainingTime, "remainingTimeDisplay");
/* Progress -------------------------------------------------------------- */
// Progress Control: Seek, Load Progress, and Play Progress
bar.progressControl = _V_.createElement("div", { className: "vjs-progress-control vjs-control" });
bar.main.appendChild(bar.progressControl);
// Seek Bar and holder for the progress bars
bar.seekBar = _V_.createElement("div", { className: "vjs-progress-holder" });
bar.progressControl.appendChild(bar.seekBar);
// Load Progress Bar
bar.loadProgressBar = _V_.createElement("div", {
className: "vjs-load-progress",
innerHTML: '<span class="vjs-control-text">Loaded: 0%</span>'
});
bar.seekBar.appendChild(bar.loadProgressBar);
this.addBehavior(bar.loadProgressBar, "loadProgressBar");
// Play Progress Bar
bar.playProgressBar = _V_.createElement("div", {
className: "vjs-play-progress",
innerHTML: '<span class="vjs-control-text">Progress: 0%</span>'
});
bar.seekBar.appendChild(bar.playProgressBar);
// Seek Handle
bar.seekHandle = _V_.createElement("div", {
className: "vjs-seek-handle",
innerHTML: '<span class="vjs-control-text">00:00</span>',
tabIndex: 0,
role: "slider", "aria-valuenow": 0, "aria-valuemin": 0, "aria-valuemax": 100
});
bar.seekBar.appendChild(bar.seekHandle);
// SeekBar Behavior includes play progress bar, and seek handle
// Needed so it can determine seek position based on handle position/size
this.addBehavior(bar.seekBar, "seekBar");
/* Fullscreen -------------------------------------------------------------- */
// Fullscreen Button
bar.fullscreenControl = _V_.createElement("div", {
className: "vjs-fullscreen-control vjs-control",
innerHTML: '<div><span class="vjs-control-text">Fullscreen</span></div>',
role: "button", tabIndex: 0
});
bar.main.appendChild(bar.fullscreenControl);
this.addBehavior(bar.fullscreenControl, "fullscreenToggle");
/* Volume -------------------------------------------------------------- */
// Fullscreen Button
bar.volumeControl = _V_.createElement("div", { className: "vjs-volume-control vjs-control" });
bar.volumeBar = _V_.createElement("div", { className: "vjs-volume-bar" });
bar.volumeLevel = _V_.createElement("div", {
className: "vjs-volume-level",
innerHTML: '<span class="vjs-control-text"></span>'
});
bar.volumeHandle = _V_.createElement("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
});
bar.volumeBar.appendChild(bar.volumeLevel);
bar.volumeBar.appendChild(bar.volumeHandle);
bar.volumeControl.appendChild(bar.volumeBar);
bar.main.appendChild(bar.volumeControl);
this.addBehavior(bar.volumeBar, "volumeBar");
// Mute Button
bar.muteControl = _V_.createElement("div", {
className: "vjs-mute-control vjs-control",
innerHTML: '<div><span class="vjs-control-text">Mute</span></div>',
role: "button", tabIndex: 0
});
bar.main.appendChild(bar.muteControl);
this.addBehavior(bar.muteControl, "muteToggle");
},
remove: function(){
this.box.removeChild(this.cels.bigPlayButton);
delete this.cels.bigPlayButton;
this.removeBehavior(this.cels.bigPlayButton, "bigPlayButton");
}
};
-52
Ver Arquivo
@@ -1,52 +0,0 @@
_V_.controlSets.bigPlayButton = {
options: {},
add: function(){
/* Creating this HTML
<div class="vjs-big-play-button"><span></span></div>
*/
this.cels.bigPlayButton = _V_.createElement("div", {
className: "vjs-big-play-button",
innerHTML: "<span></span>"
});
this.box.appendChild(this.cels.bigPlayButton);
this.addBehavior(this.cels.bigPlayButton, "bigPlayButton");
},
remove: function(){
this.removeBehavior(this.cels.bigPlayButton, "bigPlayButton");
this.box.removeChild(this.cels.bigPlayButton);
delete this.cels.bigPlayButton;
}
};
/* Big Play Button Behaviors
================================================================================ */
VideoJS.fn.newBehavior("bigPlayButton",
// Add Big Play Button Behavior
function(element){
if (!this.bels.bigPlayButtons) {
this.bels.bigPlayButtons = [];
this.addEvent("play", this.hideBigPlayButtons);
this.addEvent("ended", this.showBigPlayButtons);
}
this.bels.bigPlayButtons.push(element);
this.addBehavior(element, "playButton");
},
// Remove Big Play Button Behavior
function(element){
},
// Needed functions (added directly to player (this))
{
showBigPlayButtons: function(){
if (!this.options.controlsEnabled) { return; }
this.each(this.bels.bigPlayButtons, function(element){
element.style.display = "block";
});
},
hideBigPlayButtons: function(){
this.each(this.bels.bigPlayButtons, function(element){
element.style.display = "none";
});
}
}
);
-157
Ver Arquivo
@@ -1,157 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Controls HTML</title>
<link rel="stylesheet" href="../video-js.css" type="text/css">
</head>
<body>
<div class="video-js vjs-default-skin" style="width: 640px; height: 270px;">
<video id="vid1" class="" preload="none" width="640" height="264" data-setup="" poster="http://video-js.zencoder.com/oceans-clip.png">
<source src="http://pseudo01.hddn.com/vod/demo.flowplayervod/flowplayer-700.flv" type='video/flv'>
<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; codecs="vp8, vorbis"'>
<source src="http://video-js.zencoder.com/oceans-clip.ogv" type='video/ogg; codecs="theora, vorbis"'>
</video>
<div class="vjs-controls">
<!-- Play/Pause Button -->
<div class="vjs-play-control vjs-control" role="button" tabindex="0">
<div>
<span class="vjs-control-text">Play</span>
</div>
</div>
<!-- Current Time Display -->
<div class="vjs-current-time vjs-time-controls vjs-control">
<div>
<span class="vjs-current-time-display">00:00</span>
</div>
</div>
<!-- Optional Divider for Time -->
<div class="vjs-time-divider">
<div>
<span>/</span>
</div>
</div>
<!-- Duration Display -->
<div class="vjs-duration vjs-time-controls vjs-control">
<div>
<span class="vjs-duration-display">00:00</span>
</div>
</div>
<!-- Remaining Time Display -->
<div class="vjs-remaining-time vjs-time-controls vjs-control">
<div>
<span class="vjs-remaining-time-display">00:00</span>
</div>
</div>
<!-- Seek Slider and Load & Play Progress Bars -->
<div class="vjs-progress-control vjs-control" role="slider" tabindex="0" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100">
<!-- Seek Slider + Holds both progress bars. -->
<div class="vjs-progress-holder">
<!-- Load Progress -->
<div class="vjs-load-progress" title="Load Progress">
<span class="vjs-control-text">Loaded: 0%</span><!-- Support Multiple Load Progress Bars -->
</div>
<!-- Play Progress -->
<div class="vjs-play-progress" title="Play Progress">
<span class="vjs-control-text">Progress: 0%</span>
</div>
</div>
<!-- Seek Handle -->
<div class="vjs-seek-handle" title="Current Time">
<div>
<span class="vjs-control-text">00:00</span>
</div>
</div>
</div>
<!-- Fullscreen Control -->
<div class="vjs-fullscreen-control vjs-control" role="button" tabindex="0">
<div>
<span class="vjs-control-text">Fullscreen</span>
</div>
</div>
<!-- Volume Control -->
<div class="vjs-volume-control vjs-control">
<div class="vjs-volume-bar">
<!-- Volume Bar -->
<div class="vjs-volume-level">
<span class="vjs-control-text"></span>
</div>
<!-- Volume Handle -->
<div class="vjs-volume-handle" tabindex="0" role="slider" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100">
<span class="vjs-control-text"></span>
</div>
</div>
</div>
<!-- Mute Button -->
<div class="vjs-mute-control" role="button" tabindex="0">
<div>
<span class="vjs-control-text">Mute</span>
</div>
</div>
<!-- Rewind Button -->
<!-- <div class="vjs-rewind-control vjs-control" title="Rewind" role="button" tabindex="0">
<div>
<span class="vjs-control-text">Rewind</span>
</div>
</div> -->
<!-- Fast Forward Button -->
<!-- <div class="vjs-forward-control" title="Fast Forward" role="button" tabindex="0">
<div>
<span>Fast Forward</span>
</div>
</div> -->
<!-- Previous Video Button -->
<!-- <div class="vjs-previous-control" title="Previous Video" role="button" tabindex="0">
<div>
<span>Previous Video</span>
</div>
</div> -->
<!-- Next Video Button -->
<!-- <div class="vjs-next-control" title="Next Video" role="button" tabindex="0">
<div>
<span>Next Video</span>
</div>
</div> -->
<!-- Subtitles Button -->
<!-- <div class="vjs-subtitles-control" title="Subtitles On/Off" role="button" tabindex="0">
<div>
<span>Closed Captions</span>
</div>
</div> -->
<!-- Captions Button -->
<!-- <div class="vjs-captions-control" title="Captions On/Off" role="button" tabindex="0">
<div>
<span>Closed Captions</span>
</div>
</div> -->
</div>
</div>
</body>
</html>
-133
Ver Arquivo
@@ -1,133 +0,0 @@
_V_.controlSets.main = {
options: {},
add: 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>
*/
this.cels.main = {};
// Create a div to hold the different controls
this.cels.main.bar = _V_.createElement("div", { className: "vjs-controls" });
// Add the controls to the video's container
this.box.appendChild(this.cels.main.bar);
this.addBehavior(this.cels.main.bar, "controlBar");
// Build the play control
this.cels.main.playControl = _V_.createElement("div", { className: "vjs-play-control vjs-control", innerHTML: "<span></span>" });
this.cels.main.bar.appendChild(this.cels.main.playControl);
this.addBehavior(this.cels.main.playControl, "playToggle");
// Build the progress control
this.cels.main.progressControl = _V_.createElement("div", { className: "vjs-progress-control vjs-control" });
this.cels.main.bar.appendChild(this.cels.main.progressControl);
// Create a holder for the progress bars
this.cels.main.progressHolder = _V_.createElement("div", { className: "vjs-progress-holder" });
this.cels.main.progressControl.appendChild(this.cels.main.progressHolder);
this.addBehavior(this.cels.main.progressHolder, "seekBar");
// Create the loading progress display
this.cels.main.loadProgressBar = _V_.createElement("div", { className: "vjs-load-progress" });
this.cels.main.progressHolder.appendChild(this.cels.main.loadProgressBar);
this.addBehavior(this.cels.main.loadProgressBar, "loadProgressBar");
// Create the playing progress display
this.cels.main.playProgressBar = _V_.createElement("div", { className: "vjs-play-progress" });
this.cels.main.progressHolder.appendChild(this.cels.main.playProgressBar);
this.addBehavior(this.cels.main.playProgressBar, "playProgressBar");
// Create the progress time display (00:00 / 00:00)
this.cels.main.timeControl = _V_.createElement("div", { className: "vjs-time-control vjs-control" });
this.cels.main.bar.appendChild(this.cels.main.timeControl);
// // Create the current play time display
this.cels.main.currentTimeDisplay = _V_.createElement("span", { className: "vjs-current-time-display", innerHTML: "00:00" });
this.cels.main.timeControl.appendChild(this.cels.main.currentTimeDisplay);
this.addBehavior(this.cels.main.currentTimeDisplay, "currentTimeDisplay");
// Add time separator
this.cels.main.timeSeparator = _V_.createElement("span", { innerHTML: " / " });
this.cels.main.timeControl.appendChild(this.cels.main.timeSeparator);
// Create the total duration display
this.cels.main.durationDisplay = _V_.createElement("span", { className: "vjs-duration-display", innerHTML: "00:00" });
this.cels.main.timeControl.appendChild(this.cels.main.durationDisplay);
this.addBehavior(this.cels.main.durationDisplay, "durationDisplay");
// Create the volumne control
this.cels.main.volumeControl = _V_.createElement("div", {
className: "vjs-volume-control vjs-control",
innerHTML: '<div><span class="vjs-vc-1"></span><span class="vjs-vc-2"></span><span class="vjs-vc-3"></span><span class="vjs-vc-4"></span><span class="vjs-vc-5"></span><span class="vjs-vc-6"></span></div>'
});
this.cels.main.bar.appendChild(this.cels.main.volumeControl);
this.addBehavior(this.cels.main.volumeControl, "volumeScrubber");
this.cels.main.volumeDisplay = this.cels.main.volumeControl.children[0];
this.addBehavior(this.cels.main.volumeDisplay, "volumeDisplay");
// Crete the fullscreen control
this.cels.main.fullscreenControl = _V_.createElement("div", {
className: "vjs-fullscreen-control vjs-control",
innerHTML: '<div><span class="vjs-fc-1"></span><span class="vjs-fc-2"></span><span class="vjs-fc-3"></span><span class="vjs-fc-4"></span></div>'
});
this.cels.main.bar.appendChild(this.cels.main.fullscreenControl);
this.addBehavior(this.cels.main.fullscreenControl, "fullscreenToggle");
},
remove: function(){
this.box.removeChild(this.cels.bigPlayButton);
delete this.cels.bigPlayButton;
this.removeBehavior(this.cels.bigPlayButton, "bigPlayButton");
}
}
/* Control Bar Behaviors
================================================================================ */
VideoJS.fn.newBehavior("controlBar",
function(element){
if (!this.bels.controlBars) {
this.bels.controlBars = [];
// this.addEvent("mouseover", this.showControlBars);
// this.addEvent("mouseout", this.hideControlBars);
}
this.bels.controlBars.push(element);
},
function(element){},
{
showControlBars: function(){
this.each(this.bels.controlBars, function(bar){
// bar.style.opacity = 1;
bar.style.display = "block";
});
},
hideControlBars: function(){
this.each(this.bels.controlBars, function(bar){
// bar.style.opacity = 0;
bar.style.display = "none";
});
}
}
);
-22
Ver Arquivo
@@ -1,22 +0,0 @@
_V_.controlSets.subtitlesBox = {
options: {},
add: function(){
/* Creating this HTML
<div class="vjs-subtitles"></div>
*/
// Create a reference to the element
var subs = this.cels.subtitlesBox = _V_.createElement("div", { className: "vjs-subtitles" });
// Add the controls to the video's container
this.box.appendChild(subs);
this.addBehavior(subs, "subtitlesDisplay");
},
remove: function(){
this.removeBehavior(this.cels.subtitlesBox, "subtitlesDisplay");
this.box.removeChild(this.cels.subtitlesBox);
delete this.cels.subtitlesBox;
}
};
-381
Ver Arquivo
@@ -1,381 +0,0 @@
// HTML5 Shiv. Must be in <head>.
document.createElement("video");document.createElement("audio");
var VideoJS = _V_ = function(id, options){
// Allow for element or ID to be passed in.
var tag = (typeof id == "string" ? _V_.el(id) : id);
if (!tag || !tag.nodeName) { // Could be a box div also
throw new TypeError("The element or ID supplied is not valid. (video.js)");
return;
}
// Check if (not) using "new" operator before the function to create new instance
if (!(this instanceof arguments.callee)) {
// Return the player attr on the element if it exists
// Otherwise set up a new player.
return tag.player || new VideoJS(id, options);
}
this.tag = tag;
var box = this.box = _V_.createElement("div"),
width = tag.width || 300,
height = tag.height || 150;
// Make player findable on elements
tag.player = box.player = this;
// Wrap video tag in div (box) container
tag.parentNode.insertBefore(box, tag);
box.appendChild(tag); // Breaks iPhone, fixed in HTML5 setup.
// Give video tag properties to box
box.id = tag.id; // ID will now reference box, not the video tag
box.className = tag.className;
box.setAttribute("width", width);
box.setAttribute("height", height);
box.style.width = width+"px";
box.style.height = height+"px";
// Strip tag of basic properties
tag.id += "_html5_api";
tag.className = "vjs-tech";
tag.removeAttribute("width");
tag.removeAttribute("height");
tag.removeAttribute("controls");
// Default Options
this.options = _V_.options; // Global Defaults
_V_.merge(this.options, this.getVideoTagSettings()); // Override with Video Tag Options
_V_.merge(this.options, options); // Override/extend with options from setup call
// 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]);
}
}
}
// Store references to elements for different purposes
this.els = {};
// Tech (playback) Elements. Store playback tech objects for switching between them.
// ex. this.tels.html5 = videoTagElement; this.tels.flowplayer = swfObject;
this.tels = {};
// Behavior Elements. Store refs to elements that trigger/are triggered by a behavior.
// ex. this.bels.playButtons = [element1, element2]
this.bels = {};
// Control Elements. Store refs to elements that are part of control sets
// this.cels.mainControls.playButton = playButtonDiv;
this.cels = {};
// Cache for video property values.
this.values = {};
this.apiIsReady = false;
this.addBehavior(this.box, "box");
this.addEvent("ended", this.handleEnded);
// Build controls when the API is ready
this.addEvent("techready", _V_.proxy(this, function(){
this.each(this.options.controlSets, function(set){
_V_.controlSets[set].add.call(this);
});
}));
// Loop through playback technologies (HTML5, Flash) and check for support
// Then load the best source.
this.src(this.options.sources);
};
VideoJS.options = {
techOrder: ["h5swf","html5","flowplayer"],
controlSets: ["bigPlayButton", "bar", "subtitlesBox"/*, "replay"*/],
controlSetOptions: {
bigPlayButton: {},
bar: {},
replay: {}
},
width: "auto", // Default of web browser is 300x150. Should rely on source width/height.
height: "auto"
};
VideoJS.fn = VideoJS.prototype = {
getVideoTagSettings: function(){
var options = {
sources: [],
tracks: []
};
options.width = this.tag.width;
options.height = this.tag.height;
options.src = this.tag.src;
options.poster = this.tag.poster;
options.preload = this.tag.preload;
options.autoplay = this.tag.getAttribute("autoplay") !== null; // hasAttribute not IE <8 compatible
options.controls = this.tag.getAttribute("controls") !== null;
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)
================================================================================ */
loadTech: function(techName, source){
var tech = this.currentTech = _V_.tech[techName];
// Pause and remove current playback technology
if (this.currentTechName) {
this.removeTech(techName);
// 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 (!this.currentTechName && techName != "html5") {
this.removeTechElement(this.tag);
}
this.currentTechName = techName;
// Turn off API access because we're loading a new tech that might load asynchronously
this.isReady = false;
// Point all internal API calls to new playback tech's API.
this.api = tech.api;
// Finsh API Setup when tech is ready
this.addEvent("techready", _V_.proxy(this, function(){
// Reomve this so it's not called twice next load
this.removeEvent("techready", arguments.callee);
this.currentTechElement = this.tels[this.currentTechName];
// Set up playback technology's event triggers
this.api.setupTriggers.call(this);
this.triggerReady();
// Make playback element clickable
this.addBehavior(this.currentTechElement, "tech");
// Manually track progress in cases where the browser/flash player doesn't report it.
if (!_V_.techSupports(tech, "event", "progress")) { this.manualProgressOn(); }
// Manually track timeudpates in cases where the browser/flash player doesn't report it.
if (!_V_.techSupports(tech, "event", "timeupdate")) { this.manualTimeUpdatesOn(); }
}));
// Initialize new tech if it hasn't been yet
if (this.tels[techName] === undefined) {
tech.init.call(this, source);
} else {
_V_.insertFirst(this.tels[techName], this.box);
this.src(source);
}
},
removeTech: function(techName){
this.removeTechElement(this.tels[techName]);
// Should probably remove API listeners as well
},
removeTechElement: function(el){
this.box.removeChild(el);
},
/* Ready - Trigger functions when player is ready
================================================================================ */
readyQueue: [],
ready: function(fn){
if (this.isReady) {
fn.call(this);
} else {
this.readyQueue.push(fn);
}
},
triggerReady: function(){
if (this.isReady) return;
this.isReady = true;
if (this.readyQueue.length > 0) {
// Call all functions in ready queue
this.each(this.readyQueue, function(fn){
fn.call(this);
});
// Reset Ready Queue
this.readyQueue = [];
}
},
/* Behaviors - Make elements act like specific controls or displays
================================================================================ */
/* TODO - Make behavior classes. Use JR's simple inheritance for sub-classing. */
behaviors: {},
// New Behavior. Gets called in prototype scope (_V_.fn.newBehavior), so added to all instances.
newBehavior: function(name, add, remove, functions){
this.behaviors[name] = { add: add, remove: remove };
this.extend(functions);
},
addBehavior: function(element, behavior){
// Allow passing and ID string
if (typeof element == "string") { element = _V_.el(element); }
this.behaviors[behavior].add.call(this, element);
},
removeBehavior: function(element, behavior){
if (typeof element == "string") { element = _V_.el(element); }
this.behaviors[behavior].remove.call(this, element);
},
/* 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.addEvent("loadstart", _V_.proxy(this, this.trackProgress));
this.trackProgress();
// Set variables of closure
var tech = _V_.tech[this.currentTechName],
el = this.tels[this.currentTechName];
// Watch for native progress event
_V_.addEvent(el, "progress", _V_.proxy(this, function(){
// Remove this listener from the element
_V_.removeEvent(el, "progress", arguments.callee);
// Update known progress support for this playback technology
_V_.updateTechSupport(tech, "event", "progress", true);
// Turn off manual progress tracking
this.manualProgressOff();
}));
},
manualProgressOff: function(){
this.manualProgress = false;
this.removeEvent("loadstart", _V_.proxy(this, this.trackProgress));
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
// Set variables of closure
var tech = _V_.tech[this.currentTechName],
el = this.tels[this.currentTechName];
// Watch for native timeupdate event
_V_.addEvent(el, "timeupdate", _V_.proxy(this, function(){
// Remove this listener from the element
_V_.removeEvent(el, "timeupdate", arguments.callee);
// Update known progress support for this playback technology
_V_.updateTechSupport(tech, "event", "timeupdate", true);
// Turn off manual progress tracking
this.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)
================================================================================ */
handleEnded: function(){
if (this.options.loop) {
this.currentTime(0);
this.play();
} else {
this.currentTime(0);
this.pause();
}
},
/* 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]; }
}
},
/* 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
// this.warning(VideoJS.warnings.localStorageFull);
}
}
}
};
VideoJS.players = {};
-15
Ver Arquivo
@@ -1,15 +0,0 @@
// 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={};}})());
-152
Ver Arquivo
@@ -1,152 +0,0 @@
VideoJS.tech.h5swf = {
// swf: "flash/VideoJS.swf",
swf: "https://s3.amazonaws.com/video-js/3.0b/video-js.swf",
// swf: "http://video-js.zencoder.com/3.0b/video-js.swf",
supported: function(){
/* TODO Check for flash, etc. */
return true;
},
canPlaySource: function(sourceObj){
if (sourceObj.type in _V_.tech.h5swf.supports.format) { return "maybe"; }
},
supports: {
format: {
"video/flv": "FLV",
"video/x-flv": "FLV",
"video/mp4": "MP4",
"video/m4v": "MP4"
},
// Optional events that we can manually mimic with timers
event: {
progress: false,
timeupdate: false
}
},
// Init the swf object
init: function(sourceObj){
var player = this,
placeHolder = _V_.createElement("div", { id: player.box.id + "_temp_h5swf" }),
objId = player.box.id+"_h5swf_api"
h5swf = VideoJS.tech.h5swf,
flashvars = {
readyFunction: "_V_.tech.h5swf.onSWFReady",
eventProxyFunction: "_V_.tech.h5swf.onSWFEvent",
errorEventProxyFunction: "_V_.tech.h5swf.onSWFErrorEvent",
src: sourceObj.src,
autoplay: this.options.autoplay,
preload: this.options.preload,
loop: this.options.loop,
muted: this.options.muted
},
params = {
allowScriptAccess: "always",
wmode: "opaque",
bgcolor: "#000000"
},
attributes = {
id: objId,
name: objId,
'class': 'vjs-tech'
};
player.box.appendChild(placeHolder);
swfobject.embedSWF(_V_.tech.h5swf.swf, placeHolder.id, "480", "270", "9.0.124", "", flashvars, params, attributes);
},
onSWFReady: function(currSwf){
// Flash seems to be catching errors, so raising them manally
try {
// Delay for real swf ready.
setTimeout(function(){
var el = _V_.el(currSwf),
player = el.parentNode.player; // Get player from box
el.player = player;
// Update reference to playback technology element
player.tels.h5swf = el;
player.ready(function(){
// this.src("http://video-js.zencoder.com/oceans-clip.mp4");
});
player.triggerEvent("techready");
},0);
} catch(err) {
_V_.log(err);
}
},
onSWFEvent: function(swfID, eventName, other){
try {
var player = _V_.el(swfID).player;
if (player) {
player.triggerEvent(eventName);
}
} catch(err) {
_V_.log(err);
}
},
onSWFErrorEvent: function(swfID, eventName){
_V_.log("Error", eventName);
},
api: {
setupTriggers: function(){
// Using global onSWFEvent func to distribute events
},
play: function(){ this.tels.h5swf.vjs_play(); },
pause: function(){ this.tels.h5swf.vjs_pause(); },
src: function(src){ this.tels.h5swf.vjs_src(src); },
load: function(){ this.tels.h5swf.vjs_load(); },
buffered: function(){
return _V_.createTimeRange(0, this.tels.h5swf.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 = VideoJS.tech.h5swf.api,
readWrite = "src,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.tels.h5swf.vjs_setProperty(attr, val); };
},
createGetter = function(attr){
api[attr] = function(){ return this.tels.h5swf.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);
});
})();
// Special
// canPlayType
// addTextTrack
// textTracks
-157
Ver Arquivo
@@ -1,157 +0,0 @@
// Setup an API for the HTML5 playback technology
VideoJS.tech.html5 = {
supported: function(){
return !!document.createElement("video").canPlayType;
},
canPlaySource: function(srcObj){
return this.tag.canPlayType(srcObj.type); // Switch to global check
// Check Type
// If no Type, check ext
// Check Media Type
},
init: function(sourceObj){
var tag = this.tag, // Reuse original tag for HTML5 playback technology element
html5 = _V_.tech.html5,
options = this.options;
// 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 (html5.supports.movingElementInDOM === false) {
var newTag = _V_.createElement("video", {
id: tag.id,
className: tag.className
});
this.box.removeChild(this.tag);
tag = this.tag = newTag;
this.box.appendChild(tag);
}
// Store reference to playback element
this.tels.html5 = tag;
// Update tag settings, in case they were overridden
_V_.each(["autoplay","preload","loop","muted","poster"], function(attr){
tag[attr] = options[attr];
}, this);
if (tag.currentSrc != sourceObj.src) {
tag.src = sourceObj.src;
} else {
this.triggerEvent("loadstart");
}
this.triggerEvent("techready");
},
supports: {
/* Will hold support info as it's discovered */
},
api: {
setupTriggers: function(){
// Make video events trigger player events
// May seem verbose here, but makes other APIs possible.
// ["play", "playing", "pause", "ended", "volumechange", "error", "progress", "seeking", "timeupdate"]
var types = _V_.html5Events,
i;
for (i = 0;i<types.length; i++) {
_V_.addEvent(this.tels.html5, types[i], _V_.proxy(this, function(e){
e.stopPropagation();
this.triggerEvent(e);
}));
}
},
removeTriggers: function(){},
play: function(){ this.tels.html5.play(); },
pause: function(){ this.tels.html5.pause(); },
paused: function(){ return this.tels.html5.paused; },
currentTime: function(){ return this.tels.html5.currentTime; },
setCurrentTime: function(seconds){
try { this.tels.html5.currentTime = seconds; }
catch(e) {
_V_.log(e);
// this.warning(VideoJS.warnings.videoNotReady);
}
},
duration: function(){ return this.tels.html5.duration || 0; },
buffered: function(){ return this.tels.html5.buffered; },
volume: function(){ return this.tels.html5.volume; },
setVolume: function(percentAsDecimal){ this.tels.html5.volume = percentAsDecimal; },
muted: function(){ return this.tels.html5.muted; },
setMuted: function(muted){ this.tels.html5.muted = muted },
width: function(){ return this.tels.html5.offsetWidth; },
height: function(){ return this.tels.html5.offsetHeight; },
supportsFullScreen: function(){
if(typeof this.tels.html5.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.tels.html5.webkitEnterFullScreen();
} catch (e) {
if (e.code == 11) { this.warning(VideoJS.warnings.videoNotReady); }
}
},
src: function(src){ this.tels.html5.src = src; },
load: function(){ this.tels.html5.load(); },
currentSrc: function(){ return this.tels.html5.currentSrc; },
preload: function(){ return this.tels.html5.preload; },
setPreload: function(val){ this.tels.html5.preload = val; },
autoplay: function(){ return this.tels.html5.autoplay; },
setAutoplay: function(val){ this.tels.html5.autoplay = val; },
loop: function(){ return this.tels.html5.loop; },
setLoop: function(val){ this.tels.html5.loop = val; },
error: function(){ return this.tels.html5.error; },
networkState: function(){ return this.tels.html5.networkState; },
readyState: function(){ return this.tels.html5.readyState; },
seeking: function(){ return this.tels.html5.seeking; },
initialTime: function(){ return this.tels.html5.initialTime; },
startOffsetTime: function(){ return this.tels.html5.startOffsetTime; },
played: function(){ return this.tels.html5.played; },
seekable: function(){ return this.tels.html5.seekable; },
ended: function(){ return this.tels.html5.ended; },
videoTracks: function(){ return this.tels.html5.videoTracks; },
audioTracks: function(){ return this.tels.html5.audioTracks; },
videoWidth: function(){ return this.tels.html5.videoWidth; },
videoHeight: function(){ return this.tels.html5.videoHeight; },
textTracks: function(){ return this.tels.html5.textTracks; },
defaultPlaybackRate: function(){ return this.tels.html5.defaultPlaybackRate; },
playbackRate: function(){ return this.tels.html5.playbackRate; },
mediaGroup: function(){ return this.tels.html5.mediaGroup; },
controller: function(){ return this.tels.html5.controller; },
controls: function(){ return this.tels.html5.controls; },
defaultMuted: function(){ return this.tels.html5.defaultMuted; }
}
};
/* Device Fixes
================================================================================ */
// iOS
if (_V_.isIOS()) {
// If you move a video element in the DOM, it breaks video playback.
_V_.tech.supports.movingElementInDOM = false;
}
// 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" : "";
};
}
}
+139 -52
Ver Arquivo
@@ -1,145 +1,232 @@
---
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 VideoJS API allows you to interact with the video through Javascript, whether the browser is playing the video through HTML5 video or any number of media playback technologies that have an API wrapper (e.g. video-js.flowplayer.js).
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 (example_video_2, example_video_3, etc.).
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.
_V_("example_video_1")
{% highlight javascript %}
var myPlayer = _V_("example_video_1");
Wait until Ready
----------------
The time it takes VideoJS 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.
{% 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 react to video events using the following functions. The VideoJS API function names follow the HTML5 media API. The main difference is that attributes which you would get or set on a video element directly ( videoElement.currentTime = "120"; ), you would use a function syntax for VideoJS ( myPlayer.currentTime(120); )
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.
Example:
Start video playback. Returns the player object.
{% highlight javascript %}
myPlayer.play();
{% endhighlight %}
myPlayer.play();
### pause()
Pause the video playback.
Returns: the player object
Example:
Pause the video playback. Returns: the player object
myPlayer.pause();
{% highlight javascript %}
myPlayer.pause();
{% endhighlight %}
### currentTime()
Returns the current time of the video in seconds.
Example:
var whereYouAt = myPlayer.currentTime();
{% highlight javascript %}
var whereYouAt = myPlayer.currentTime();
{% endhighlight %}
### 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
{% 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.
Example:
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.
var howLongIsThis = myPlayer.duration();
{% highlight javascript %}
var howLongIsThis = myPlayer.duration();
{% endhighlight %}
### buffered()
Returns a [TimeRange](http://videojs.com/docs/timerange.html) with sections of the video that have been downloaded. If you just want the percent of the video that's been downloaded, use bufferedPercent.
Example:
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.
var whatHasBeenBuffered = myPlayer.buffered();
{% highlight javascript %}
var whatHasBeenBuffered = myPlayer.buffered();
{% endhighlight %}
### bufferedPercent()
Returns the percent (as a decimal) of the video that's been downloaded.
Example:
var howMuchIsDownloaded = myPlayer.bufferedPercent();
{% 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.
Example:
var howLoudIsIt = myPlayer.volume();
{% highlight javascript %}
var howLoudIsIt = myPlayer.volume();
{% endhighlight %}
### 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
{% highlight javascript %}
myPlayer.volume(0.5); // Set volume to half
{% endhighlight %}
### width()
Returns the current width of the video in pixels.
Example:
{% 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
Example:
myPlayer.width(640);
{% highlight javascript %}
myPlayer.width(640);
{% endhighlight %}
### height()
Returns the current height of the video in pixels.
Example:
var howTallIsIt = myPlayer.height();
{% 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
myPlayer.height(480);
{% 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.
Returns the player object.
myPlayer.size(640,480);
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.
### 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.
{% 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.
myPlayer.enterFullScreen();
{% highlight javascript %}
### exitFullScreen()
myPlayer.enterFullScreen();
{% endhighlight %}
### cancelFullScreen()
Return the video to its normal size after having been in full screen mode.
Returns the player object.
myPlayer.exitFullScreen();
{% highlight javascript %}
myPlayer.exitFullScreen();
{% endhighlight %}
Events
------
You can attach event listeners to the player similarly to how you would for a video element.
var myFunc = function(){
// Do something when the event is fired
};
myPlayer.addEvent("eventName", myFunc);
{% highlight javascript %}
var myFunc = function(){
// Do something when the event is fired
};
myPlayer.addEvent("eventName", myFunc);
{% endhighlight %}
You can also remove the listeners later.
myPlayer.removeEvent("eventName", myFunc);
{% 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>
-50
Ver Arquivo
@@ -1,50 +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");
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)
+39 -1
Ver Arquivo
@@ -1,3 +1,12 @@
---
layout: docs
title: VideoJS Glossary
description: Video.JS Glossary
body_id: glossary
body_class: docs subpage
---
Glossary
========
@@ -6,4 +15,33 @@ The container of elements on the page that must be loaded before you can interac
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.
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 its up to browser developers to follow those directions, so that video works the same across all browsers. This doesnt always happen thanks to technology, legal, and financial choices made by browser developers, but so far no ones 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, thats 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) cant 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.
+29
Ver Arquivo
@@ -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.
+28
Ver Arquivo
@@ -1,2 +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.)
+35 -14
Ver Arquivo
@@ -1,29 +1,50 @@
---
layout: docs
title: Setup
description: Setup
body_id: setup
body_class: docs subpage
---
Setup
=====
Step 1: Include the VideoJS Javascript and CSS files in the head of your page.
------------------------------------------------------------------------------
You can download the VideoJS source and host it on your own servers, or use the free CDN hosted version (thanks to Zencoder).
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.
<script src="http://video-js.zencoder.com/3.0/video.min.js"></script>
<link href="http://video-js.zencoder.com/3.0/video-js.css" rel="stylesheet">
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.net/c/video.js"></script>
<link href="http://vjs.zencdn.net/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 VideoJS:
Use the video tag as normal, with a few extra pieces for Video.js:
1. The 'data-setup' Atrribute tells VideoJS 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)).
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 VideoJS functionality, like fullscreen and subtitles.
- '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)).
<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>
{% 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 %}
+33
Ver Arquivo
@@ -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>.
+11 -9
Ver Arquivo
@@ -1,18 +1,20 @@
---
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, VideoJS.swf, etc. (not just "Flash").
With the VideoJS API you can control any type of browser-based video, as long as the playback technology in use has an API and a VideoJS API wrapper for it.
Including an API Wrapper
------------------------
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
----------------
-2
Ver Arquivo
@@ -1,2 +0,0 @@
TimeRange
=========
-8
Ver Arquivo
@@ -1,8 +0,0 @@
HTML5 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)
Diff do arquivo suprimido porque uma ou mais linhas são muito longas
Arquivo binário não exibido.
+25
Ver Arquivo
@@ -0,0 +1,25 @@
/*!
Video.js - HTML5 Video Player
Version 3.0r2
LGPL v3 LICENSE INFO
This file is part of Video.js. Copyright 2011 Zencoder, Inc.
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.
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 Video.js. If not, see <http://www.gnu.org/licenses/>.
*/
// Self-executing function to prevent global vars and help with minification
;(function(window, undefined){
var document = window.document;
+3
Ver Arquivo
@@ -2,5 +2,8 @@
// Expose to global
window.VideoJS = window._V_ = VideoJS;
// Run Auto-load players
_V_.autoSetup();
// End self-executing function
})(window);
+188
Ver Arquivo
@@ -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);
}
});
+795
Ver Arquivo
@@ -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
Ver Arquivo
@@ -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);
};
Ver Arquivo
+12 -4
Ver Arquivo
@@ -1,4 +1,4 @@
// Event System (J.Resig - Secrets of a JS Ninja http://jsninja.com/ [Go buy it, really])
// 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
@@ -26,8 +26,15 @@ _V_.extend({
var handlers = _V_.getData(elem).events[event.type];
// Go through and call all the real bound handlers
if (handlers) {
for (var i = 0, l = handlers.length; i < l; i++) {
if (handlers[i]) handlers[i].call(elem, event); // Incase one's been removed
// 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);
}
}
};
@@ -281,7 +288,8 @@ _V_.Event.prototype = {
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(" ");
_V_.Event.props = "altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode 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; }
Ver Arquivo
+93 -36
Ver Arquivo
@@ -1,4 +1,7 @@
_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]; }
}
@@ -10,19 +13,6 @@ _V_.extend({
tech: {}, // Holder for playback technology settings
controlSets: {}, // Holder for control set definitions
techSupports: function(tech, type, name){
if (tech.supports[type]) {
return tech.supports[type][name];
}
return false;
},
updateTechSupport: function(tech, type, name, value){
if (!tech.supports[type]) { tech.supports[type] = {}; }
tech.supports[type][name] = value;
},
html5Events: "loadstart,suspend,abort,error,emptied,stalled,loadedmetadata,loadeddata,canplay,canplaythrough,playing,waiting,seeking,seeked,ended,durationchange,timeupdate,progress,play,pause,ratechange,volumechange".split(","),
// Device Checks
isIE: function(){ return !+"\v1"; },
isIPad: function(){ return navigator.userAgent.match(/iPad/i) !== null; },
@@ -37,7 +27,10 @@ _V_.extend({
var match = navigator.userAgent.match(/Android (\d+)\./i);
if (match && match[1]) { return match[1]; }
},
//isAndroidBrowser
testVid: document.createElement("video"),
ua: navigator.userAgent,
support: {},
each: function(arr, fn){
if (!arr || arr.length === 0) { return; }
@@ -61,18 +54,21 @@ _V_.extend({
}
return el;
},
insertFirst: function(node, parent){
if (parent.firstChild) {
parent.insertBefore(parent.firstChild, node);
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(" ");
@@ -119,18 +115,15 @@ _V_.extend({
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));
},
// 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);
},
@@ -232,7 +225,7 @@ _V_.extend({
try {
request.open("GET", url);
} catch(e) {
_V_.log(e);
_V_.log("VideoJS XMLHttpRequest (open)", e);
// onError(e);
return false;
}
@@ -242,7 +235,9 @@ _V_.extend({
if (request.status == 200 || local && request.status == 0) {
onSuccess(request.responseText);
} else {
onError();
if (onError) {
onError();
}
}
}
});
@@ -250,19 +245,81 @@ _V_.extend({
try {
request.send();
} catch(e) {
_V_.log(e);
onError(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);
}
}
}
});
// /* Function Context Allows for binding context to functions when using in event listeners
// ================================================================================ */
// Function.prototype.context = function(obj){
// var method = this,
// temp = function(){
// return method.apply(obj, arguments);
// };
// return temp;
// };
// 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
Ver Arquivo
@@ -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
};
}
})();
+4
Ver Arquivo
@@ -0,0 +1,4 @@
_V_.addEvent(window, "load", function(){
_V_.windowLoaded = true;
});
_V_.autoSetupTimeout();
+451
Ver Arquivo
@@ -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);
};
+4 -3
Ver Arquivo
@@ -6,7 +6,7 @@ _V_.Track = function(attributes, player){
this.kind = attributes.kind;
this.srclang = attributes.srclang;
this.label = attributes.label;
this["default"] = attributes["default"];
this["default"] = attributes["default"]; // 'default' is reserved-ish
this.title = attributes.title;
this.cues = [];
@@ -14,7 +14,8 @@ _V_.Track = function(attributes, player){
this.lastCueIndex = 0;
// Update current cue on timeupdate
player.addEvent("timeupdate", _V_.proxy(this, this.update))
player.addEvent("timeupdate", _V_.proxy(this, this.update));
// Reset cue time on media end
player.addEvent("ended", _V_.proxy(this, function() { this.lastCueIndex = 0; }));
@@ -87,7 +88,7 @@ _V_.Track.prototype = {
// 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;
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)
@@ -1,5 +1,7 @@
// Flowplayer API Connector
VideoJS.tech.flowplayer = {
name: "Flowplayer",
supported: function(){
if (flowplayer) {
return true;
+20
Ver Arquivo
@@ -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>
+147
Ver Arquivo
@@ -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");
}

Alguns arquivos não foram exibidos porque demasiados arquivos foram alterados neste diff Mostrar Mais