Customized, easily themeable HTML5 video player.
Note: all aspects are in-progress
Note: delete this section when development is closer to completion
This player exists mainly as a backup plan in case SublimeVideo, recently bought by DailyMotion, drops support. A modern solution, one without a flash fallback, is the aim of this player. A few benchmarks for development:
- Only
MP4 H.264
andWebM
are needed as formats (H.264 will account for about 90% support). Between these two formats every modern browser is supported (OGG
in all instances is equal to WebM support, but WebM still has wider support) - No flash fallback is needed for any devices, however, fullscreen in IE9 & IE10 will need to have some sort of workaround. This is the only forseeable shortfall with avoiding a flash fallback.
- Nearly every modern
- It’s HTML5-compliant, and doesn’t require any non-W3C attributes to work.
- Uses
poster
to set default pre-start image - Pulls
width
andheight
from video element on initialization Note: ShadowDOM manipulation is currently only supported in Chrome, with no plans for additional support from other browsers any time soon. For that reason this approach is ignored.
- Uses
HTML:
<video controls height="300" poster="poster.jpg" width="600">
<source src="mp4.mp4" type="video/mp4">
<source src="webm.webm" type="video/webm">
</video>
JS:
<script type="text/javascript">
env = new EnvyVideo(videoElement[, settings]);
</script>
videoElement
(required) can handle:
- CSS selector (will take the first instance)
- JavaScript DOM element object
- jQuery object
settings
(optional) handles a JS object to override default settings
prefix
:string
Class prefix for all CSS hooks Default:envy-video
Some notes exist on Google Drive for now:
https://drive.google.com/#folders/0B0V3MqSa3ulNUmdJZ1ZfQnVxTFE
Required development
- Make the scrubber work
- Add fullscreen (for IE9 + IE10, position:fixed & stretch, maybe?)
- Add quality toggle (lo, hi quality similar to Vimeo—maybe no more than that)
- Add playback speed (I was thinking 1x, 1.1x, 1.3x, 1.6x, and 2x; reasoning is +10%, +20%, +40% relative to each other. Plus it’s a slimmer button than three-digit 1.25x, etc.)
- Add subtitle functionality (.vtt files; see http://docs.sublimevideo.net/subtitles)
- Add shortcuts (space to play, etc.)
- Make sure competiting shortcuts don’t fire on top of each other or are janky in general (refer to “Throttling” function from Underscore.js)
- Events should ideally be on “keydown” rather than “keyup” but should probably only fire once until keyup.
- Buffering and loading control
- The API, complete with action methods and status queries
Nice stuff to have
- Add scrubber thumbnails on playhead hover like on YouTube (maybe create a
<canvas>
element offscreen and write current seek point to that canvas—maybe. Read: http://www.html5rocks.com/en/tutorials/canvas/performance/) - Playlists
- Prev / Next videos
- Audio language switch (multiple audio tracks)
Some ideas for API calls; ones in bold exist now. All others are conceptual at this point and may change
destroy
Teardown and unbind all event listenersfullscreen
next
Go to next video in playlist and playpause
Pause playbackplay
Start/resume playback- **
playPause
** Toggle between play and pause prev
Go to previous video in playlistseek(ms)
Jump to point in video
@param num
Milliseconds to jump tosetAudio(audioFileMP4, audioFileWebM [, muteVideo])
Change the audio track on the video (useful for language dubs)
@param str
Path to MP4 audio file
@param str
Path to WebM audio file
@param bool
Mute the video’s embedded audio track? Default: truesetHeight(num)
setVideo(videoFileMP4, videoFileWebM)
Change video files and restart video without destructing player
@param str
Path to MP4 video file
@param str
Path to WebM audio file
Note: when this is actually implemented, maybe an option to change the poster image?setWidth(num)
sub(on[, vtt])
Turn subtitles on/off and/or set/change subtitle file@param bool
Subtitles visible? True or false
@param str
Path to *.vtt subtitle fileupdate(settings, callback)
@param obj
Settings to change; reinitializes
beforeReady(callback)
onNext(callback)
onPause(callback)
onPlay(callback)
onPrev(callback)
onReady(callback)
onSetupError(callback)
isBuffering
&isLoaded
isFullscreen
isPlaying
isPaused
isReady
getVideo
getPlaylist
@returns Array
of objects