JS Days Mobile Meow

  • 6,795 views
Uploaded on

This is the story of the glory and struggle of bringing a high quality YouTube experience to the mobile web. Once upon a time there was a web developer who wanted to play videos on the web. So he …

This is the story of the glory and struggle of bringing a high quality YouTube experience to the mobile web. Once upon a time there was a web developer who wanted to play videos on the web. So he filmed a cat and wrote a Flash and a HTML5 player. He spent many hours making it work on his favorite desktop browsers and even the one his grandfather still used. People could watch his cat video, he smiled, and the world was good. Then one day someone put a browser in a phone and soon there were many phones with many different browsers. This new set of environments were even harder to develop for and had a slew of new terrifying bugs. The web developer was miserable knowing people couldn’t watch his cat video. With much time and effort he figured out many of the secrets needed to combat the evils of the different mobile platforms. Once again people could watch his cat video, he smiled, and the world was good. The end.

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
No Downloads

Views

Total Views
6,795
On Slideshare
0
From Embeds
0
Number of Embeds
2

Actions

Shares
Downloads
13
Comments
1
Likes
2

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. Mobile MeowBring YouTube to the Mobile Web By YouTubes Greg Schechter
  • 2. Greg SchechterThe Web Warriorschechter@google.com
  • 3. Video
  • 4. Video
  • 5. A Brief History
  • 6. Video
  • 7. Flash
  • 8. <video>
  • 9. Video
  • 10. Playback Stats
  • 11. Flash Native <video>
  • 12. FlashFlash == Flash
  • 13. Flash Flash
  • 14. Native
  • 15. Native ○ For fallbacks, use rtsp:// protocol (serving .3pg) if the device wont support HTML5 ○ Use custom protocol / URL scheme to launch your own Android, iOS native app (no Windows Phone yet) ■ youtube://video_id
  • 16. <video>
  • 17. The Different Browsers Safari Android
  • 18. The Different Browsers OperaSafari Android Chrome Silk Mini Firefox Opera IE
  • 19. The Different Browsers OperaSafari Android Chrome Silk Mini Firefox Opera IE AMP LE S
  • 20. By brownpau at http://www.flickr.com/photos/brownpau/533267369/
  • 21. How do we start <video>
  • 22. The Source <video src="funny_cat_video">
  • 23. The Source<video src="funny_cat_video.webm/mp4/ogg">
  • 24. Mobile Formats Support Chrome Safari Firefox Opera IE AndroidH.264WebM Android 4+ Android 4+ Android 4+HLS Android 3+ Platform Versions and Distribution
  • 25. The Source <video> <source src="funny_cat_video.mp4"> <source src="funny_cat_video.webm"> </video>
  • 26. HLS = HTTP Live Streaming <video src="playlist.m3u8">
  • 27. 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 ...
  • 28. HLSBig Features ○ Live and Adaptive Streaming ○ Built in CDN failover ○ Metadata + Cue PointsApple App Requirements ○ > 10 minutes in duration or 5 mb in 5 minutes ○ at least one 64 kbps or lower stream requiredTools and more information on Apples website:Apples Using HTTP Live Streaming
  • 29. Power
  • 30. Power Consumption: H264 vs WebM **fullscreen flash **windowed flashResearch done by Yossi Oren For more information visit http://iss.oy.ne.ro/
  • 31. Stick it in a page
  • 32. Basic video tagSafari ○ 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 properlyOpera ○ Gives video dimentions black background if the information is available ○ Has issues with stretching WebMIE 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
  • 33. Give it a poster and click it
  • 34. Poster AttributeUse the poster attribute to get a thumbnailSafari, Chrome, Android, and Opera ○ Preserve aspect ratio of poster imageIE and Firefox ○ Stretch image to size of video tagIE ○ Keeps poster as paused stateAll Others ○ Replace video with the paused frame
  • 35. Basic video tagChrome ○ Default click to toggle play/pause ○ Remove with an empty onclick handlerSafari ○ Will launch any supported video with or without an onclick handlerAndroid and IE ○ Shows click interactions but does not play with empty onclick
  • 36. Basic video tagPro tips: ○ Create your own cued state to convey you can play the video ○ Set the background color to black for continuity across platforms
  • 37. Controls <video controls>
  • 38. Controls Chrome Safari Firefox Opera IE AndroidPlay/pauseButtonVolume Only in Mute toggle Dont work inControls Fullscreen only Android 4Seek barFullscreen Button Gesture ButtonbuttonPlayback Both Fullscreen Inline only Determined Fullscreen BothType only by hardware only
  • 39. Custom Controls● Preserve your brand● Unified experience across platforms and browsers
  • 40. Custom Controls Lets get some custom controls
  • 41. Custom Controls● Allows us to expand the set of controls and add our own ○ annotations ○ playlist ○ captions ○ more
  • 42. Custom Controls Pro Tips● User expect to be able to drag the progress bar ○ Need to remender to prevent scroll on touchstart● Volume cant be set everywhere and users are accustomed to using device controls ○ So dont build controls for it
  • 43. Custom Controls Pro Tips● Fingers are fat ○ Average finger is 11mm so make targets at least 40px with 10px padding ○ Use SVGs so icons can be scaled and shared with desktop application ○ Do what you can in css
  • 44. Custom Controls Pro Tips● Dont trigger content with hover● Fullscreen ○ The browsing context is always fullscreen so fake it
  • 45. Fullscreen
  • 46. requestFullScreen
  • 47. requestFullScreen● Desktop Only ○ Firefox, Safari, and Chrome ○ Vendor Prefixed
  • 48. What about Mobile?
  • 49. Isnt it already fullscreen?
  • 50. Yes (sort of)
  • 51. Mobile Fullscreen● Open New Tab● webkitEnterFullscreen ■ Webkit only ■ Video element only ■ metadata must be loaded
  • 52. 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
  • 53. @viewport { width: device-width; }
  • 54. autoplay <video autoplay>
  • 55. autoplayIn Safari on iOS (for all devices, including iPad),where the user may be on a cellular network andbe charged per data unit, preload and autoplay aredisabled. No data is loaded until the user initiates it.
  • 56. What about everyone else?
  • 57. Autoplay Chrome Safari Firefox Opera IE AndroidAttributeScripted Buggy
  • 58. autoplay
  • 59. autoplay <video onclick="this.play()">
  • 60. autoplayfunction 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();}
  • 61. autoplayfunction 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);}
  • 62. Embeds
  • 63. Embeds <script>
  • 64. Embeds <script> ○ We need our content to be sandboxed ○ More than just a video tag
  • 65. Embeds <script> ○ We need our content to be sandboxed ○ More than just a video tag <object>
  • 66. 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
  • 67. Embeds <iframe>
  • 68. Embeds <iframe> ○ Allows our content to be sandboxed ○ JavaScript API communication
  • 69. Embeds<iframe type="text/html" width="640" height="385" frameborder="0" src="http://www.youtube.com/embed/VIDEO_ID" allowfullscreen></iframe>
  • 70. EmbedsPro 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>
  • 71. Embeds Pro Tips:html { /** Hack to fix iPhone resizing. */ overflow: hidden;}
  • 72. 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);}
  • 73. Testing
  • 74. Testing: The Old Fashioned Way ● Device lab ○ accurate ○ costly ○ space inefficient ○ boring
  • 75. 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
  • 76. 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
  • 77. Testing: Automation ● Selenium! ○ use with simulated or real devices ○ not boring
  • 78. 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
  • 79. Testing: Automation ● Chrome, Opera ○ Driver APIs built-in ○ Remote debugging ● FFMobile ○ No webdriver APIs
  • 80. Testing: Automation Strategy ● Test API methods in mobile context first ○ cheap ○ can approximate video playback by video. currentTime
  • 81. Testing: Automation Strategy ● More sophisticated tests to follow ○ screenreader ● Screen cap processing ○ check for distortion ○ playback accuracy
  • 82. Testing: Automation Strategy ● Screen cap processing
  • 83. Testing: Hardware Assistance for more information check out http://bitbeam.org/
  • 84. The Future Cats in Space by WF&TD
  • 85. Or
  • 86. PointerEventshttp://msdn.microsoft.com/en-us/library/ie/hh673557(v=vs.85).aspx
  • 87. http://imgs.xkcd.com/comics/in_ur_reality.png
  • 88. Track<video> <track src="cats_meow" kind="subtitles"></video>
  • 89. Camera Access with getUserMedia
  • 90. 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
  • 91. Questions? can haz question? By cloudzilla http://www.flickr.com/photos/cloudzilla/378829651/schechter@google.com