Skip to content

Commit be5bacb

Browse files
author
Jeremy White
committed
Fixed crashing bug with getting current time and duration
1 parent 928bfd6 commit be5bacb

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

scripts/connectsdk.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -544,28 +544,38 @@ var connectsdk = (function () {
544544
}
545545
} else if (commandType === 'getPosition')
546546
{
547+
var currentTime = 0;
548+
549+
if (mediaElement && mediaElement.currentTime)
550+
currentTime = mediaElement.currentTime;
551+
547552
this._send({
548553
type: 'p2p',
549554
to: from,
550555
payload: {
551556
contentType: 'connectsdk.mediaCommandResponse',
552557
mediaCommandResponse: {
553558
type: commandType,
554-
position: mediaElement.currentTime,
559+
position: currentTime,
555560
requestId:requestId
556561
}
557562
}
558563
});
559564
} else if (commandType === 'getDuration')
560565
{
566+
var duration = 0;
567+
568+
if (mediaElement && mediaElement.duration)
569+
duration = mediaElement.duration;
570+
561571
this._send({
562572
type: 'p2p',
563573
to: from,
564574
payload: {
565575
contentType: 'connectsdk.mediaCommandResponse',
566576
mediaCommandResponse: {
567577
type: commandType,
568-
duration: mediaElement.duration,
578+
duration: duration,
569579
requestId:requestId
570580
}
571581
}

0 commit comments

Comments
 (0)