Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make private properties more private #34

Closed
calebboyd opened this issue Jul 24, 2015 · 4 comments
Closed

Make private properties more private #34

calebboyd opened this issue Jul 24, 2015 · 4 comments

Comments

@calebboyd
Copy link
Contributor

I ran into this issue when trying to load Twilio on the iPad.

Referring to these properties specifically:
https://github.com/eface2face/cordova-plugin-iosrtc/blob/master/js/MediaStream.js#L66-L70

Twilio has a method that looks like this:

PeerConnection.prototype.attachAudio = function(callback) {
        if (this.stream) {
            var audioTracks = this.stream.audioTracks || this.stream.getAudioTracks();
            audioTracks[0].enabled = true;
        }
        if (callback && typeof callback == "function") {
            callback();
        }
}

As you can see it errors when accessing the [0].enabled property of this.stream.audioTracks

I've filed an issue in Twilio to prefer spec.. But it would probably be good for the module hide its private state better anyway.

Also.. Thank you for a great plugin!

@ibc ibc closed this as completed in 655b3de Jul 25, 2015
@ibc
Copy link
Collaborator

ibc commented Jul 25, 2015

Why is Twilo calling stream.audioTracks? A MediaStream does not have such a property...

@calebboyd
Copy link
Contributor Author

I have no idea -- it is pretty odd... I'll let you know If I hear back from them on the matter.. Thanks for making that change

@markandrus
Copy link

Prior to Chrome 26, audioTracks was a property on MediaStream. Chrome 26 introduced the getAudioTracks() method. The compat code could probably be changed to

var audioTracks = typeof this.stream.getAudioTracks === 'function'
  ? this.stream.getAudioTracks() : this.stream.audioTracks;

@calebboyd
Copy link
Contributor Author

Just saw this, Thanks for the clarification @markandrus

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants