muaz-khan / RTCMultiConnection

RTCMultiConnection is a WebRTC JavaScript library for peer-to-peer applications (screen sharing, audio/video conferencing, file sharing, media streaming etc.)
https://muazkhan.com:9001/
MIT License
2.57k stars 1.37k forks source link

ERROR: Method 'getUserMedia:' not defined in Plugin 'iosrtcPlugin' #712

Open Yagnik13 opened 5 years ago

Yagnik13 commented 5 years ago

Hello Guys, I face this is when I click on the open room in video conferencing demo in ios platform if you can help me out from it please help me.

I'm trying for the first time this demo so I don't have that much idea like you guys so thanks in advance

you can check my log below

2019-01-03 16:50:34.207236+0530 Video Conferencing[865:268076] [DYMTLInitPlatform] platform initialization successful 2019-01-03 16:50:34.323370+0530 Video Conferencing[865:267794] Apache Cordova native platform version 4.5.5 is starting. 2019-01-03 16:50:34.324765+0530 Video Conferencing[865:267794] Multi-tasking -> Device: YES, App: YES 2019-01-03 16:50:34.332852+0530 Video Conferencing[865:267794]

Started backup to iCloud! Please be careful. Your application might be rejected by Apple if you store too much data. For more information please read "iOS Data Storage Guidelines" at: https://developer.apple.com/icloud/documentation/data-storage/ To disable web storage backup to iCloud, set the BackupWebStorage preference to "local" in the Cordova config.xml file 2019-01-03 16:50:34.428069+0530 Video Conferencing[865:267794] Using UIWebView 2019-01-03 16:50:34.431100+0530 Video Conferencing[865:267794] [CDVTimer][console] 0.073910ms 2019-01-03 16:50:34.431280+0530 Video Conferencing[865:267794] [CDVTimer][handleopenurl] 0.115991ms 2019-01-03 16:50:34.432163+0530 Video Conferencing[865:267794] Unlimited access to network resources 2019-01-03 16:50:34.432421+0530 Video Conferencing[865:267794] Unlimited access to network resources 2019-01-03 16:50:34.432461+0530 Video Conferencing[865:267794] [CDVTimer][intentandnavigationfilter] 1.142979ms 2019-01-03 16:50:34.432545+0530 Video Conferencing[865:267794] [CDVTimer][gesturehandler] 0.043988ms 2019-01-03 16:50:34.437802+0530 Video Conferencing[865:267794] iosrtcPlugin#pluginInitialize() 2019-01-03 16:50:34.454096+0530 Video Conferencing[865:267794] PluginGetUserMedia#init() 2019-01-03 16:50:34.454129+0530 Video Conferencing[865:267794] [CDVTimer][iosrtcplugin] 21.559954ms 2019-01-03 16:50:34.464757+0530 Video Conferencing[865:267794] [CDVTimer][statusbar] 10.591984ms 2019-01-03 16:50:34.464796+0530 Video Conferencing[865:267794] [CDVTimer][TotalPluginStartup] 34.461975ms 2019-01-03 16:50:34.477725+0530 Video Conferencing[865:268058] Metal GPU Frame Capture Enabled 2019-01-03 16:50:34.479312+0530 Video Conferencing[865:268058] Metal API Validation Enabled 2019-01-03 16:50:36.005313+0530 Video Conferencing[865:267794] Resetting plugins due to page load. 2019-01-03 16:50:36.005408+0530 Video Conferencing[865:267794] iosrtcPlugin#onReset() | doing nothing 2019-01-03 16:50:37.180433+0530 Video Conferencing[865:267794] [] <<<< AVOutputDeviceDiscoverySession (FigRouteDiscoverer) >>>> -[AVFigRouteDiscovererOutputDeviceDiscoverySessionImpl outputDeviceDiscoverySessionDidChangeDiscoveryMode:]: Setting device discovery mode to DiscoveryMode_None (client: Video Conferencing) 2019-01-03 16:50:37.286433+0530 Video Conferencing[865:268101] [] <<<< AVOutputDeviceDiscoverySession (FigRouteDiscoverer) >>>> -[AVFigRouteDiscovererOutputDeviceDiscoverySessionImpl outputDeviceDiscoverySessionDidChangeDiscoveryMode:]: Setting device discovery mode to DiscoveryMode_Presence (client: Video Conferencing) 2019-01-03 16:50:37.362265+0530 Video Conferencing[865:267794] Finished load of: file:///var/containers/Bundle/Application/9B235441-3B89-4F20-9D2D-28066E00ABF8/Video%20Conferencing.app/www/index.html 2019-01-03 16:50:37.373507+0530 Video Conferencing[865:267794] iosrtc:videoElementsHandler video element found +0ms 2019-01-03 16:50:37.373552+0530 Video Conferencing[865:267794] iosrtc:videoElementsHandler observeVideo() +1ms 2019-01-03 16:50:37.373566+0530 Video Conferencing[865:267794] iosrtc:videoElementsHandler video element found +0ms 2019-01-03 16:50:37.373578+0530 Video Conferencing[865:267794] iosrtc:videoElementsHandler observeVideo() +0ms 2019-01-03 16:50:37.373590+0530 Video Conferencing[865:267794] iosrtc registerGlobals() +11ms 2019-01-03 16:50:37.373602+0530 Video Conferencing[865:267794] iosrtc registerGlobals() +0ms 2019-01-03 16:50:47.688203+0530 Video Conferencing[865:267794] iosrtc:getUserMedia [original constraints:{"audio":true,"video":{"mandatory":{},"optional":[{"facingMode":"user"}]}}] +10s 2019-01-03 16:50:47.688321+0530 Video Conferencing[865:267794] iosrtc:getUserMedia [computed constraints:{"audio":true,"video":true}] +2ms

