unified-video-framework 1.4.354 → 1.4.356
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/package.json +1 -1
- package/packages/web/dist/WebPlayer.d.ts.map +1 -1
- package/packages/web/dist/WebPlayer.js +59 -10
- package/packages/web/dist/WebPlayer.js.map +1 -1
- package/packages/web/dist/react/types/FlashNewsTickerTypes.d.ts +16 -1
- package/packages/web/dist/react/types/FlashNewsTickerTypes.d.ts.map +1 -1
- package/packages/web/src/WebPlayer.ts +71 -12
- package/packages/web/src/react/types/FlashNewsTickerTypes.ts +56 -4
|
@@ -1,15 +1,30 @@
|
|
|
1
1
|
export interface FlashNewsTickerItem {
|
|
2
2
|
id: string;
|
|
3
3
|
text: string;
|
|
4
|
+
html?: string;
|
|
4
5
|
priority?: number;
|
|
5
6
|
startTime?: number;
|
|
6
7
|
endTime?: number;
|
|
7
8
|
metadata?: Record<string, any>;
|
|
8
9
|
}
|
|
10
|
+
export interface TickerDisplayConfig {
|
|
11
|
+
items: FlashNewsTickerItem[];
|
|
12
|
+
height?: number;
|
|
13
|
+
backgroundColor?: string;
|
|
14
|
+
textColor?: string;
|
|
15
|
+
fontSize?: number;
|
|
16
|
+
fontWeight?: number | string;
|
|
17
|
+
speed?: number;
|
|
18
|
+
gap?: number;
|
|
19
|
+
separator?: string;
|
|
20
|
+
offset?: number;
|
|
21
|
+
}
|
|
9
22
|
export interface FlashNewsTickerConfig {
|
|
10
23
|
enabled?: boolean;
|
|
11
|
-
items
|
|
24
|
+
items?: FlashNewsTickerItem[];
|
|
12
25
|
position?: 'top' | 'bottom' | 'both';
|
|
26
|
+
topConfig?: TickerDisplayConfig;
|
|
27
|
+
bottomConfig?: TickerDisplayConfig;
|
|
13
28
|
height?: number;
|
|
14
29
|
backgroundColor?: string;
|
|
15
30
|
textColor?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FlashNewsTickerTypes.d.ts","sourceRoot":"","sources":["../../../src/react/types/FlashNewsTickerTypes.ts"],"names":[],"mappings":"AAUA,MAAM,WAAW,mBAAmB;IAElC,EAAE,EAAE,MAAM,CAAC;IAGX,IAAI,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"FlashNewsTickerTypes.d.ts","sourceRoot":"","sources":["../../../src/react/types/FlashNewsTickerTypes.ts"],"names":[],"mappings":"AAUA,MAAM,WAAW,mBAAmB;IAElC,EAAE,EAAE,MAAM,CAAC;IAGX,IAAI,EAAE,MAAM,CAAC;IAOb,IAAI,CAAC,EAAE,MAAM,CAAC;IAGd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAGlB,SAAS,CAAC,EAAE,MAAM,CAAC;IAGnB,OAAO,CAAC,EAAE,MAAM,CAAC;IAGjB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAChC;AAKD,MAAM,WAAW,mBAAmB;IAElC,KAAK,EAAE,mBAAmB,EAAE,CAAC;IAK7B,MAAM,CAAC,EAAE,MAAM,CAAC;IAGhB,eAAe,CAAC,EAAE,MAAM,CAAC;IAGzB,SAAS,CAAC,EAAE,MAAM,CAAC;IAGnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAGlB,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAK7B,KAAK,CAAC,EAAE,MAAM,CAAC;IAGf,GAAG,CAAC,EAAE,MAAM,CAAC;IAGb,SAAS,CAAC,EAAE,MAAM,CAAC;IAGnB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAKD,MAAM,WAAW,qBAAqB;IAEpC,OAAO,CAAC,EAAE,OAAO,CAAC;IAGlB,KAAK,CAAC,EAAE,mBAAmB,EAAE,CAAC;IAG9B,QAAQ,CAAC,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAC;IAGrC,SAAS,CAAC,EAAE,mBAAmB,CAAC;IAGhC,YAAY,CAAC,EAAE,mBAAmB,CAAC;IAKnC,MAAM,CAAC,EAAE,MAAM,CAAC;IAGhB,eAAe,CAAC,EAAE,MAAM,CAAC;IAGzB,SAAS,CAAC,EAAE,MAAM,CAAC;IAGnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAGlB,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAK7B,KAAK,CAAC,EAAE,MAAM,CAAC;IAGf,YAAY,CAAC,EAAE,OAAO,CAAC;IAGvB,GAAG,CAAC,EAAE,MAAM,CAAC;IAGb,IAAI,CAAC,EAAE,OAAO,CAAC;IAGf,SAAS,CAAC,EAAE,MAAM,CAAC;IAKnB,SAAS,CAAC,EAAE,MAAM,CAAC;IAGnB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAKD,MAAM,WAAW,kBAAkB;IAEjC,IAAI,EAAE,MAAM,IAAI,CAAC;IAGjB,IAAI,EAAE,MAAM,IAAI,CAAC;IAGjB,SAAS,EAAE,MAAM,OAAO,CAAC;IAGzB,WAAW,EAAE,CAAC,KAAK,EAAE,mBAAmB,EAAE,KAAK,IAAI,CAAC;IAGpD,OAAO,EAAE,CAAC,IAAI,EAAE,mBAAmB,KAAK,IAAI,CAAC;IAG7C,UAAU,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IAGrC,UAAU,EAAE,MAAM,IAAI,CAAC;IAGvB,YAAY,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC,qBAAqB,CAAC,KAAK,IAAI,CAAC;IAG/D,KAAK,EAAE,MAAM,IAAI,CAAC;IAGlB,MAAM,EAAE,MAAM,IAAI,CAAC;IAGnB,QAAQ,EAAE,MAAM,OAAO,CAAC;CACzB"}
|
|
@@ -2281,20 +2281,46 @@ export class WebPlayer extends BasePlayer {
|
|
|
2281
2281
|
this.flashTickerTopElement = null;
|
|
2282
2282
|
this.flashTickerBottomElement = null;
|
|
2283
2283
|
|
|
2284
|
-
if (!config.enabled
|
|
2284
|
+
if (!config.enabled) {
|
|
2285
2285
|
return;
|
|
2286
2286
|
}
|
|
2287
2287
|
|
|
2288
|
-
//
|
|
2289
|
-
if (config.position === '
|
|
2290
|
-
|
|
2291
|
-
|
|
2288
|
+
// Handle 'both' position with separate configs
|
|
2289
|
+
if (config.position === 'both') {
|
|
2290
|
+
// Create top ticker with topConfig or fallback to main config
|
|
2291
|
+
if (config.topConfig && config.topConfig.items && config.topConfig.items.length > 0) {
|
|
2292
|
+
const topConfig = { ...config, ...config.topConfig };
|
|
2293
|
+
this.flashTickerTopElement = this.createTickerElement(topConfig, 'top');
|
|
2294
|
+
this.flashTickerContainer.appendChild(this.flashTickerTopElement);
|
|
2295
|
+
} else if (config.items && config.items.length > 0) {
|
|
2296
|
+
this.flashTickerTopElement = this.createTickerElement(config, 'top');
|
|
2297
|
+
this.flashTickerContainer.appendChild(this.flashTickerTopElement);
|
|
2298
|
+
}
|
|
2299
|
+
|
|
2300
|
+
// Create bottom ticker with bottomConfig or fallback to main config
|
|
2301
|
+
if (config.bottomConfig && config.bottomConfig.items && config.bottomConfig.items.length > 0) {
|
|
2302
|
+
const bottomConfig = { ...config, ...config.bottomConfig };
|
|
2303
|
+
this.flashTickerBottomElement = this.createTickerElement(bottomConfig, 'bottom');
|
|
2304
|
+
this.flashTickerContainer.appendChild(this.flashTickerBottomElement);
|
|
2305
|
+
} else if (config.items && config.items.length > 0) {
|
|
2306
|
+
this.flashTickerBottomElement = this.createTickerElement(config, 'bottom');
|
|
2307
|
+
this.flashTickerContainer.appendChild(this.flashTickerBottomElement);
|
|
2308
|
+
}
|
|
2292
2309
|
}
|
|
2310
|
+
// Handle single position (top or bottom)
|
|
2311
|
+
else {
|
|
2312
|
+
if (!config.items || config.items.length === 0) {
|
|
2313
|
+
return;
|
|
2314
|
+
}
|
|
2293
2315
|
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2316
|
+
if (config.position === 'top') {
|
|
2317
|
+
this.flashTickerTopElement = this.createTickerElement(config, 'top');
|
|
2318
|
+
this.flashTickerContainer.appendChild(this.flashTickerTopElement);
|
|
2319
|
+
} else {
|
|
2320
|
+
// Default to bottom
|
|
2321
|
+
this.flashTickerBottomElement = this.createTickerElement(config, 'bottom');
|
|
2322
|
+
this.flashTickerContainer.appendChild(this.flashTickerBottomElement);
|
|
2323
|
+
}
|
|
2298
2324
|
}
|
|
2299
2325
|
}
|
|
2300
2326
|
|
|
@@ -2332,16 +2358,46 @@ export class WebPlayer extends BasePlayer {
|
|
|
2332
2358
|
padding-left: 100%;
|
|
2333
2359
|
`;
|
|
2334
2360
|
|
|
2361
|
+
// Calculate responsive font size based on container width
|
|
2362
|
+
const calculateResponsiveFontSize = (): number => {
|
|
2363
|
+
const containerWidth = this.container?.offsetWidth || 1920;
|
|
2364
|
+
const baseFontSize = config.fontSize || 14;
|
|
2365
|
+
|
|
2366
|
+
// Scale font size based on container width
|
|
2367
|
+
// Base: 14px at 1920px width
|
|
2368
|
+
if (containerWidth < 768) {
|
|
2369
|
+
// Mobile: smaller font
|
|
2370
|
+
return Math.max(baseFontSize * 0.8, 12);
|
|
2371
|
+
} else if (containerWidth < 1280) {
|
|
2372
|
+
// Tablet: slightly smaller
|
|
2373
|
+
return Math.max(baseFontSize * 0.9, 13);
|
|
2374
|
+
}
|
|
2375
|
+
// Desktop: use configured size
|
|
2376
|
+
return baseFontSize;
|
|
2377
|
+
};
|
|
2378
|
+
|
|
2379
|
+
const responsiveFontSize = calculateResponsiveFontSize();
|
|
2380
|
+
|
|
2335
2381
|
// Render items multiple times for continuous seamless loop
|
|
2336
2382
|
const renderItems = () => {
|
|
2383
|
+
if (!config.items) return;
|
|
2337
2384
|
config.items.forEach((item) => {
|
|
2338
2385
|
const span = document.createElement('span');
|
|
2339
|
-
|
|
2386
|
+
|
|
2387
|
+
// Support HTML content for rich formatting (e.g., colored "Breaking:")
|
|
2388
|
+
if (item.html) {
|
|
2389
|
+
span.innerHTML = item.html;
|
|
2390
|
+
} else {
|
|
2391
|
+
span.textContent = item.text;
|
|
2392
|
+
}
|
|
2393
|
+
|
|
2340
2394
|
span.style.cssText = `
|
|
2341
2395
|
color: ${config.textColor || '#ffffff'};
|
|
2342
|
-
font-size: ${
|
|
2396
|
+
font-size: ${responsiveFontSize}px;
|
|
2343
2397
|
font-weight: ${config.fontWeight || 600};
|
|
2344
2398
|
margin-right: ${config.gap || 100}px;
|
|
2399
|
+
display: inline-flex;
|
|
2400
|
+
align-items: center;
|
|
2345
2401
|
`;
|
|
2346
2402
|
track.appendChild(span);
|
|
2347
2403
|
|
|
@@ -2351,7 +2407,7 @@ export class WebPlayer extends BasePlayer {
|
|
|
2351
2407
|
sep.textContent = config.separator;
|
|
2352
2408
|
sep.style.cssText = `
|
|
2353
2409
|
color: ${config.textColor || '#ffffff'};
|
|
2354
|
-
font-size: ${
|
|
2410
|
+
font-size: ${responsiveFontSize}px;
|
|
2355
2411
|
opacity: 0.5;
|
|
2356
2412
|
margin: 0 8px;
|
|
2357
2413
|
`;
|
|
@@ -2385,6 +2441,9 @@ export class WebPlayer extends BasePlayer {
|
|
|
2385
2441
|
|
|
2386
2442
|
private calculateTickerDuration(config: FlashNewsTickerConfig): number {
|
|
2387
2443
|
const speed = config.speed || 50;
|
|
2444
|
+
if (!config.items || config.items.length === 0) {
|
|
2445
|
+
return 15; // Default minimum duration
|
|
2446
|
+
}
|
|
2388
2447
|
const itemsLength = config.items.reduce((acc, item) => acc + item.text.length, 0);
|
|
2389
2448
|
const avgCharWidth = 10; // Approximate pixel width per character
|
|
2390
2449
|
const gap = config.gap || 100;
|
|
@@ -15,6 +15,13 @@ export interface FlashNewsTickerItem {
|
|
|
15
15
|
/** Text content to display */
|
|
16
16
|
text: string;
|
|
17
17
|
|
|
18
|
+
/**
|
|
19
|
+
* HTML content to display (supports rich formatting like colors, bold, etc.)
|
|
20
|
+
* If provided, this takes precedence over 'text'
|
|
21
|
+
* Example: '<span style="color: red;">Breaking:</span> News content'
|
|
22
|
+
*/
|
|
23
|
+
html?: string;
|
|
24
|
+
|
|
18
25
|
/** Priority for ordering (higher = shown first). Default: 0 */
|
|
19
26
|
priority?: number;
|
|
20
27
|
|
|
@@ -28,6 +35,45 @@ export interface FlashNewsTickerItem {
|
|
|
28
35
|
metadata?: Record<string, any>;
|
|
29
36
|
}
|
|
30
37
|
|
|
38
|
+
/**
|
|
39
|
+
* Configuration for a single ticker (top or bottom)
|
|
40
|
+
*/
|
|
41
|
+
export interface TickerDisplayConfig {
|
|
42
|
+
/** Array of news items to display */
|
|
43
|
+
items: FlashNewsTickerItem[];
|
|
44
|
+
|
|
45
|
+
// Visual styling
|
|
46
|
+
|
|
47
|
+
/** Height of ticker in pixels. Default: 40 */
|
|
48
|
+
height?: number;
|
|
49
|
+
|
|
50
|
+
/** Background color with alpha. Default: 'rgba(0,0,0,0.7)' */
|
|
51
|
+
backgroundColor?: string;
|
|
52
|
+
|
|
53
|
+
/** Text color. Default: '#ffffff' */
|
|
54
|
+
textColor?: string;
|
|
55
|
+
|
|
56
|
+
/** Font size in pixels. Default: 14 */
|
|
57
|
+
fontSize?: number;
|
|
58
|
+
|
|
59
|
+
/** Font weight. Default: 600 */
|
|
60
|
+
fontWeight?: number | string;
|
|
61
|
+
|
|
62
|
+
// Animation
|
|
63
|
+
|
|
64
|
+
/** Animation speed in pixels per second. Default: 50 */
|
|
65
|
+
speed?: number;
|
|
66
|
+
|
|
67
|
+
/** Space between items in pixels. Default: 100 */
|
|
68
|
+
gap?: number;
|
|
69
|
+
|
|
70
|
+
/** Separator text between items. Default: ' • ' */
|
|
71
|
+
separator?: string;
|
|
72
|
+
|
|
73
|
+
/** Offset in pixels for safe area. Default: 0 for bottom, 10 for top */
|
|
74
|
+
offset?: number;
|
|
75
|
+
}
|
|
76
|
+
|
|
31
77
|
/**
|
|
32
78
|
* Configuration for the flash news ticker
|
|
33
79
|
*/
|
|
@@ -35,13 +81,19 @@ export interface FlashNewsTickerConfig {
|
|
|
35
81
|
/** Enable or disable the ticker. Default: true */
|
|
36
82
|
enabled?: boolean;
|
|
37
83
|
|
|
38
|
-
/** Array of news items to display */
|
|
39
|
-
items
|
|
84
|
+
/** Array of news items to display (for backward compatibility when position is 'top' or 'bottom') */
|
|
85
|
+
items?: FlashNewsTickerItem[];
|
|
40
86
|
|
|
41
87
|
/** Position on screen. Default: 'bottom' */
|
|
42
88
|
position?: 'top' | 'bottom' | 'both';
|
|
43
89
|
|
|
44
|
-
|
|
90
|
+
/** Configuration for top ticker (only used when position is 'both') */
|
|
91
|
+
topConfig?: TickerDisplayConfig;
|
|
92
|
+
|
|
93
|
+
/** Configuration for bottom ticker (only used when position is 'both') */
|
|
94
|
+
bottomConfig?: TickerDisplayConfig;
|
|
95
|
+
|
|
96
|
+
// Visual styling (applies to both if position is 'both' and no specific config provided)
|
|
45
97
|
|
|
46
98
|
/** Height of ticker in pixels. Default: 40 */
|
|
47
99
|
height?: number;
|
|
@@ -80,7 +132,7 @@ export interface FlashNewsTickerConfig {
|
|
|
80
132
|
/** Top offset in pixels for safe area. Default: 10 */
|
|
81
133
|
topOffset?: number;
|
|
82
134
|
|
|
83
|
-
/** Bottom offset in pixels for safe area. Default:
|
|
135
|
+
/** Bottom offset in pixels for safe area. Default: 0 */
|
|
84
136
|
bottomOffset?: number;
|
|
85
137
|
}
|
|
86
138
|
|