JS Days Mobile Meow
- 17. Native
○ For fallbacks, use rtsp:// protocol (serving .3pg) if the
device won't support HTML5
○ Use custom protocol / URL scheme to launch your own
Android, iOS native app (no Windows Phone yet)
■ youtube://video_id
- 26. Mobile Formats Support
Chrome Safari Firefox Opera IE Android
H.264
WebM Android 4+ Android 4+ Android 4+
HLS Android 3+
Platform Versions and Distribution
- 27. The Source
<video>
<source src="funny_cat_video.mp4">
<source src="funny_cat_video.webm">
</video>
- 28. HLS = HTTP Live Streaming
<video src="playlist.m3u8">
- 29. HLS
video-0-1.ts
format-0.m3u8 video-0-2.ts
...
video-1-1.ts
index.m3u8 format-0.m3u8 video-1-2.ts
...
video-2-1.ts
format-0.m3u8 video-2-2.ts
...
- 30. HLS
Big Features
○ Live and Adaptive Streaming
○ Built in CDN failover
○ Metadata + Cue Points
Apple App Requirements
○ > 10 minutes in duration or 5 mb in 5 minutes
○ at least one 64 kbps or lower stream required
Tools and more information on Apple's website:
Apple's Using HTTP Live Streaming
- 32. Power Consumption: H264 vs WebM
**fullscreen flash
**windowed flash
Research done by Yossi Oren For more information visit http://iss.oy.ne.ro/
- 34. Basic video tag
Safari
○ Renders a thumbnail poster and play button (flaky)
○ Background is set to black and cannot be overwritten
○ If a parent element has display:none set at any point the video fails to
playback properly
Opera
○ Gives video dimentions black background if the information is
available
○ Has issues with stretching WebM
IE and Android
○ Play button/film icon for all video tags regardless if browser can play
the format
○ Background is set to black/grey and cannot be overwritten
- 36. Poster Attribute
Use the poster attribute to get a thumbnail
Safari, Chrome, Android, and Opera
○ Preserve aspect ratio of poster image
IE and Firefox
○ Stretch image to size of video tag
IE
○ Keeps poster as paused state
All Others
○ Replace video with the paused frame
- 37. Basic video tag
Chrome
○ Default click to toggle play/pause
○ Remove with an empty onclick handler
Safari
○ Will launch any supported video with or without an onclick handler
Android and IE
○ Shows click interactions but does not play with empty onclick
- 38. Basic video tag
Pro tips:
○ Create your own cued state to convey you can play the video
○ Set the background color to black for continuity across platforms
- 40. Controls
Chrome Safari Firefox Opera IE Android
Play/pause
Button
Volume Only in Mute toggle Don't work in
Controls Fullscreen only Android 4
Seek bar
Fullscreen Button Gesture Button
button
Playback Both Fullscreen Inline only Determined Fullscreen Both
Type only by hardware only
- 43. Custom Controls
● Allows us to expand the set of controls and add our own
○ annotations
○ playlist
○ captions
○ more
- 44. Custom Controls Pro Tips
● User expect to be able to drag the progress
bar
○ Need to remender to prevent scroll on touchstart
● Volume can't be set everywhere and users
are accustomed to using device controls
○ So don't build controls for it
- 45. Custom Controls Pro Tips
● Fingers are fat
○ Average finger is 11mm so make targets at least
40px with 10px padding
○ Use SVG's so icons can be scaled and shared with
desktop application
○ Do what you can in css
- 46. Custom Controls Pro Tips
● Don't trigger content with hover
● Fullscreen
○ The browsing context is always fullscreen so fake it
- 53. Mobile Fullscreen
● Open New Tab
● webkitEnterFullscreen
■ Webkit only
■ Video element only
■ metadata must be loaded
- 54. Mobile Fullscreen
● Open New Tab
● webkitEnterFullscreen
■ Webkit only
■ Video element only
■ metadata must be loaded
● Pro Tip: Remember size context
changes so use viewport to scale
icons and controls
- 58. autoplay
In Safari on iOS (for all devices, including iPad),
where the user may be on a cellular network and
be charged per data unit, preload and autoplay are
disabled. No data is loaded until the user initiates it.
- 60. Autoplay
Chrome Safari Firefox Opera IE Android
Attribute
Scripted Buggy
- 62. autoplay
<video onclick="this.play()">
- 65. autoplay
function someClickEvent(evt) {
// In a user initiated thread.
myVideoElement.load();
getVideoData(); // Triggers an ajax call.
}
function onGetVideoDataReturned(data) {
// Not in a user initiated thread.
setVideoElementSrc(data);
myVideoElement.load();
myVideoElement.play();
}
- 66. autoplay
function someClickEvent(evt) {
// In a user initiated thread.
myVideoElement.load();
getVideoData(); // Triggers an ajax call.
}
function onGetVideoDataReturned(data) {
// Not in a user initiated thread.
setVideoElementSrc(data);
myVideoElement.load();
// For Android
window.setTimeout(function() {
myVideoElement.play();
}, 0);
}
- 69. Embeds
<script>
○ We need our content to be sandboxed
○ More than just a video tag
- 70. Embeds
<script>
○ We need our content to be sandboxed
○ More than just a video tag
<object>
- 71. Embeds
<script>
○ We need our content to be sandboxed
○ More than just a video tag
<object>
○ Can load content with the data
attribute
○ But no way to interact with it via
JavaScript
- 73. Embeds
<iframe>
○ Allows our content to be sandboxed
○ JavaScript API communication
- 75. Embeds
Pro tip: Plan for the future (if you can)
<iframe type="text/html"
width="640"
height="385"
frameborder="0"
src="http://www.youtube.com/embed/VIDEO_ID"
allowfullscreen>
</iframe>
- 77. Embeds Pro Tips:
body {
/** Dymanic Resizing **/
background-color: #000;
height: 100%;
width: 100%;
/** Remove highlight when use clicks **/
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}
- 79. Testing: The Old Fashioned Way
● Device lab
○ accurate
○ costly
○ space inefficient
○ boring
- 80. Testing: With Software
● Hardware Emulators / Simulators
○ available for major systems
○ approximation varies
○ still boring
● Android Emulator
○ bulky, slow, no video codecs
● iOs Simulator
○ both tablet and phone
- 81. Testing: With Software
● Browser Simulators
○ Poorer approximation
● Opera Mobile Simulator
○ missing video tag support
● Fennec (FF) Simulator
○ poor touch control mapping
○ sends desktop user agent
- 83. Testing: Automation
● Android Webdriver
○ Still no video support
● iOS Webdriver
○ Need to register as ios dev
○ Intermittent issues with playback
● IE
○ No webdriver APIs for mobile
- 84. Testing: Automation
● Chrome, Opera
○ Driver APIs built-in
○ Remote debugging
● FFMobile
○ No webdriver APIs
- 86. Testing: Automation Strategy
● More sophisticated tests to follow
○ screenreader
● Screen cap processing
○ check for distortion
○ playback accuracy
- 96. More to learn
● HTML5 Video Spec
○ http://dev.w3.org/html5/spec-author-view/video.html
● Browser Blogs
○ http://dev.opera.com/
○ http://hacks.mozilla.org/
○ http://blogs.msdn.com/b/ie/
○ http://peter.sh/
● Documentation
○ https://developer.mozilla.org/en-US/
● Other
○ http://developer.apple.
com/library/safari/#documentation/AudioVideo/Conceptual/Using_HT
ML5_Audio_Video/Device-SpecificConsiderations/Device-
SpecificConsiderations.html
- 97. Questions?
can haz question?
By cloudzilla http://www.flickr.com/photos/cloudzilla/378829651/
schechter@google.com