This repository has been archived by the owner on Jan 18, 2023. It is now read-only.
forked from msach22/cordova-plugin-opentok
-
Notifications
You must be signed in to change notification settings - Fork 80
#50 - Update the view when <video>
elements are added or removed from the DOM (or when it's style or any parent style changes)
#59
Open
wolfenrain
wants to merge
9
commits into
opentok:main
Choose a base branch
from
Mediapioniers:issue-50
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 7 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
bbd0ab1
DOM & Video observables
00aceae
Merge branch '3.2.0' of https://github.com/opentok/cordova-plugin-ope…
a2fc832
Timeoffset for angular/ionic on slower devices..
41efaae
Added check if zIndex changed.
a27d4eb
OTSubscriber, added type check in EventReceived
cebe4cf
Merge branch 'master' of https://github.com/opentok/cordova-plugin-op…
f4ec3da
Merge branch 'master' of https://github.com/opentok/cordova-plugin-op…
ffbbe76
#50 Implemented fixes, and extra check for MutationObserver
c731bc9
#50 Removed change that should be its own change(#110)
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -119,7 +119,6 @@ class TBSession | |
element = @publisher.pubElement | ||
if(element) | ||
@resetElement(element) | ||
TBUpdateObjects() | ||
return Cordova.exec(TBSuccess, TBError, OTPlugin, "unpublish", [] ) | ||
unsubscribe: (subscriber) -> | ||
console.log("JS: Unsubscribe") | ||
|
@@ -130,7 +129,6 @@ class TBSession | |
if(element) | ||
@resetElement(element) | ||
delete( streamElements[ elementId ] ) | ||
TBUpdateObjects() | ||
return Cordova.exec(TBSuccess, TBError, OTPlugin, "unsubscribe", [subscriber.streamId] ) | ||
|
||
constructor: (@apiKey, @sessionId) -> | ||
|
@@ -166,7 +164,11 @@ class TBSession | |
# event listeners | ||
# todo - other events: connectionCreated, connectionDestroyed, signal?, streamPropertyChanged, signal:type? | ||
eventReceived: (response) => | ||
@[response.eventType](response.data) | ||
pdebug "session event received", response | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please remove this line, we don't need to log these events |
||
if typeof @[response.eventType] == "function" | ||
@[response.eventType](response.data) | ||
else | ||
pdebug "No method found for EventType: '" + response.eventType + "'"; | ||
connectionCreated: (event) => | ||
connection = new TBConnection( event.connection ) | ||
connectionEvent = new TBEvent("connectionCreated") | ||
|
@@ -183,12 +185,31 @@ class TBSession | |
delete( @connections[ connection.connectionId] ) | ||
return @ | ||
sessionConnected: (event) => | ||
pdebug "sessionConnectedHandler", event | ||
OTDomObserver.observe(document, { | ||
# Set to true if additions and removals of the target node's child elements (including text nodes) are to be observed. | ||
childList: true | ||
# Set to true if mutations to target's attributes are to be observed. | ||
attributes: true | ||
# Set to true if mutations to target's data are to be observed. | ||
characterData: false | ||
# Set to true if mutations to not just target, but also target's descendants are to be observed. | ||
subtree: true | ||
# Set to true if attributes is set to true and target's attribute value before the mutation needs to be recorded. | ||
attributeOldValue: false | ||
# Set to true if characterData is set to true and target's data before the mutation needs to be recorded. | ||
characterDataOldValue: false | ||
# Set to an array of attribute local names (without namespace) if not all attribute mutations need to be observed. | ||
attributeFilter: ['style', 'class'] | ||
}) | ||
@dispatchEvent(new TBEvent("sessionConnected")) | ||
@connection = new TBConnection( event.connection ) | ||
@connections[event.connection.connectionId] = @connection | ||
event = null | ||
return @ | ||
sessionDisconnected: (event) => | ||
pdebug "sessionDisconnected event", event | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please remove this, we do not need to log this event. |
||
OTDomObserver.disconnect() | ||
@alreadyPublishing = false | ||
sessionDisconnectedEvent = new TBEvent("sessionDisconnected") | ||
sessionDisconnectedEvent.reason = event.reason | ||
|
@@ -206,6 +227,7 @@ class TBSession | |
streamCreated: (event) => | ||
stream = new TBStream( event.stream, @connections[event.stream.connectionId] ) | ||
@streams[ stream.streamId ] = stream | ||
OT.timeStreamCreated[stream.streamId] = performance.now() | ||
streamEvent = new TBEvent("streamCreated") | ||
streamEvent.stream = stream | ||
#streamEvent = new TBEvent( {stream: stream } ) | ||
|
@@ -223,7 +245,6 @@ class TBSession | |
if(element) | ||
@resetElement(element) | ||
delete( streamElements[ stream.streamId ] ) | ||
TBUpdateObjects() | ||
delete( @streams[ stream.streamId ] ) | ||
return @ | ||
streamPropertyChanged: (event) -> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -74,14 +74,22 @@ class TBSubscriber | |
width = DefaultWidth | ||
height = DefaultHeight | ||
obj = replaceWithVideoStream(@element, stream.streamId, {width:width, height:height, insertMode:insertMode}) | ||
# If element is not yet in body, set it to 0 and then the observer will set it properly. | ||
if !document.body.contains(@element) | ||
width = 0; | ||
height = 0; | ||
position = getPosition(@element) | ||
ratios = TBGetScreenRatios() | ||
OT.getHelper().eventing(@) | ||
Cordova.exec(TBSuccess, TBError, OTPlugin, "subscribe", [stream.streamId, position.top, position.left, width, height, zIndex, subscribeToAudio, subscribeToVideo, ratios.widthRatio, ratios.heightRatio] ) | ||
Cordova.exec(@eventReceived, TBSuccess, OTPlugin, "addEvent", ["subscriberEvents"] ) | ||
|
||
eventReceived: (response) => | ||
@[response.eventType](response.data) | ||
pdebug "subscriber event received", response | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please remove this because this causes issues with stats events which are fired constantly. We don't need to log to the console each time we receive this event. |
||
if typeof @[response.eventType] == "function" | ||
@[response.eventType](response.data) | ||
else | ||
pdebug "No method found for EventType: '" + response.eventType + "'"; | ||
connected: (event) => | ||
streamEvent = new TBEvent("connected") | ||
streamEvent.stream = event.streamId | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this line changes
position
tothis.position
lines 36 and 37 should also change toposition
tothis.position
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lines 37 and 37 have been changed to use the
@position