/Android-WebCast

Android app to watch web videos on Google Chromecast.

Primary LanguageJavaGNU General Public License v2.0GPL-2.0

Android app to watch web videos on Google Chromecast.

Description

App consists of 2 Activities:

  1. WebView to browse websites
    • left drawer contains a list of bookmarks
      • data is persistent
      • click to:
        • open website URLs in WebView
        • watch video URLs in next Activity
      • long click to:
        • rename
        • delete
    • right drawer contains videos
      • data is transient and only valid for the current website
      • click to:
        • add to bookmarks
        • watch video URL in next Activity
      • long click to:
        • delete
    • menu icons:
      • bookmarks toggle: add/remove current website URL
  2. ExoPlayer to watch video(s)
    • video player w/:
      • cast icon when at least one Google Chromecast is detected on LAN
      • playlist
    • click on video URL in playlist to:
      • if not casting, load video in player
      • if casting, cast video to Google Chromecast (receiver app)

Notes

  • when video is played in ExoPlayer
    • Referer HTTP header is set to the URL of the website
    • icon in lower right corner of toolbar to toggle fullscreen mode
  • when video is cast to Google Chromecast
    • the video URL is communicated to the receiver app running in the Google Chromecast
    • the receiver app requests the video file/stream directly from its server
      • Referer HTTP header cannot be set to the URL of the website
        • the receiver app is restrained by standard browser security policies
          • the specs for XHR and fetch forbid changing certain HTTP request headers, including Referer
    • the Android device running this app can be turned off, and it would have no effect on playback of the video that is casting

Status

  • everything works, but..
    • how well will depend entirely upon the implementation of WebView on your Android device
      • this app supports Android 4.1 Jellybean and newer
        • Android 4.x
          • WebView is embedded into the Android operating system
          • WebView in 4.1 cannot load the javascript video player on many websites
            • consequently, the video URL is never requested.. and this app has no opportunity to intercept it
          • WebView in 4.4 is also imperfect, though noticeably better than in Android 4.1
        • Android 5.0+
          • WebView in 5.0 was moved to a system app
            • upgradable
            • based on the Google Chrome web browser
            • works much better than earlier embedded implementations
    • the ExoPlayer Chromecast extension could be better
      • future updates to this library would directly benefit future builds of this app

TL;DR


Organization of Git Repo:

methodology used in previous branches

  • used an external HTTP client library
  • used the Content-Type response header to detect video files

methodology used in this branch

  • uses WebView to download all HTTP requests
  • uses regular expressions to detect file extensions associated with video formats in URL requests

Highlights of Source Code:

identification of video URLs in outbound HTTP requests:

same methodology as applied to a Chrome extension:


Legal: