44
44
<script >
45
45
import { defineComponent } from " vue" ;
46
46
47
- import daily, {
48
- type DailyCall ,
49
- type DailyEventObjectAppMessage ,
50
- type DailyEventObjectFatalError ,
51
- type DailyParticipant ,
52
- } from " @daily-co/daily-js" ;
47
+ import daily from " @daily-co/daily-js" ;
53
48
54
49
import WaitingCard from " ./WaitingCard.vue" ;
55
50
import ChatTile from " ./ChatTile.vue" ;
@@ -82,7 +77,7 @@ export default defineComponent({
82
77
required: true ,
83
78
},
84
79
},
85
- data (): CallTileData {
80
+ data () {
86
81
return {
87
82
callObject: null ,
88
83
participants: [],
@@ -161,7 +156,7 @@ export default defineComponent({
161
156
});
162
157
},
163
158
methods: {
164
- updateMedia (participantID : string , newTracks : Tracks ) {
159
+ updateMedia (participantID , newTracks ) {
165
160
// Get the video tag.
166
161
let videoTile = document .getElementById (
167
162
participantID
@@ -188,7 +183,7 @@ export default defineComponent({
188
183
// This will happen if this is the first time we're
189
184
// setting the tracks.
190
185
if (! existingStream || existingStream .getTracks ().length === 0 ) {
191
- const tracks: MediaStreamTrack [] = [];
186
+ const tracks = [];
192
187
if (newVideo) tracks .push (newVideo);
193
188
if (newAudio) tracks .push (newAudio);
194
189
const newStream = new MediaStream (tracks);
@@ -223,30 +218,30 @@ export default defineComponent({
223
218
}
224
219
},
225
220
refreshAudioTrack (
226
- existingStream: MediaStream ,
227
- newAudioTrack: MediaStreamTrack | null
228
- ): boolean {
221
+ existingStream,
222
+ newAudioTrack
223
+ ) {
229
224
// If there is no new track, just early out
230
225
// and keep the old track on the stream as-is.
231
226
if (! newAudioTrack) return false ;
232
227
const existingTracks = existingStream .getAudioTracks ();
233
228
return this .refreshTrack (existingStream, existingTracks, newAudioTrack);
234
229
},
235
230
refreshVideoTrack (
236
- existingStream: MediaStream ,
237
- newVideoTrack: MediaStreamTrack | null
238
- ): boolean {
231
+ existingStream,
232
+ newVideoTrack
233
+ ) {
239
234
// If there is no new track, just early out
240
235
// and keep the old track on the stream as-is.
241
236
if (! newVideoTrack) return false ;
242
237
const existingTracks = existingStream .getVideoTracks ();
243
238
return this .refreshTrack (existingStream, existingTracks, newVideoTrack);
244
239
},
245
240
refreshTrack (
246
- existingStream: MediaStream ,
247
- oldTracks: MediaStreamTrack[] ,
248
- newTrack: MediaStreamTrack
249
- ): boolean {
241
+ existingStream,
242
+ oldTracks,
243
+ newTrack
244
+ ) {
250
245
const trackCount = oldTracks .length ;
251
246
// If there is no matching old track,
252
247
// just add the new track.
@@ -269,7 +264,7 @@ export default defineComponent({
269
264
}
270
265
return false ;
271
266
},
272
- playMedia (video : HTMLVideoElement ) {
267
+ playMedia (video ) {
273
268
const isPlaying =
274
269
! video .paused &&
275
270
! video .ended &&
@@ -286,8 +281,8 @@ export default defineComponent({
286
281
console .warn (" Failed to play media." , e);
287
282
});
288
283
},
289
- getParticipantTracks (p : DailyParticipant ) {
290
- const mediaTracks: Tracks = {
284
+ getParticipantTracks (p ) {
285
+ const mediaTracks = {
291
286
videoTrack: null ,
292
287
audioTrack: null ,
293
288
};
@@ -312,13 +307,13 @@ export default defineComponent({
312
307
return mediaTracks;
313
308
},
314
309
// Add chat message to local message array
315
- updateMessages (e : DailyEventObjectAppMessage < any > | undefined ) {
310
+ updateMessages (e ) {
316
311
if (! e) return ;
317
312
console .log (" [MESSAGE] " , e .data );
318
313
this .messages .push (e? .data );
319
314
},
320
315
// Show local error in UI when daily-js reports an error
321
- handleError (e : DailyEventObjectFatalError | undefined ) {
316
+ handleError (e ) {
322
317
if (! e) return ;
323
318
console .log (" [ERROR] " , e);
324
319
this .error = e .errorMsg ;
@@ -357,7 +352,7 @@ export default defineComponent({
357
352
* because they do no receive an app-message Daily event for their
358
353
* own messages.
359
354
*/
360
- sendMessage (text : string ) {
355
+ sendMessage (text ) {
361
356
if (! this .callObject ) return ;
362
357
// Attach the local participant's username to the message to be displayed in ChatTile.vue
363
358
const local = this .callObject .participants ().local ;
0 commit comments