Skip to content

Commit bbb96ae

Browse files
committed
Updates examples and docs for 2.x
* Updates the example. * Removes the android-specific example. Since the two platforms are pretty much in sync now, it doens't make sense to have two separate examples to grok. * Update the example in the readme. * Add in the section in the readme about migrating from 1.x to 2.x.
1 parent 1e27e37 commit bbb96ae

File tree

3 files changed

+28
-104
lines changed

3 files changed

+28
-104
lines changed

Example/index.android.js

Lines changed: 0 additions & 88 deletions
This file was deleted.
Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ export default class Example extends Component {
139139
this.setState({
140140
videoTracks: new Map([
141141
...this.state.videoTracks,
142-
[track.trackId, { ...participant, ...track }]
142+
[track.trackSid, { participantSid: participant.sid, videoTrackSid: track.trackSid }]
143143
]),
144144
});
145145
}
@@ -148,7 +148,7 @@ export default class Example extends Component {
148148
console.log("onParticipantRemovedVideoTrack: ", participant, track)
149149

150150
const videoTracks = this.state.videoTracks
151-
videoTracks.delete(track.trackId)
151+
videoTracks.delete(track.trackSid)
152152

153153
this.setState({ videoTracks: new Map([ ...videoTracks ]) });
154154
}
@@ -189,15 +189,12 @@ export default class Example extends Component {
189189
this.state.status === 'connected' &&
190190
<View style={styles.remoteGrid}>
191191
{
192-
Array.from(this.state.videoTracks, ([trackId, track]) => {
192+
Array.from(this.state.videoTracks, ([trackSid, trackIdentifier]) => {
193193
return (
194194
<TwilioVideoParticipantView
195195
style={styles.remoteVideo}
196-
key={trackId}
197-
trackIdentifier={{
198-
participantIdentity: track.identity,
199-
videoTrackId: trackId
200-
}}
196+
key={trackSid}
197+
trackIdentifier={trackIdentifier}
201198
/>
202199
)
203200
})

README.md

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -214,14 +214,19 @@ export default class Example extends Component {
214214
_onParticipantAddedVideoTrack = ({participant, track}) => {
215215
console.log("onParticipantAddedVideoTrack: ", participant, track)
216216

217-
this.setState({videoTracks: { ...this.state.videoTracks, [track.trackId]: { ...participant, ...track }}})
217+
this.setState({
218+
videoTracks: new Map([
219+
...this.state.videoTracks,
220+
[track.trackSid, { participantSid: participant.sid, videoTrackSid: track.trackSid }]
221+
]),
222+
});
218223
}
219224

220225
_onParticipantRemovedVideoTrack = ({participant, track}) => {
221226
console.log("onParticipantRemovedVideoTrack: ", participant, track)
222227

223228
const videoTracks = this.state.videoTracks
224-
videoTracks.delete(track.trackId)
229+
videoTracks.delete(track.trackSid)
225230

226231
this.setState({videoTracks: { ...videoTracks }})
227232
}
@@ -262,15 +267,12 @@ export default class Example extends Component {
262267
this.state.status === 'connected' &&
263268
<View style={styles.remoteGrid}>
264269
{
265-
Object.keys(this.state.videoTracks).map(trackId => {
270+
Array.from(this.state.videoTracks, ([trackSid, trackIdentifier]) => {
266271
return (
267272
<TwilioVideoParticipantView
268273
style={styles.remoteVideo}
269-
key={trackId}
270-
trackIdentifier={{
271-
participantIdentity: this.state.videoTracks[trackId].identity,
272-
videoTrackId: trackId
273-
}}
274+
key={trackSid}
275+
trackIdentifier={trackIdentifier}
274276
/>
275277
)
276278
})
@@ -327,6 +329,19 @@ To run the example application:
327329
- Install objective-c dependencies: `cd ios && pod install`
328330
- Open the xcworkspace and run the app: `open Example.xcworkspace`
329331

332+
## Migrating from 1.x to 2.x
333+
334+
* Make sure your pod dependencies are updated. If you manually specified a pod version, you'll want to update it as follows:
335+
336+
```
337+
s.dependency 'TwilioVideo', '~> 2.2.0'
338+
```
339+
340+
* Both participants and tracks are uniquely identified by their `sid`/`trackSid` field.
341+
The `trackId` field no longer exists and should be replaced by `trackSid`. Commensurate with this change,
342+
participant views now expect `participantSid` and `videoTrackSid` keys in the `trackIdentity` prop (instead of
343+
`identity` and `trackId`).
344+
330345
## Contact
331346

332347
- Martín Fernández <fmartin91@gmail.com>

0 commit comments

Comments
 (0)