2016-07-27 16 views
0

Ich versuche, bidirektionalen Video-Chat unter iOS (9.3) mit cordova-plugin-opentokjs ( https://www.npmjs.com/package/cordova-plugin-opentokjs) cordova-plugin-iosrtc zu bekommen. Ich benutze Cordova 6.3.0 und OpenTok 2.8.1. Das Problem, das ich habe ist, dass wenn ich das Video starten ich einen Fehler von der Teilnehmerstrom erhalten wie folgt:OpenTok mit Cordova Fehler 1013 Medienressource nicht geeignet

[Error] TypeError: undefined is not a constructor (evaluating 'new global.AudioContext()') 
[Error] OT.exception :: title: Connection Failed (1013) msg: OT.Subscriber PeerConnection Error: There was an unexpected problem with the Video Stream: The media resource indicated by the src attribute was not suitable. 
[Error] No message (2) 
[Error] OT.exception :: title: Unexpected Server Response (2001) msg: Unexpected server response. Try this operation again later. 

Der Verlag Strom funktioniert gut ... zumindest ich selbst sehen kann (aber der andere Benutzer kann mich nicht sehen). Irgendwelche Ideen? Hier

ist einige relevante Code:

this.onDeviceReady = function() { 

    if (window.device.platform === 'iOS') { 
    cordova.plugins.iosrtc.registerGlobals(); 
    } 
}; 

Und wenn ich lese das Video Seite Ich (Aufruf initializeSession):

... 
initializePublisher: function() { 
    var self = this; 
    if (Globals.debug) 
    console.log("initializePublisher"); 

    if (!this.videoInputDevices || this.videoInputDevices.length === 0) 
    return; 

    var inputDevice = this.videoInputDevices[this.currentVideoDevice]; 
    if (!inputDevice || !inputDevice.deviceId) 
    return; 

    var $contianer = $('#openTokVideoContainer .mnOpenTokPublisherContainer'); 
    $contianer.empty(); 

    var $div = $('<div id="openTokPublisherStream"></div>'); 
    $contianer.append($div); 

    this.publisher = OT.initPublisher('openTokPublisherStream', { 
    width: '100%', 
    height: '100%', 
    fitMode: 'contain', 
    videoSource: inputDevice.deviceId, 
    mirror: (this.currentVideoDevice === 0) 
    }); 

    this.publisher.on('streamCreated', function(e) { 
    var stream = e.stream, 
     streamId = stream.streamId, 
     $div = $('#openTokVideoContainer .mnOpenTokPublisherContainer > *'); 

    $div.attr('data-stream', streamId); 
    console.log("Publisher stream: ", streamId); 
    }); 

    this.session.publish(this.publisher); 
}, 
initializeSession: function() { 
    var config = this.config, 
     self = this; 

    if (Globals.debug) 
    console.log("initializeSession"); 

    if (Globals.debug) 
    console.log("INIT SESSION " + config.sessionId + " TOKEN" + config.token); 

    this.session = OT.initSession(config.apiKey, config.sessionId); 
    this.session.on('streamCreated', function(e) { 
    var config = self.config; 
    if (Globals.debug) 
     console.log("onSessionConnected"); 

    self.subscribeToStream(e.stream, 'mnOpenTokSubscriberContainer'); 

    if (Globals.debug) 
     console.log("Stream created "); 
    }); 

    this.session.on('streamDestroyed', function(e) { 
    self.closeAllStreamSubscriptions(e.stream); 
    }); 

    this.session.connect(config.token, function (e) { 
    if (!self.publisher) { 
     self.getVideoDevices().then(function() { 
     self.initializePublisher(); 
     }); 
    } 
    }); 

    if (Globals.debug) 
    console.log("initializeSession"); 
},... 

Hilfe?

Edit: Nach vielen Kopfschlagen, Plugin-Updates, etc., ich habe jetzt ist es mir folgende Fehlermeldung (und das veröffentlichte Video nicht mehr funktioniert):

[Error] TypeError: undefined is not a constructor (evaluating 'new u(n.content)') 
[Error] TypeError: undefined is not a constructor (evaluating 'new u(n.content)') 
[Error] TypeError: undefined is not a constructor (evaluating 'new u(n.content)') 
[Error] TypeError: undefined is not a constructor (evaluating 'new u(n.content)') 
[Error] TypeError: undefined is not a constructor (evaluating 'new t({type:"offer",sdp:l.content.sdp})') 
[Error] TypeError: undefined is not a constructor (evaluating 'new u(n.content)') 
[Error] TypeError: undefined is not a constructor (evaluating 'new u(n.content)') 
[Error] TypeError: undefined is not a constructor (evaluating 'new u(n.content)') 
[Error] TypeError: undefined is not a constructor (evaluating 'new u(n.content)') 
[Error] TypeError: undefined is not a constructor (evaluating 'new u(n.content)') 
[Error] TypeError: undefined is not a constructor (evaluating 'new u(n.content)') 
[Error] TypeError: undefined is not a constructor (evaluating 'new u(n.content)') 
[Error] TypeError: undefined is not a constructor (evaluating 'new u(n.content)') 
[Error] TypeError: undefined is not a constructor (evaluating 'new u(n.content)') 
[Error] TypeError: undefined is not a constructor (evaluating 'new u(n.content)') 
[Error] TypeError: undefined is not a constructor (evaluating 'new u(n.content)') 
[Error] TypeError: undefined is not a constructor (evaluating 'new u(n.content)') 
[Error] TypeError: undefined is not a constructor (evaluating 'new u(n.content)') 
[Error] TypeError: undefined is not a constructor (evaluating 'new u(n.content)') 
[Error] TypeError: undefined is not a constructor (evaluating 'new u(n.content)') 
[Error] TypeError: undefined is not a constructor (evaluating 'new u(n.content)') 
[Error] TypeError: undefined is not a constructor (evaluating 'new u(n.content)') 
[Error] TypeError: undefined is not a constructor (evaluating 'new u(n.content)') 
[Error] TypeError: undefined is not a constructor (evaluating 'new u(n.content)') 
[Error] TypeError: undefined is not a constructor (evaluating 'new u(n.content)') 
[Error] OT.Publisher.onStreamAvailableError TypeError: Unknown Error while getting user media 
[Error] OT.exception :: title: Unable to Publish (1500) msg: GetUserMedia 
[Error] No message (2) 
[Error] No message (2) 
[Error] OT.exception :: title: Unexpected Server Response (2001) msg: Unexpected server response. Try this operation again later. 

Antwort

0

ich glaube, das Problem ist, Wenn die OpenTok-Bibliothek zu diesem Zeitpunkt in index.html enthalten ist, ist die WebRTC-API immer noch nicht im globalen Gültigkeitsbereich registriert. Die OpenTok-Bibliothek sollte geladen werden, nachdem die cordova.plugins.iosrtc.registerGlobals() ausgeführt wurde.

Verwenden Sie das folgende Skript am Ende des Körpers in der index.html dynamisch die OpenTok Bibliothek zu laden:

<script type="text/javascript"> 
    document.addEventListener("deviceready", function(){ 
    // cordova-plugin-device provides the device object 
    if (device && device.platform === 'iOS') { 
     cordova.plugins.iosrtc.registerGlobals(); 
    } 

    // Insert OpenTok library after the device is ready 
    var s = document.createElement('script'); 
    s.setAttribute('src', 'https://static.opentok.com/v2/js/opentok.min.js'); 
    document.body.appendChild(s); 
    }, false); 
</script>