AdapterJS icon indicating copy to clipboard operation
AdapterJS copied to clipboard

Rework attachMediaStream() plugin implementation for better integration

Open ekzobrain opened this issue 9 years ago • 1 comments

It is general practice to hide the orignal element with style="display:none", not remove completely. Then you could restore it easily, and all of it's properties (even changed while working with plugin) would be preserved. Currently, yes, we have such a use case: by default video tag is opaque and user sees a picture behind it. When a call starts - peer's stream it attached to this video element. When a call ends video tag should becomes opaque again (that's why we need to detach media stream from it). And between calls some video files may be played in this video tag. Of course we could just replace video tag with a new one every time, but i think it is a bad approach. Also, this approach might be helpful in listening to video element events. For example, you hide video element and listen to it's "volumechange" event to enable/disable stream audio tracks. That would solve #34. So generally, user interracts with original video element, and you just proxy it's events to your plugin in some way. Of couse this approach needs investigation and testing, but i find it possible and perspective.

Conserning ID management:

Usually it is done this way: you leave original ID on it's place, and set ID of your inserted content to something like 'ID_plugin'. Then, when user want to manipulate original element some way - he can get it by original ID and does not get any mess. But when he uses attachMediaStream(), for example (calls one of your API methods), this method transparetly converts ID to ID_plugin and takes actions in favor of your inserted content. General idea here is that you transparently insert some new content and user (developer) even doesn't notice that, when working with original element's or your plugin's public API. For example, in method "attachMediaStream" it could look like this:

function attachMediaStream(element, stream) { var object_element = document.getElementById(element.id + '_plugin'); element = object_element; ...

ekzobrain avatar Apr 01 '15 21:04 ekzobrain

Thanks for the issue splitting. Again, really a good idea, we will get to it as soon as we can. :)

johache avatar Apr 01 '15 21:04 johache