issue part -----------------------------------------------------------------------------------------

2019-01-03 16:50:47.688488+0530 Video Conferencing[865:267794] ERROR: Method 'getUserMedia:' not defined in Plugin 'iosrtcPlugin' 2019-01-03 16:50:47.688639+0530 Video Conferencing[865:267794] -[CDVCommandQueue executePending] [Line 142] FAILED pluginJSON = ["iosrtcPlugin637489434","iosrtcPlugin","getUserMedia",[{"audio":true,"video":true}]] 2019-01-03 16:51:00.015714+0530 Video Conferencing[865:267794] Status bar could not find cached time string image. Rendering in-process.


muaz-khan commented 5 years ago

Please make sure to try their older releases:

And make sure that you're using this file:

Do you download or upgrade to their latest iosrtc-swift-support.js

PS. Here is relevant file that may require a little improvements especially if we're calling navigator.mediaDevices.getUserMedia and htmlVideoElement.srcObject.

Please make sure to remove adapter.js on your ios-compilations.

If will strongly recommend this until dev/ios-hacks.js gets updated:

connection.autoCreateMediaElement = false;
connection.dontCaptureUserMedia = true;

function beforeOpenOrJoinRoom(callback) {
    // behind the scene: cordova.plugins.iosrtc.getUserMedia(constrains, success, failure)
    navigator.getUserMedia(connection.mediaConstraints, function(stream) {
        connection.attachStreams.push(stream);
        showVideo(stream, true);
        callback();
    }, function(error) {});
}

function showVideo(stream, isMuted) {
    var video = document.createElement('video');
    if (isMuted) {
        video.muted = true;
        video.volume = 0;
    }
    video.src = URL.createObjectURL(stream);
    connection.videosContainer.appendChild(video);
    video.play();
}

connection.onstream = function(event) {
    showVideo(event.stream);
};

btnOpenRoom.onclick = function() {
    beforeOpenOrJoinRoom(function() {
        connection.open('roomid', function(isRoomOpened, rooid, error) {
            if (error) alert(error);
        });
    });
};

btnJoinRoom.onclick = function() {
    beforeOpenOrJoinRoom(function() {
        connection.join('roomid', function(isRoomJoined, rooid, error) {
            if (error) alert(error);
        });
    });
};

Explanation:

  1. autoCreateMediaElement=false ignores any video tag/element creation
  2. dontCaptureUserMedia=true ignores any getUserMedia invocation
  3. You are manually calling old getUserMedia API i.e. navigator.getUserMedia
  4. showVideo uses old-deprecated URL.createObjectURL instead of srcObject

Hope this works on iOS. Please try only on iOS (ipad/iphone).

Yagnik13 commented 5 years ago

Thanks for instant response

I did as per your instruction but still, nothing happens in my application. I'll share you a zip file of my project if you find something wrong in it.

@muaz-khan please check below link and please share the mistake if any found

https://drive.google.com/drive/folders/1Z-bvfvRNZwliTE2RB9EBDkdDeracZT9m?usp=sharing