Skip to content

Commit ca8906c

Browse files
Merge pull request #2095 from twilio/prep-2.31.0
Prep 2.31.0
2 parents 1fbd6f6 + 212b9f4 commit ca8906c

File tree

13 files changed

+18381
-55
lines changed

13 files changed

+18381
-55
lines changed

.circleci/config.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,15 @@ executors:
7474
<<: *defaultEnv
7575
generic-executor:
7676
docker:
77-
- image: alpine:3.7
77+
- image: alpine:3.21
7878
auth:
7979
username: $DOCKER_HUB_USERNAME
8080
password: $DOCKER_HUB_PASSWORD
8181
environment:
8282
<<: *defaultEnv
8383
machine-executor:
8484
machine:
85-
image: ubuntu-2004:202111-02
85+
image: ubuntu-2404:current
8686
environment:
8787
<<: *defaultEnv
8888
commands:

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ test/crossbrowser/src/browser/index.js
1111
test/lib/sdkdriver/lib
1212
test/lib/sdkdriver/test/integration/browser/index.js
1313
npm-debug.log
14-
package-lock.json
1514
test.json
1615
nodemon.json
1716
yarn.lock

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@ The Twilio Programmable Video SDKs use [Semantic Versioning](http://www.semver.o
22

33
**Version 1.x reached End of Life on September 8th, 2021.** See the changelog entry [here](https://www.twilio.com/changelog/end-of-life-complete-for-unsupported-versions-of-the-programmable-video-sdk). Support for the 1.x version ended on December 4th, 2020.
44

5+
2.31.0 (April 21, 2025)
6+
=======================
7+
8+
New Features
9+
------------
10+
11+
### Document Picture-in-Picture API Support
12+
13+
Previously, when `Client Track Switch Off Control` was set to `auto`, video tracks were automatically switched off—even if they were visible and rendered in a [Document Picture-in-Picture](https://developer.chrome.com/docs/web-platform/document-picture-in-picture) (PiP) window. This caused issues where users could see the video element, but the track itself was disabled. In this new SDK version, video tracks will remain active and continue to play when displayed in a PiP window.
14+
515
2.30.0 (March 28, 2025)
616
========================
717

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ Releases of twilio-video.js are hosted on a CDN, and you can include these
7474
directly in your web app using a &lt;script&gt; tag.
7575

7676
```html
77-
<script src="//sdk.twilio.com/js/video/releases/2.30.0/twilio-video.min.js"></script>
77+
<script src="//sdk.twilio.com/js/video/releases/2.31.0/twilio-video.min.js"></script>
7878
```
7979

8080
Using this method, twilio-video.js will set a browser global:

appveyor.yml

Lines changed: 0 additions & 20 deletions
This file was deleted.

lib/media/track/remotevideotrack.js

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -338,15 +338,19 @@ class RemoteVideoTrack extends RemoteMediaVideoTrack {
338338
}
339339
}
340340

341-
function setupDocumentVisibilityTurnOff(removeVideoTrack) {
342-
function onVisibilityChanged() {
343-
maybeUpdateEnabledHint(removeVideoTrack);
341+
function isAttachedToDocumentPip(remoteVideoTrack) {
342+
if (!('documentPictureInPicture' in globalThis)) {
343+
return false;
344344
}
345345

346-
documentVisibilityMonitor.onVisibilityChange(1, onVisibilityChanged);
347-
return () => {
348-
documentVisibilityMonitor.offVisibilityChange(1, onVisibilityChanged);
349-
};
346+
const pipWindow = globalThis.documentPictureInPicture.window;
347+
if (!pipWindow) {
348+
return false;
349+
}
350+
351+
const pipEls = new WeakSet(pipWindow.document.querySelectorAll('video'));
352+
353+
return remoteVideoTrack._getAllAttachedElements().some(el => pipEls.has(el));
350354
}
351355

352356
function maybeUpdateEnabledHint(remoteVideoTrack) {
@@ -358,7 +362,9 @@ function maybeUpdateEnabledHint(remoteVideoTrack) {
358362
const pipWindows = remoteVideoTrack._getAllAttachedElements().filter(el => remoteVideoTrack._elToPipWindows.has(el));
359363

360364
// even when document is invisible we may have track playing in pip window.
361-
const enabled = pipWindows.length > 0 || (document.visibilityState === 'visible' && visibleElements.length > 0);
365+
const enabled = pipWindows.length > 0 ||
366+
isAttachedToDocumentPip(remoteVideoTrack) ||
367+
(document.visibilityState === 'visible' && visibleElements.length > 0);
362368

363369
if (enabled === true) {
364370
remoteVideoTrack._turnOffTimer.clear();
@@ -388,6 +394,17 @@ function maybeUpdateDimensionHint(remoteVideoTrack) {
388394
}
389395
}
390396

397+
function setupDocumentVisibilityTurnOff(removeVideoTrack) {
398+
function onVisibilityChanged() {
399+
maybeUpdateEnabledHint(removeVideoTrack);
400+
}
401+
402+
documentVisibilityMonitor.onVisibilityChange(1, onVisibilityChanged);
403+
return () => {
404+
documentVisibilityMonitor.offVisibilityChange(1, onVisibilityChanged);
405+
};
406+
}
407+
391408
/**
392409
* @typedef {object} VideoContentPreferences
393410
* @property {VideoTrack.Dimensions} [renderDimensions] - Render Dimensions to request for the {@link RemoteVideoTrack}.

0 commit comments

Comments
 (0)