Reputation: 32270
Objective:
Providing native support for the unsupported WebRTC JS APIs in WebKit and make WebRTC call through the webapp loaded in WkWebView.
So far What I have tried:
As of now WebRTC W3C JavaScript APIs is not supported in webkit.
There is a cross platform plugin available from cordova to support webRTC but I don't want to go cross platform way.
There is a webRTC native framework available but I don't want to go completely native way.
So far I was able to override navigator.getUserMedia in JavaScript
navigator.getUserMedia = function(constraints, onSuccess, onError){
myWebRTC.getUserMedia(document.getElementById('roomid').value)
}
and call native AppRTC SDK API to initiate the call from the native side and it works.
if let roomId=NSUserDefaults.standardUserDefaults().valueForKey("RoomId"){
appClient = ARDAppClient(delegate: self)
appClient?.createLocalMediaStream()
appClient?.connectToRoomWithId(String(roomId), options: nil)
localVideoView?.hidden = false;
remoteVideoView?.hidden = false;
btnDisconnect?.hidden = false;
webview?.hidden = true;
}
Here is the complete source code
AppRTC it has its own native video view, but I want to show the video in HTML element inside the webview.
AppRTC doesn't provide a video stream as well... even if I could a way to get the stream out of it. How can I give the stream to wkwebview is a challenge because its RTC with just evaluate JavaScript I don't think its possible.
So I have integrated CocoaHTTPServer and I am thinking of finding a way to stream from this to WkWebView.
Any insights, suggestions in achieving my objective is highly appreciated!
Upvotes: 2
Views: 1549
Reputation: 157
You can use the plugin iosRTC for iOS and crosswalk for android but we didn't found a cross platform plugin :/
Here our tutorial : https://apirtc.com/apirtc-on-cordova/
And one sample project with cordova : https://github.com/apizee/ApiRTC-mobile
Upvotes: 0