@thestatic-tv/dcl-sdk 2.4.0 → 2.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +12 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +44 -15
- package/dist/index.mjs +44 -15
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -45,6 +45,12 @@ interface StaticTVConfig {
|
|
|
45
45
|
* ```
|
|
46
46
|
*/
|
|
47
47
|
videoScreen?: Entity;
|
|
48
|
+
/**
|
|
49
|
+
* Fallback video URL to play when no stream is active or stopVideo() is called.
|
|
50
|
+
* Prevents "broken screen" appearance. Set to empty string to disable.
|
|
51
|
+
* @default 'https://media.thestatic.tv/fallback-loop.mp4'
|
|
52
|
+
*/
|
|
53
|
+
fallbackVideoUrl?: string;
|
|
48
54
|
/**
|
|
49
55
|
* Scene ID for Admin Panel API calls.
|
|
50
56
|
* Optional - defaults to API key ID if not provided.
|
|
@@ -998,9 +1004,15 @@ declare class StaticTVClient {
|
|
|
998
1004
|
playVideo(url: string): void;
|
|
999
1005
|
/**
|
|
1000
1006
|
* Stop video playback on the configured videoScreen entity.
|
|
1007
|
+
* If fallbackVideoUrl is configured (default), plays the fallback loop.
|
|
1001
1008
|
* Called by Admin Panel.
|
|
1002
1009
|
*/
|
|
1003
1010
|
stopVideo(): void;
|
|
1011
|
+
/**
|
|
1012
|
+
* Internal video player - handles both regular videos and fallback
|
|
1013
|
+
* @internal
|
|
1014
|
+
*/
|
|
1015
|
+
private _playVideoInternal;
|
|
1004
1016
|
/**
|
|
1005
1017
|
* Get the currently playing video URL
|
|
1006
1018
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -45,6 +45,12 @@ interface StaticTVConfig {
|
|
|
45
45
|
* ```
|
|
46
46
|
*/
|
|
47
47
|
videoScreen?: Entity;
|
|
48
|
+
/**
|
|
49
|
+
* Fallback video URL to play when no stream is active or stopVideo() is called.
|
|
50
|
+
* Prevents "broken screen" appearance. Set to empty string to disable.
|
|
51
|
+
* @default 'https://media.thestatic.tv/fallback-loop.mp4'
|
|
52
|
+
*/
|
|
53
|
+
fallbackVideoUrl?: string;
|
|
48
54
|
/**
|
|
49
55
|
* Scene ID for Admin Panel API calls.
|
|
50
56
|
* Optional - defaults to API key ID if not provided.
|
|
@@ -998,9 +1004,15 @@ declare class StaticTVClient {
|
|
|
998
1004
|
playVideo(url: string): void;
|
|
999
1005
|
/**
|
|
1000
1006
|
* Stop video playback on the configured videoScreen entity.
|
|
1007
|
+
* If fallbackVideoUrl is configured (default), plays the fallback loop.
|
|
1001
1008
|
* Called by Admin Panel.
|
|
1002
1009
|
*/
|
|
1003
1010
|
stopVideo(): void;
|
|
1011
|
+
/**
|
|
1012
|
+
* Internal video player - handles both regular videos and fallback
|
|
1013
|
+
* @internal
|
|
1014
|
+
*/
|
|
1015
|
+
private _playVideoInternal;
|
|
1004
1016
|
/**
|
|
1005
1017
|
* Get the currently playing video URL
|
|
1006
1018
|
*/
|
package/dist/index.js
CHANGED
|
@@ -3494,6 +3494,7 @@ function setupStaticUI(client) {
|
|
|
3494
3494
|
// src/StaticTVClient.ts
|
|
3495
3495
|
var import_ecs3 = require("@dcl/sdk/ecs");
|
|
3496
3496
|
var DEFAULT_BASE_URL = "https://thestatic.tv/api/v1/dcl";
|
|
3497
|
+
var DEFAULT_FALLBACK_VIDEO = "https://media.thestatic.tv/fallback-loop.mp4";
|
|
3497
3498
|
var KEY_TYPE_CHANNEL = "channel";
|
|
3498
3499
|
var KEY_TYPE_SCENE = "scene";
|
|
3499
3500
|
var StaticTVClient = class {
|
|
@@ -3731,17 +3732,7 @@ var StaticTVClient = class {
|
|
|
3731
3732
|
if (screen !== void 0) {
|
|
3732
3733
|
this.log(`Playing video: ${url}`);
|
|
3733
3734
|
this._currentVideoUrl = url;
|
|
3734
|
-
|
|
3735
|
-
import_ecs3.VideoPlayer.deleteFrom(screen);
|
|
3736
|
-
}
|
|
3737
|
-
import_ecs3.VideoPlayer.create(screen, {
|
|
3738
|
-
src: url,
|
|
3739
|
-
playing: true,
|
|
3740
|
-
volume: 1
|
|
3741
|
-
});
|
|
3742
|
-
import_ecs3.Material.setBasicMaterial(screen, {
|
|
3743
|
-
texture: import_ecs3.Material.Texture.Video({ videoPlayerEntity: screen })
|
|
3744
|
-
});
|
|
3735
|
+
this._playVideoInternal(url, false);
|
|
3745
3736
|
if (this.guideUI) {
|
|
3746
3737
|
const videos = this.guideUI.getVideos();
|
|
3747
3738
|
const video = videos.find((v) => v.src === url);
|
|
@@ -3756,22 +3747,55 @@ var StaticTVClient = class {
|
|
|
3756
3747
|
}
|
|
3757
3748
|
/**
|
|
3758
3749
|
* Stop video playback on the configured videoScreen entity.
|
|
3750
|
+
* If fallbackVideoUrl is configured (default), plays the fallback loop.
|
|
3759
3751
|
* Called by Admin Panel.
|
|
3760
3752
|
*/
|
|
3761
3753
|
stopVideo() {
|
|
3762
3754
|
const screen = this.config.videoScreen;
|
|
3763
|
-
if (screen !== void 0
|
|
3764
|
-
this.log("Stopping video");
|
|
3765
|
-
import_ecs3.VideoPlayer.getMutable(screen).playing = false;
|
|
3766
|
-
this._currentVideoUrl = "";
|
|
3755
|
+
if (screen !== void 0) {
|
|
3767
3756
|
if (this.guideUI) {
|
|
3768
3757
|
this.guideUI.currentVideoId = null;
|
|
3769
3758
|
}
|
|
3759
|
+
const fallbackUrl = this.config.fallbackVideoUrl;
|
|
3760
|
+
const fallbackDisabled = fallbackUrl === "";
|
|
3761
|
+
if (fallbackDisabled) {
|
|
3762
|
+
if (import_ecs3.VideoPlayer.has(screen)) {
|
|
3763
|
+
this.log("Stopping video (no fallback)");
|
|
3764
|
+
import_ecs3.VideoPlayer.getMutable(screen).playing = false;
|
|
3765
|
+
}
|
|
3766
|
+
this._currentVideoUrl = "";
|
|
3767
|
+
} else {
|
|
3768
|
+
const url = fallbackUrl || DEFAULT_FALLBACK_VIDEO;
|
|
3769
|
+
this.log(`Playing fallback: ${url}`);
|
|
3770
|
+
this._currentVideoUrl = "";
|
|
3771
|
+
this._playVideoInternal(url, true);
|
|
3772
|
+
}
|
|
3770
3773
|
}
|
|
3771
3774
|
if (this.config.onVideoStop) {
|
|
3772
3775
|
this.config.onVideoStop();
|
|
3773
3776
|
}
|
|
3774
3777
|
}
|
|
3778
|
+
/**
|
|
3779
|
+
* Internal video player - handles both regular videos and fallback
|
|
3780
|
+
* @internal
|
|
3781
|
+
*/
|
|
3782
|
+
_playVideoInternal(url, isFallback = false) {
|
|
3783
|
+
const screen = this.config.videoScreen;
|
|
3784
|
+
if (screen === void 0) return;
|
|
3785
|
+
if (import_ecs3.VideoPlayer.has(screen)) {
|
|
3786
|
+
import_ecs3.VideoPlayer.deleteFrom(screen);
|
|
3787
|
+
}
|
|
3788
|
+
import_ecs3.VideoPlayer.create(screen, {
|
|
3789
|
+
src: url,
|
|
3790
|
+
playing: true,
|
|
3791
|
+
loop: isFallback,
|
|
3792
|
+
// Loop fallback videos
|
|
3793
|
+
volume: 1
|
|
3794
|
+
});
|
|
3795
|
+
import_ecs3.Material.setBasicMaterial(screen, {
|
|
3796
|
+
texture: import_ecs3.Material.Texture.Video({ videoPlayerEntity: screen })
|
|
3797
|
+
});
|
|
3798
|
+
}
|
|
3775
3799
|
/**
|
|
3776
3800
|
* Get the currently playing video URL
|
|
3777
3801
|
*/
|
|
@@ -3783,6 +3807,11 @@ var StaticTVClient = class {
|
|
|
3783
3807
|
* @internal
|
|
3784
3808
|
*/
|
|
3785
3809
|
_handleGuideVideoSelect(video) {
|
|
3810
|
+
if (video.channelId && video.isLive === false) {
|
|
3811
|
+
this.showNotification(`${video.name} is offline`);
|
|
3812
|
+
this.stopVideo();
|
|
3813
|
+
return;
|
|
3814
|
+
}
|
|
3786
3815
|
if (video.src) {
|
|
3787
3816
|
this.playVideo(video.src);
|
|
3788
3817
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -3451,6 +3451,7 @@ function setupStaticUI(client) {
|
|
|
3451
3451
|
// src/StaticTVClient.ts
|
|
3452
3452
|
import { VideoPlayer, Material } from "@dcl/sdk/ecs";
|
|
3453
3453
|
var DEFAULT_BASE_URL = "https://thestatic.tv/api/v1/dcl";
|
|
3454
|
+
var DEFAULT_FALLBACK_VIDEO = "https://media.thestatic.tv/fallback-loop.mp4";
|
|
3454
3455
|
var KEY_TYPE_CHANNEL = "channel";
|
|
3455
3456
|
var KEY_TYPE_SCENE = "scene";
|
|
3456
3457
|
var StaticTVClient = class {
|
|
@@ -3688,17 +3689,7 @@ var StaticTVClient = class {
|
|
|
3688
3689
|
if (screen !== void 0) {
|
|
3689
3690
|
this.log(`Playing video: ${url}`);
|
|
3690
3691
|
this._currentVideoUrl = url;
|
|
3691
|
-
|
|
3692
|
-
VideoPlayer.deleteFrom(screen);
|
|
3693
|
-
}
|
|
3694
|
-
VideoPlayer.create(screen, {
|
|
3695
|
-
src: url,
|
|
3696
|
-
playing: true,
|
|
3697
|
-
volume: 1
|
|
3698
|
-
});
|
|
3699
|
-
Material.setBasicMaterial(screen, {
|
|
3700
|
-
texture: Material.Texture.Video({ videoPlayerEntity: screen })
|
|
3701
|
-
});
|
|
3692
|
+
this._playVideoInternal(url, false);
|
|
3702
3693
|
if (this.guideUI) {
|
|
3703
3694
|
const videos = this.guideUI.getVideos();
|
|
3704
3695
|
const video = videos.find((v) => v.src === url);
|
|
@@ -3713,22 +3704,55 @@ var StaticTVClient = class {
|
|
|
3713
3704
|
}
|
|
3714
3705
|
/**
|
|
3715
3706
|
* Stop video playback on the configured videoScreen entity.
|
|
3707
|
+
* If fallbackVideoUrl is configured (default), plays the fallback loop.
|
|
3716
3708
|
* Called by Admin Panel.
|
|
3717
3709
|
*/
|
|
3718
3710
|
stopVideo() {
|
|
3719
3711
|
const screen = this.config.videoScreen;
|
|
3720
|
-
if (screen !== void 0
|
|
3721
|
-
this.log("Stopping video");
|
|
3722
|
-
VideoPlayer.getMutable(screen).playing = false;
|
|
3723
|
-
this._currentVideoUrl = "";
|
|
3712
|
+
if (screen !== void 0) {
|
|
3724
3713
|
if (this.guideUI) {
|
|
3725
3714
|
this.guideUI.currentVideoId = null;
|
|
3726
3715
|
}
|
|
3716
|
+
const fallbackUrl = this.config.fallbackVideoUrl;
|
|
3717
|
+
const fallbackDisabled = fallbackUrl === "";
|
|
3718
|
+
if (fallbackDisabled) {
|
|
3719
|
+
if (VideoPlayer.has(screen)) {
|
|
3720
|
+
this.log("Stopping video (no fallback)");
|
|
3721
|
+
VideoPlayer.getMutable(screen).playing = false;
|
|
3722
|
+
}
|
|
3723
|
+
this._currentVideoUrl = "";
|
|
3724
|
+
} else {
|
|
3725
|
+
const url = fallbackUrl || DEFAULT_FALLBACK_VIDEO;
|
|
3726
|
+
this.log(`Playing fallback: ${url}`);
|
|
3727
|
+
this._currentVideoUrl = "";
|
|
3728
|
+
this._playVideoInternal(url, true);
|
|
3729
|
+
}
|
|
3727
3730
|
}
|
|
3728
3731
|
if (this.config.onVideoStop) {
|
|
3729
3732
|
this.config.onVideoStop();
|
|
3730
3733
|
}
|
|
3731
3734
|
}
|
|
3735
|
+
/**
|
|
3736
|
+
* Internal video player - handles both regular videos and fallback
|
|
3737
|
+
* @internal
|
|
3738
|
+
*/
|
|
3739
|
+
_playVideoInternal(url, isFallback = false) {
|
|
3740
|
+
const screen = this.config.videoScreen;
|
|
3741
|
+
if (screen === void 0) return;
|
|
3742
|
+
if (VideoPlayer.has(screen)) {
|
|
3743
|
+
VideoPlayer.deleteFrom(screen);
|
|
3744
|
+
}
|
|
3745
|
+
VideoPlayer.create(screen, {
|
|
3746
|
+
src: url,
|
|
3747
|
+
playing: true,
|
|
3748
|
+
loop: isFallback,
|
|
3749
|
+
// Loop fallback videos
|
|
3750
|
+
volume: 1
|
|
3751
|
+
});
|
|
3752
|
+
Material.setBasicMaterial(screen, {
|
|
3753
|
+
texture: Material.Texture.Video({ videoPlayerEntity: screen })
|
|
3754
|
+
});
|
|
3755
|
+
}
|
|
3732
3756
|
/**
|
|
3733
3757
|
* Get the currently playing video URL
|
|
3734
3758
|
*/
|
|
@@ -3740,6 +3764,11 @@ var StaticTVClient = class {
|
|
|
3740
3764
|
* @internal
|
|
3741
3765
|
*/
|
|
3742
3766
|
_handleGuideVideoSelect(video) {
|
|
3767
|
+
if (video.channelId && video.isLive === false) {
|
|
3768
|
+
this.showNotification(`${video.name} is offline`);
|
|
3769
|
+
this.stopVideo();
|
|
3770
|
+
return;
|
|
3771
|
+
}
|
|
3743
3772
|
if (video.src) {
|
|
3744
3773
|
this.playVideo(video.src);
|
|
3745
3774
|
}
|
package/package.json
CHANGED