0

I have gone through the latest Google cast SDK. I have also gone through the share extension and other extension app creation for iOS.

my question is is it possible to make an extension which will be by default added to all browser of iOS device and when user click on this, this will start casting the video to Chromecast.

I am sorry, this is very wide question so I don't exactly require codes, just hint of something will do.

Saty
  • 2,563
  • 3
  • 37
  • 88

1 Answers1

0

tldr: the media part is solvable, the chromecast part may be impossible.

App Extension

An Action Extension permits you to execute JavaScript on the current page. You could then search the webpage for media links and allow the user to select which video they wish to see (if there is more than one, for example). This might be problematic for very dynamic pages but would probably work. I did this to look for HTML elements with id's to make them linkable/bookmarkable elements.

Details

My app extension configuration looked like below, but instead of having an NSExtensionActivationRule of *SupportsWebPage* or *SupportsWebUrl* you may wish to use NSExtensionActivationSupportsMovieWithMaxCount:

<key>NSExtensionAttributes</key>
<dict>
    <key>NSExtensionActivationRule</key>
    <dict>
        <key>NSExtensionActivationSupportsWebPageWithMaxCount</key>
        <integer>1</integer>
        <key>NSExtensionActivationSupportsWebUrlWithMaxCount</key>
        <integer>0</integer>
    </dict>
    <key>NSExtensionJavaScriptPreprocessingFile</key>
    <string>you_must_write_this.js</string>
</dict>

Chrome and Firefox on iOS are not showing my app extension, but that may be because my NSActivationExtensionRule is not matching.

The NSExtensionJavaScriptPreprocessingFile value is a file YOU include in the project which is written in JavaScript and conforms to the API described here. You probably want to rename it from you_must_write_this.js.

ChromeCast

This part I'm not sure about, and I'm looking at this right now but: Some APIs Are Unavailable to App Extensions outlines the limitations of App Extensions.

[...] An app extension cannot: [...] Access a sharedApplication object, and so cannot use any of the methods on that object

Doing a grep -r sharedApplication ./Pods in a new ChromeCast app I'm writing shows:

Binary file ./Pods/google-cast-sdk/GoogleCastSDK-Public-3.2.0-Release/GoogleCast.framework/GoogleCast matches

Note there's also a limitation to prevent long running code, so any code you write must be complete when the App Extension UI closes. The ChromeCast can continue of course, but your UI elements will be closed (which will make reconnecting to the ChromeCast slower).

I will experiment and get back, but I'm not very hopeful.

edit1: My current experiments show:

CastQuick log -[GCKNNetworkReachability startMonitoring]  startMonitoring
CastQuick log -[GCKRuntimeConfiguration httpRequest:didFailWithError:]  download request failed with: Error Domain=NSURLErrorDomain Code=-995 "(null)"

This appears to be an app extension limitation that requires the GoogleCast SDK use your containing app's group ID when using NSURLSession since background uploads and downloads will share with/open the main app.

Other APIs have had to expose a configurable variable to do so, my guess is a bug/enhancement against the GoogleCast API would need to be created.

J. Longman
  • 101
  • 1
  • 7