Certain schools block youtube.com, where our videos are embedded from.
As a fallback, we display the downloadable copy of our videos using video.js.
Whitelist:
- https://s.youtube.com
- https://www.youtube.com
- https://*.googlevideo.com
- https://*.ytimg.com
Whitelist:
Blacklist:
- https://www.youtube.com — specifically https://www.youtube.com/favicon.ico (this is how we detect to serve the fallback player)
- Chrome: should always work (player will try Flash first, if not available, will use HTML5 player)
- Firefox: for fallback player, need to have Flash player installed
- Safari: for fallback player, have Flash player installed (it may still work when Flash is uninstalled, I haven't been able to test this case)
- iOS / Android: should always work
We use the technique from Khan Academy's YouTube fallback, testing img
loading of youtube.com/favicon.ico
.
Since youtubeeducation.com does not have a favicon.ico, we are using youtube.com as the default video address and fallback host.
We will use the fallback player if either:
- You visit a url with
?force_youtube_fallback
in it - jQuery detects an error when loading https://www.youtube.com/favicon.ico
To display our fallback videos, we use video.js with files served from our server through the Rails asset pipeline. This includes files in vendor/assets/[fonts, javascripts, stylesheets, flash]
.
These videos are loaded from our video download host: http://videos.code.org/
For a semi-decent simulation of blocked YouTube, add ?force_youtube_fallback
to the URL. This is how our UI tests
sudo vim /etc/hosts
# insert:
127.0.0.1 www.youtube.com
127.0.0.1 youtube.com
127.0.0.1 youtubeeducation.com
127.0.0.1 www.youtubeeducation.com
127.0.0.1 ytimg.com
Charles is an HTTP proxy, throttling, monitoring power tool.
You can use Charles to block certain hosts and to monitor where requests are being made.
To block certain hosts, go to the Blacklist tool or right click on a request that's been captured and check blacklist.
Firefox does not support HTML5 video playing of mp4 video files, so we want to consider the cases of:
- Firefox visitors with Flash player
- Firefox visitors without Flash player
To test how the page looks with Firefox without Flash, use the FlashDisable Firefox extension.
Hit the local endpoint http://localhost:3000/reset_session to reset your session and the video will show again.