@scalemule/nextjs 0.1.54 → 0.1.55
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/audio.css +324 -33
- package/dist/audio.d.mts +4 -1
- package/dist/audio.d.ts +4 -1
- package/dist/audio.js +168 -21
- package/dist/audio.mjs +168 -21
- package/docs/network-audio.md +5 -2
- package/package.json +1 -1
package/dist/audio.css
CHANGED
|
@@ -226,7 +226,8 @@
|
|
|
226
226
|
}
|
|
227
227
|
|
|
228
228
|
/* src/components/network-audio-player.css */
|
|
229
|
-
.sm-network-player
|
|
229
|
+
.sm-network-player,
|
|
230
|
+
.sm-network-article {
|
|
230
231
|
--sm-player-paper: #fff;
|
|
231
232
|
--sm-player-ink: #203b30;
|
|
232
233
|
--sm-player-muted: #52675c;
|
|
@@ -235,57 +236,74 @@
|
|
|
235
236
|
--sm-player-soft: #f2f6f3;
|
|
236
237
|
box-sizing: border-box;
|
|
237
238
|
color: var(--sm-player-ink);
|
|
238
|
-
|
|
239
|
-
border-top: 2px solid var(--sm-player-accent);
|
|
240
|
-
padding: 16px max(20px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
|
|
241
|
-
font: 400 14px/1.45 var(--font-inter, system-ui), sans-serif;
|
|
239
|
+
font: 400 14px/1.45 var(--sm-player-sans, var(--font-inter, system-ui)), sans-serif;
|
|
242
240
|
color-scheme: light;
|
|
243
241
|
}
|
|
244
242
|
.sm-network-player *,
|
|
245
243
|
.sm-network-article * {
|
|
246
244
|
box-sizing: border-box;
|
|
247
245
|
}
|
|
246
|
+
.sm-network-player {
|
|
247
|
+
background: var(--sm-player-paper);
|
|
248
|
+
border-top: 1px solid var(--sm-player-line);
|
|
249
|
+
padding: 16px max(20px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
|
|
250
|
+
}
|
|
248
251
|
.sm-network-player--fixed {
|
|
249
252
|
position: fixed;
|
|
250
253
|
z-index: var(--sm-player-z-index, 100);
|
|
251
254
|
inset: auto 0 0;
|
|
252
|
-
box-shadow: 0 -
|
|
255
|
+
box-shadow: 0 -8px 32px #203b3010;
|
|
253
256
|
}
|
|
254
257
|
.sm-network-player button,
|
|
255
258
|
.sm-network-player select,
|
|
256
259
|
.sm-network-article button {
|
|
260
|
+
display: inline-flex;
|
|
261
|
+
align-items: center;
|
|
262
|
+
justify-content: center;
|
|
263
|
+
gap: 8px;
|
|
257
264
|
color: inherit;
|
|
258
265
|
font: inherit;
|
|
259
|
-
border: 1px solid var(--sm-player-line
|
|
266
|
+
border: 1px solid var(--sm-player-line);
|
|
260
267
|
background: transparent;
|
|
261
268
|
min-height: 44px;
|
|
262
|
-
border-radius:
|
|
269
|
+
border-radius: 10px;
|
|
263
270
|
padding: 8px 12px;
|
|
264
271
|
cursor: pointer;
|
|
265
272
|
touch-action: manipulation;
|
|
273
|
+
transition:
|
|
274
|
+
background-color 160ms ease,
|
|
275
|
+
color 160ms ease,
|
|
276
|
+
border-color 160ms ease;
|
|
266
277
|
}
|
|
267
278
|
.sm-network-player button:disabled,
|
|
268
279
|
.sm-network-article button:disabled {
|
|
269
|
-
opacity: .
|
|
280
|
+
opacity: .45;
|
|
270
281
|
cursor: default;
|
|
271
282
|
}
|
|
272
283
|
.sm-network-player :is(button, a, input, select):focus-visible,
|
|
273
284
|
.sm-network-article button:focus-visible {
|
|
274
|
-
outline: 3px solid var(--sm-player-accent
|
|
285
|
+
outline: 3px solid var(--sm-player-accent);
|
|
275
286
|
outline-offset: 3px;
|
|
276
287
|
}
|
|
277
288
|
.sm-network-player button:hover:not(:disabled),
|
|
278
289
|
.sm-network-article button:hover:not(:disabled) {
|
|
279
|
-
background: var(--sm-player-soft
|
|
290
|
+
background: var(--sm-player-soft);
|
|
291
|
+
}
|
|
292
|
+
.sm-network-icon {
|
|
293
|
+
display: block;
|
|
294
|
+
width: 20px;
|
|
295
|
+
height: 20px;
|
|
296
|
+
flex: 0 0 20px;
|
|
280
297
|
}
|
|
281
298
|
.sm-network-player__row {
|
|
282
299
|
display: flex;
|
|
283
300
|
align-items: center;
|
|
284
|
-
gap:
|
|
301
|
+
gap: 20px;
|
|
285
302
|
max-width: 1320px;
|
|
286
303
|
margin: auto;
|
|
287
304
|
}
|
|
288
|
-
.sm-network-player .sm-network-player__play
|
|
305
|
+
.sm-network-player .sm-network-player__play,
|
|
306
|
+
.sm-network-article__disc {
|
|
289
307
|
width: 48px;
|
|
290
308
|
height: 48px;
|
|
291
309
|
flex: 0 0 48px;
|
|
@@ -299,52 +317,148 @@
|
|
|
299
317
|
.sm-network-player .sm-network-player__play:hover {
|
|
300
318
|
background: var(--sm-player-ink);
|
|
301
319
|
}
|
|
302
|
-
.sm-network-player__play
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
320
|
+
.sm-network-player__play .sm-network-icon,
|
|
321
|
+
.sm-network-article__disc .sm-network-icon {
|
|
322
|
+
width: 24px;
|
|
323
|
+
height: 24px;
|
|
306
324
|
}
|
|
307
325
|
.sm-network-player__story {
|
|
308
326
|
min-width: 0;
|
|
309
|
-
flex: 1 1
|
|
327
|
+
flex: 1 1 320px;
|
|
310
328
|
}
|
|
311
329
|
.sm-network-player__story a {
|
|
312
330
|
display: block;
|
|
313
331
|
overflow: hidden;
|
|
314
332
|
text-overflow: ellipsis;
|
|
315
333
|
white-space: nowrap;
|
|
316
|
-
font: 600
|
|
334
|
+
font: 600 18px/1.4 var(--sm-player-serif, var(--font-editorial, Georgia)), serif;
|
|
317
335
|
color: inherit;
|
|
318
336
|
text-decoration: none;
|
|
319
337
|
}
|
|
320
338
|
.sm-network-player__story a:hover {
|
|
321
339
|
text-decoration: underline;
|
|
340
|
+
text-underline-offset: 3px;
|
|
322
341
|
}
|
|
323
342
|
.sm-network-player__story :is(span, small) {
|
|
343
|
+
display: block;
|
|
324
344
|
color: var(--sm-player-muted);
|
|
325
|
-
font-size:
|
|
345
|
+
font-size: 11px;
|
|
326
346
|
}
|
|
327
347
|
.sm-network-player__timeline {
|
|
328
|
-
flex: 1 1
|
|
329
|
-
|
|
348
|
+
flex: 1 1 220px;
|
|
349
|
+
max-width: 300px;
|
|
350
|
+
min-width: 120px;
|
|
330
351
|
}
|
|
331
352
|
.sm-network-player input[type=range] {
|
|
332
353
|
accent-color: var(--sm-player-accent);
|
|
333
354
|
cursor: pointer;
|
|
334
355
|
min-height: 24px;
|
|
335
356
|
}
|
|
336
|
-
.sm-network-player__timeline input {
|
|
357
|
+
.sm-network-player__timeline input[type=range] {
|
|
358
|
+
appearance: none;
|
|
337
359
|
display: block;
|
|
338
360
|
width: 100%;
|
|
361
|
+
height: 24px;
|
|
339
362
|
margin: 0;
|
|
363
|
+
background: transparent;
|
|
364
|
+
}
|
|
365
|
+
.sm-network-player__timeline input::-webkit-slider-runnable-track {
|
|
366
|
+
height: 4px;
|
|
367
|
+
border-radius: 4px;
|
|
368
|
+
background:
|
|
369
|
+
linear-gradient(
|
|
370
|
+
to right,
|
|
371
|
+
var(--sm-player-accent) var(--sm-progress, 0%),
|
|
372
|
+
var(--sm-player-line) var(--sm-progress, 0%));
|
|
373
|
+
}
|
|
374
|
+
.sm-network-player__timeline input::-moz-range-track {
|
|
375
|
+
height: 4px;
|
|
376
|
+
border-radius: 4px;
|
|
377
|
+
background: var(--sm-player-line);
|
|
378
|
+
}
|
|
379
|
+
.sm-network-player__timeline input::-moz-range-progress {
|
|
380
|
+
height: 4px;
|
|
381
|
+
border-radius: 4px;
|
|
382
|
+
background: var(--sm-player-accent);
|
|
383
|
+
}
|
|
384
|
+
.sm-network-player__timeline input::-webkit-slider-thumb {
|
|
385
|
+
appearance: none;
|
|
386
|
+
width: 12px;
|
|
387
|
+
height: 12px;
|
|
388
|
+
border-radius: 50%;
|
|
389
|
+
border: 2px solid var(--sm-player-paper);
|
|
390
|
+
background: var(--sm-player-accent);
|
|
391
|
+
box-shadow: 0 0 0 1px var(--sm-player-accent);
|
|
392
|
+
margin-top: -4px;
|
|
393
|
+
}
|
|
394
|
+
.sm-network-player__timeline input::-moz-range-thumb {
|
|
395
|
+
width: 8px;
|
|
396
|
+
height: 8px;
|
|
397
|
+
border-radius: 50%;
|
|
398
|
+
border: 2px solid var(--sm-player-paper);
|
|
399
|
+
background: var(--sm-player-accent);
|
|
400
|
+
box-shadow: 0 0 0 1px var(--sm-player-accent);
|
|
340
401
|
}
|
|
341
402
|
.sm-network-player__timeline div {
|
|
342
403
|
display: flex;
|
|
343
404
|
justify-content: space-between;
|
|
405
|
+
gap: 8px;
|
|
344
406
|
color: var(--sm-player-muted);
|
|
407
|
+
font-size: 11px;
|
|
408
|
+
font-variant-numeric: tabular-nums;
|
|
409
|
+
white-space: nowrap;
|
|
410
|
+
}
|
|
411
|
+
.sm-network-player__shortcuts {
|
|
412
|
+
display: flex;
|
|
413
|
+
align-items: center;
|
|
414
|
+
gap: 4px;
|
|
415
|
+
flex-shrink: 0;
|
|
416
|
+
}
|
|
417
|
+
.sm-network-player__shortcuts button {
|
|
418
|
+
border-color: transparent;
|
|
419
|
+
padding-inline: 10px;
|
|
420
|
+
white-space: nowrap;
|
|
421
|
+
}
|
|
422
|
+
.sm-network-player__shortcuts .sm-network-player__rate {
|
|
423
|
+
min-width: 52px;
|
|
424
|
+
gap: 1px;
|
|
425
|
+
font-weight: 650;
|
|
426
|
+
font-variant-numeric: tabular-nums;
|
|
427
|
+
background: var(--sm-player-soft);
|
|
428
|
+
}
|
|
429
|
+
.sm-network-player__rate span {
|
|
345
430
|
font-size: 12px;
|
|
431
|
+
font-weight: 400;
|
|
432
|
+
}
|
|
433
|
+
.sm-network-player__shortcuts .sm-network-player__highlight[aria-pressed=true] {
|
|
434
|
+
color: var(--sm-player-accent);
|
|
435
|
+
background: var(--sm-player-soft);
|
|
436
|
+
box-shadow: inset 0 -2px var(--sm-player-accent);
|
|
437
|
+
}
|
|
438
|
+
.sm-network-player__shortcuts .sm-network-player__queue {
|
|
439
|
+
margin-left: 6px;
|
|
440
|
+
border-color: var(--sm-player-line);
|
|
441
|
+
}
|
|
442
|
+
.sm-network-player__count {
|
|
443
|
+
display: grid;
|
|
444
|
+
place-items: center;
|
|
445
|
+
min-width: 20px;
|
|
446
|
+
height: 20px;
|
|
447
|
+
padding-inline: 4px;
|
|
448
|
+
border-radius: 50%;
|
|
449
|
+
background: var(--sm-player-soft);
|
|
450
|
+
font-size: 11px;
|
|
346
451
|
font-variant-numeric: tabular-nums;
|
|
347
452
|
}
|
|
453
|
+
.sm-network-player__queue > .sm-network-icon:last-child {
|
|
454
|
+
width: 14px;
|
|
455
|
+
height: 14px;
|
|
456
|
+
flex-basis: 14px;
|
|
457
|
+
transition: transform 160ms ease;
|
|
458
|
+
}
|
|
459
|
+
.sm-network-player__queue[aria-expanded=true] > .sm-network-icon:last-child {
|
|
460
|
+
transform: rotate(180deg);
|
|
461
|
+
}
|
|
348
462
|
.sm-network-player__details {
|
|
349
463
|
max-height: min(60dvh, 600px);
|
|
350
464
|
overflow: auto;
|
|
@@ -366,15 +480,35 @@
|
|
|
366
480
|
.sm-network-player__tools input {
|
|
367
481
|
width: 100px;
|
|
368
482
|
}
|
|
483
|
+
.sm-network-player__select {
|
|
484
|
+
position: relative;
|
|
485
|
+
display: inline-flex;
|
|
486
|
+
}
|
|
487
|
+
.sm-network-player__select select {
|
|
488
|
+
appearance: none;
|
|
489
|
+
min-width: 88px;
|
|
490
|
+
padding-right: 32px;
|
|
491
|
+
background: var(--sm-player-paper);
|
|
492
|
+
}
|
|
493
|
+
.sm-network-player__select > .sm-network-icon {
|
|
494
|
+
position: absolute;
|
|
495
|
+
right: 10px;
|
|
496
|
+
top: 50%;
|
|
497
|
+
transform: translateY(-50%);
|
|
498
|
+
width: 16px;
|
|
499
|
+
height: 16px;
|
|
500
|
+
pointer-events: none;
|
|
501
|
+
color: var(--sm-player-muted);
|
|
502
|
+
}
|
|
369
503
|
.sm-network-player__expanded {
|
|
370
504
|
display: grid;
|
|
371
505
|
grid-template-columns: minmax(0, 1fr) auto;
|
|
372
506
|
gap: 32px;
|
|
373
507
|
border-top: 1px solid var(--sm-player-line);
|
|
374
|
-
padding-top:
|
|
508
|
+
padding-top: 20px;
|
|
375
509
|
}
|
|
376
510
|
.sm-network-player h2 {
|
|
377
|
-
font: 600 22px/1.3 var(--font-editorial, Georgia), serif;
|
|
511
|
+
font: 600 22px/1.3 var(--sm-player-serif, var(--font-editorial, Georgia)), serif;
|
|
378
512
|
margin: 0 0 12px;
|
|
379
513
|
}
|
|
380
514
|
.sm-network-player ol {
|
|
@@ -391,8 +525,10 @@
|
|
|
391
525
|
}
|
|
392
526
|
.sm-network-player li[aria-current=true] {
|
|
393
527
|
background: var(--sm-player-soft);
|
|
528
|
+
border-radius: 10px;
|
|
394
529
|
}
|
|
395
530
|
.sm-network-player .sm-network-player__queue-title {
|
|
531
|
+
display: block;
|
|
396
532
|
flex: 1;
|
|
397
533
|
text-align: left;
|
|
398
534
|
border: 0;
|
|
@@ -424,18 +560,97 @@
|
|
|
424
560
|
display: flex;
|
|
425
561
|
flex-wrap: wrap;
|
|
426
562
|
align-items: center;
|
|
427
|
-
gap:
|
|
563
|
+
gap: 12px 20px;
|
|
564
|
+
padding: 16px;
|
|
565
|
+
border: 1px solid var(--sm-player-line);
|
|
566
|
+
border-radius: 18px;
|
|
567
|
+
background: var(--sm-player-soft);
|
|
428
568
|
}
|
|
429
|
-
.sm-network-article
|
|
430
|
-
|
|
431
|
-
|
|
569
|
+
.sm-network-article .sm-network-article__listen {
|
|
570
|
+
flex: 1 1 auto;
|
|
571
|
+
justify-content: flex-start;
|
|
572
|
+
gap: 14px;
|
|
573
|
+
padding: 0;
|
|
574
|
+
border: 0;
|
|
575
|
+
border-radius: 24px 8px 8px 24px;
|
|
576
|
+
text-align: left;
|
|
577
|
+
}
|
|
578
|
+
.sm-network-article__caption {
|
|
579
|
+
display: flex;
|
|
580
|
+
flex-direction: column;
|
|
581
|
+
gap: 3px;
|
|
582
|
+
}
|
|
583
|
+
.sm-network-article__caption > span:first-child {
|
|
584
|
+
font: 500 20px/1.2 var(--sm-player-serif, var(--font-editorial, Georgia)), serif;
|
|
585
|
+
}
|
|
586
|
+
.sm-network-article__duration {
|
|
587
|
+
font-size: 12px;
|
|
588
|
+
color: var(--sm-player-muted);
|
|
589
|
+
font-variant-numeric: tabular-nums;
|
|
590
|
+
}
|
|
591
|
+
.sm-network-article__listen:hover .sm-network-article__disc {
|
|
592
|
+
background: var(--sm-player-ink);
|
|
593
|
+
}
|
|
594
|
+
.sm-network-article__actions {
|
|
595
|
+
display: flex;
|
|
596
|
+
align-items: center;
|
|
597
|
+
gap: 4px;
|
|
598
|
+
flex-wrap: wrap;
|
|
599
|
+
}
|
|
600
|
+
.sm-network-article__actions button {
|
|
601
|
+
border-color: transparent;
|
|
602
|
+
font-size: 12px;
|
|
603
|
+
padding-inline: 10px;
|
|
604
|
+
}
|
|
605
|
+
.sm-network-article__actions button:hover:not(:disabled) {
|
|
606
|
+
background: var(--sm-player-paper);
|
|
607
|
+
}
|
|
608
|
+
.sm-network-article__actions .sm-network-article__queue:disabled {
|
|
609
|
+
opacity: 1;
|
|
610
|
+
color: var(--sm-player-muted);
|
|
611
|
+
}
|
|
612
|
+
.sm-network-article__actions button[aria-pressed=true] {
|
|
613
|
+
color: var(--sm-player-accent);
|
|
614
|
+
}
|
|
615
|
+
.sm-network-toggle {
|
|
616
|
+
flex-shrink: 0;
|
|
617
|
+
display: inline-flex;
|
|
618
|
+
align-items: center;
|
|
619
|
+
width: 26px;
|
|
620
|
+
height: 16px;
|
|
621
|
+
padding: 3px;
|
|
622
|
+
border-radius: 10px;
|
|
623
|
+
background: var(--sm-player-muted);
|
|
624
|
+
}
|
|
625
|
+
.sm-network-toggle::after {
|
|
626
|
+
content: "";
|
|
627
|
+
width: 10px;
|
|
628
|
+
height: 10px;
|
|
629
|
+
border-radius: 50%;
|
|
630
|
+
background: var(--sm-player-paper);
|
|
631
|
+
transition: transform 160ms ease;
|
|
632
|
+
}
|
|
633
|
+
[aria-pressed=true] > .sm-network-toggle {
|
|
634
|
+
background: var(--sm-player-accent);
|
|
635
|
+
}
|
|
636
|
+
[aria-pressed=true] > .sm-network-toggle::after {
|
|
637
|
+
transform: translateX(10px);
|
|
638
|
+
}
|
|
639
|
+
@media (max-width: 1100px) {
|
|
640
|
+
.sm-network-player__row {
|
|
641
|
+
gap: 14px;
|
|
642
|
+
}
|
|
643
|
+
.sm-network-player__highlight > span,
|
|
644
|
+
.sm-network-player__queue-label {
|
|
645
|
+
display: none;
|
|
646
|
+
}
|
|
432
647
|
}
|
|
433
648
|
@media (max-width: 700px) {
|
|
434
649
|
.sm-network-player {
|
|
435
|
-
padding
|
|
650
|
+
padding: 12px max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
|
|
436
651
|
}
|
|
437
652
|
.sm-network-player__row {
|
|
438
|
-
gap: 10px;
|
|
653
|
+
gap: 10px 12px;
|
|
439
654
|
flex-wrap: wrap;
|
|
440
655
|
}
|
|
441
656
|
.sm-network-player__story {
|
|
@@ -444,12 +659,88 @@
|
|
|
444
659
|
.sm-network-player__story a {
|
|
445
660
|
font-size: 17px;
|
|
446
661
|
}
|
|
662
|
+
.sm-network-player__story > span {
|
|
663
|
+
display: none;
|
|
664
|
+
}
|
|
447
665
|
.sm-network-player__timeline {
|
|
448
|
-
flex: 1 1
|
|
449
|
-
min-width:
|
|
666
|
+
flex: 1 1 80px;
|
|
667
|
+
min-width: 80px;
|
|
668
|
+
max-width: none;
|
|
669
|
+
}
|
|
670
|
+
.sm-network-player__timeline div {
|
|
671
|
+
font-size: 10px;
|
|
672
|
+
}
|
|
673
|
+
.sm-network-player__shortcuts {
|
|
674
|
+
gap: 2px;
|
|
675
|
+
}
|
|
676
|
+
.sm-network-player__shortcuts button {
|
|
677
|
+
min-width: 44px;
|
|
678
|
+
padding-inline: 8px;
|
|
679
|
+
}
|
|
680
|
+
.sm-network-player__shortcuts .sm-network-player__queue {
|
|
681
|
+
margin-left: 2px;
|
|
682
|
+
gap: 4px;
|
|
683
|
+
}
|
|
684
|
+
.sm-network-player__queue > .sm-network-icon:last-child {
|
|
685
|
+
display: none;
|
|
450
686
|
}
|
|
451
687
|
.sm-network-player__expanded {
|
|
452
688
|
grid-template-columns: minmax(0, 1fr);
|
|
453
689
|
gap: 20px;
|
|
454
690
|
}
|
|
691
|
+
.sm-network-article {
|
|
692
|
+
gap: 10px;
|
|
693
|
+
padding: 14px;
|
|
694
|
+
}
|
|
695
|
+
.sm-network-article__actions {
|
|
696
|
+
flex: 1 1 100%;
|
|
697
|
+
padding-top: 8px;
|
|
698
|
+
border-top: 1px solid var(--sm-player-line);
|
|
699
|
+
}
|
|
700
|
+
.sm-network-article__actions button {
|
|
701
|
+
flex: 1 0 auto;
|
|
702
|
+
white-space: nowrap;
|
|
703
|
+
}
|
|
704
|
+
}
|
|
705
|
+
@media (max-width: 400px) {
|
|
706
|
+
.sm-network-player__row {
|
|
707
|
+
column-gap: 6px;
|
|
708
|
+
}
|
|
709
|
+
.sm-network-player__shortcuts button {
|
|
710
|
+
padding-inline: 5px;
|
|
711
|
+
}
|
|
712
|
+
.sm-network-player__shortcuts .sm-network-player__queue {
|
|
713
|
+
gap: 2px;
|
|
714
|
+
}
|
|
715
|
+
.sm-network-player__remaining-label {
|
|
716
|
+
display: none;
|
|
717
|
+
}
|
|
718
|
+
.sm-network-player__remaining::before {
|
|
719
|
+
content: "\2212";
|
|
720
|
+
}
|
|
721
|
+
}
|
|
722
|
+
@media (prefers-reduced-motion: reduce) {
|
|
723
|
+
.sm-network-player *,
|
|
724
|
+
.sm-network-article *,
|
|
725
|
+
.sm-network-toggle::after {
|
|
726
|
+
transition: none !important;
|
|
727
|
+
}
|
|
728
|
+
}
|
|
729
|
+
@media (forced-colors: active) {
|
|
730
|
+
.sm-network-player__timeline input[type=range] {
|
|
731
|
+
appearance: auto;
|
|
732
|
+
}
|
|
733
|
+
.sm-network-player__timeline input::-webkit-slider-thumb {
|
|
734
|
+
appearance: auto;
|
|
735
|
+
}
|
|
736
|
+
.sm-network-player__highlight[aria-pressed=true],
|
|
737
|
+
.sm-network-article button[aria-pressed=true] {
|
|
738
|
+
outline: 2px solid Highlight;
|
|
739
|
+
}
|
|
740
|
+
.sm-network-toggle {
|
|
741
|
+
border: 1px solid ButtonText;
|
|
742
|
+
}
|
|
743
|
+
.sm-network-toggle::after {
|
|
744
|
+
background: ButtonText;
|
|
745
|
+
}
|
|
455
746
|
}
|
package/dist/audio.d.mts
CHANGED
|
@@ -228,6 +228,7 @@ interface NetworkAudioContextValue {
|
|
|
228
228
|
notice: string | null;
|
|
229
229
|
command: (command: NetworkAudioCommand) => void;
|
|
230
230
|
openNetworkPlayer?: () => void;
|
|
231
|
+
highlightAvailable: boolean;
|
|
231
232
|
highlightEnabled: boolean;
|
|
232
233
|
setHighlightEnabled: (enabled: boolean) => void;
|
|
233
234
|
}
|
|
@@ -244,9 +245,11 @@ declare function useArticleNarration(track: NetworkAudioTrack, narration?: Audio
|
|
|
244
245
|
interface ArticleAudioControlsProps {
|
|
245
246
|
track: NetworkAudioTrack;
|
|
246
247
|
narration?: AudioPlayerNarration;
|
|
248
|
+
/** Recording length shown before playback; resolved media supplies the live duration. */
|
|
249
|
+
durationMs?: number | null;
|
|
247
250
|
className?: string;
|
|
248
251
|
}
|
|
249
|
-
declare function ArticleAudioControls({ track, narration, className }: ArticleAudioControlsProps): react_jsx_runtime.JSX.Element;
|
|
252
|
+
declare function ArticleAudioControls({ track, narration, durationMs, className }: ArticleAudioControlsProps): react_jsx_runtime.JSX.Element;
|
|
250
253
|
interface NetworkAudioPlayerProps {
|
|
251
254
|
networkName?: string;
|
|
252
255
|
/** Render an actual ad or sponsor creative here. The expanded slot is labeled Advertisement. */
|
package/dist/audio.d.ts
CHANGED
|
@@ -228,6 +228,7 @@ interface NetworkAudioContextValue {
|
|
|
228
228
|
notice: string | null;
|
|
229
229
|
command: (command: NetworkAudioCommand) => void;
|
|
230
230
|
openNetworkPlayer?: () => void;
|
|
231
|
+
highlightAvailable: boolean;
|
|
231
232
|
highlightEnabled: boolean;
|
|
232
233
|
setHighlightEnabled: (enabled: boolean) => void;
|
|
233
234
|
}
|
|
@@ -244,9 +245,11 @@ declare function useArticleNarration(track: NetworkAudioTrack, narration?: Audio
|
|
|
244
245
|
interface ArticleAudioControlsProps {
|
|
245
246
|
track: NetworkAudioTrack;
|
|
246
247
|
narration?: AudioPlayerNarration;
|
|
248
|
+
/** Recording length shown before playback; resolved media supplies the live duration. */
|
|
249
|
+
durationMs?: number | null;
|
|
247
250
|
className?: string;
|
|
248
251
|
}
|
|
249
|
-
declare function ArticleAudioControls({ track, narration, className }: ArticleAudioControlsProps): react_jsx_runtime.JSX.Element;
|
|
252
|
+
declare function ArticleAudioControls({ track, narration, durationMs, className }: ArticleAudioControlsProps): react_jsx_runtime.JSX.Element;
|
|
250
253
|
interface NetworkAudioPlayerProps {
|
|
251
254
|
networkName?: string;
|
|
252
255
|
/** Render an actual ad or sponsor creative here. The expanded slot is labeled Advertisement. */
|
package/dist/audio.js
CHANGED
|
@@ -1279,6 +1279,7 @@ var NetworkPlayerClient = class {
|
|
|
1279
1279
|
// src/components/network-audio-player.tsx
|
|
1280
1280
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
1281
1281
|
var Context = (0, import_react2.createContext)(null);
|
|
1282
|
+
var NarrationRegistration = (0, import_react2.createContext)(null);
|
|
1282
1283
|
var serverSnapshot = () => EMPTY_SNAPSHOT;
|
|
1283
1284
|
function NetworkAudioProvider({ children, resolveAudio, connection, host, checkpointStorageKey }) {
|
|
1284
1285
|
if (connection && host) throw new Error("Use connection on reader pages and host on the dedicated player route, not both.");
|
|
@@ -1287,6 +1288,16 @@ function NetworkAudioProvider({ children, resolveAudio, connection, host, checkp
|
|
|
1287
1288
|
const [remoteSnapshot, setRemoteSnapshot] = (0, import_react2.useState)(null);
|
|
1288
1289
|
const [notice, setNotice] = (0, import_react2.useState)(null);
|
|
1289
1290
|
const [highlightEnabled, setHighlightEnabled] = (0, import_react2.useState)(false);
|
|
1291
|
+
const [narrationTracks, setNarrationTracks] = (0, import_react2.useState)(() => /* @__PURE__ */ new Map());
|
|
1292
|
+
const registerNarration = (0, import_react2.useCallback)((key) => {
|
|
1293
|
+
const id = /* @__PURE__ */ Symbol();
|
|
1294
|
+
setNarrationTracks((previous) => new Map(previous).set(id, key));
|
|
1295
|
+
return () => setNarrationTracks((previous) => {
|
|
1296
|
+
const next = new Map(previous);
|
|
1297
|
+
next.delete(id);
|
|
1298
|
+
return next;
|
|
1299
|
+
});
|
|
1300
|
+
}, []);
|
|
1290
1301
|
const client = (0, import_react2.useRef)(null);
|
|
1291
1302
|
(0, import_react2.useEffect)(() => {
|
|
1292
1303
|
controller.setResolver(resolveAudio);
|
|
@@ -1350,19 +1361,22 @@ function NetworkAudioProvider({ children, resolveAudio, connection, host, checkp
|
|
|
1350
1361
|
}, [controller]);
|
|
1351
1362
|
const openNetworkPlayer = (0, import_react2.useCallback)(() => client.current?.open(), []);
|
|
1352
1363
|
const activeSnapshot = remoteSnapshot ?? snapshot;
|
|
1353
|
-
|
|
1364
|
+
const activeTrack = activeSnapshot.queue[activeSnapshot.index];
|
|
1365
|
+
const highlightAvailable = !!activeTrack && [...narrationTracks.values()].includes(trackKey(activeTrack));
|
|
1366
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Context.Provider, { value: {
|
|
1354
1367
|
snapshot: activeSnapshot,
|
|
1355
1368
|
remote: remoteSnapshot !== null,
|
|
1356
1369
|
hosted: !!host,
|
|
1357
1370
|
notice,
|
|
1358
1371
|
command,
|
|
1359
1372
|
openNetworkPlayer: connection ? openNetworkPlayer : void 0,
|
|
1373
|
+
highlightAvailable,
|
|
1360
1374
|
highlightEnabled,
|
|
1361
1375
|
setHighlightEnabled
|
|
1362
|
-
}, children: [
|
|
1376
|
+
}, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(NarrationRegistration.Provider, { value: registerNarration, children: [
|
|
1363
1377
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(NetworkMediaSession, {}),
|
|
1364
1378
|
children
|
|
1365
|
-
] });
|
|
1379
|
+
] }) });
|
|
1366
1380
|
}
|
|
1367
1381
|
function useNetworkAudio() {
|
|
1368
1382
|
const context = (0, import_react2.useContext)(Context);
|
|
@@ -1421,6 +1435,12 @@ var subscribeCapabilities = () => () => {
|
|
|
1421
1435
|
function useArticleNarration(track, narration) {
|
|
1422
1436
|
const { snapshot, highlightEnabled, setHighlightEnabled } = useNetworkAudio();
|
|
1423
1437
|
const supported = (0, import_react2.useSyncExternalStore)(subscribeCapabilities, narrationHighlightSupported, () => false);
|
|
1438
|
+
const registerNarration = (0, import_react2.useContext)(NarrationRegistration);
|
|
1439
|
+
const narrationKey = trackKey(track);
|
|
1440
|
+
const available = !!narration && supported;
|
|
1441
|
+
(0, import_react2.useEffect)(() => {
|
|
1442
|
+
if (available) return registerNarration?.(narrationKey);
|
|
1443
|
+
}, [available, narrationKey, registerNarration]);
|
|
1424
1444
|
const active = snapshot.queue[snapshot.index];
|
|
1425
1445
|
const matching = !!active && trackKey(active) === trackKey(track);
|
|
1426
1446
|
const clock = (0, import_react2.useRef)({ snapshot, received: 0 });
|
|
@@ -1474,26 +1494,88 @@ function useArticleNarration(track, narration) {
|
|
|
1474
1494
|
}, [matching, highlightEnabled, supported, narration?.targetId, narration?.timingsUrl, track.id, track.publicationId]);
|
|
1475
1495
|
return { highlightAvailable: !!narration && supported, highlightEnabled, setHighlightEnabled, matching };
|
|
1476
1496
|
}
|
|
1477
|
-
function
|
|
1497
|
+
function AudioIcon({ name }) {
|
|
1498
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("svg", { className: "sm-network-icon", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.7", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", focusable: "false", children: [
|
|
1499
|
+
name === "play" && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "m9 5 11 7-11 7Z", fill: "currentColor", stroke: "none" }),
|
|
1500
|
+
name === "pause" && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M7 5h3v14H7zm7 0h3v14h-3z", fill: "currentColor", stroke: "none" }),
|
|
1501
|
+
name === "queue" && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_jsx_runtime2.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M4 6h16M4 12h10M4 18h8m7-5v8m-4-4h8" }) }),
|
|
1502
|
+
name === "check" && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "m5 12 4 4L19 6" }),
|
|
1503
|
+
name === "highlight" && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_jsx_runtime2.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "m7 14 7-9 5 4-7 9-5-4Zm0 0-3 5h8M16 3l5 4M3 22h17" }) }),
|
|
1504
|
+
name === "next" && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
|
|
1505
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "m6 5 10 7-10 7Z", fill: "currentColor", stroke: "none" }),
|
|
1506
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M19 5v14" })
|
|
1507
|
+
] }),
|
|
1508
|
+
name === "chevron" && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "m7 10 5 5 5-5" }),
|
|
1509
|
+
name === "external" && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M14 4h6v6m0-6L10 14m10 1v5H4V4h5" })
|
|
1510
|
+
] });
|
|
1511
|
+
}
|
|
1512
|
+
var formatTime = (seconds) => `${Math.floor(seconds / 60)}:${String(Math.floor(seconds % 60)).padStart(2, "0")}`;
|
|
1513
|
+
var PLAYBACK_RATES = [0.5, 0.75, 1, 1.25, 1.5, 1.75, 2, 2.5, 3];
|
|
1514
|
+
function ArticleAudioControls({ track, narration, durationMs, className = "" }) {
|
|
1478
1515
|
const { snapshot, command } = useNetworkAudio();
|
|
1479
1516
|
const { highlightAvailable, highlightEnabled, setHighlightEnabled, matching } = useArticleNarration(track, narration);
|
|
1480
1517
|
const playing = matching && (snapshot.status === "playing" || snapshot.status === "loading");
|
|
1481
1518
|
const queued = snapshot.queue.some((item) => trackKey(item) === trackKey(track));
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.
|
|
1485
|
-
|
|
1519
|
+
const duration = matching && snapshot.duration > 0 ? snapshot.duration : (durationMs ?? 0) / 1e3;
|
|
1520
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: `sm-network-article ${className}`, role: "group", "aria-label": "Article audio", children: [
|
|
1521
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
1522
|
+
"button",
|
|
1523
|
+
{
|
|
1524
|
+
type: "button",
|
|
1525
|
+
className: "sm-network-article__listen",
|
|
1526
|
+
"aria-label": playing ? "Pause this story" : "Listen to this story",
|
|
1527
|
+
onClick: () => command(playing ? { action: "pause" } : { action: "playTrack", track }),
|
|
1528
|
+
children: [
|
|
1529
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "sm-network-article__disc", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(AudioIcon, { name: playing ? "pause" : "play" }) }),
|
|
1530
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: "sm-network-article__caption", children: [
|
|
1531
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: playing ? "Pause this story" : "Listen to this story" }),
|
|
1532
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "sm-network-article__duration", children: matching && snapshot.status === "loading" ? "Loading audio\u2026" : duration > 0 ? `${formatTime(duration)} listening time` : "Article audio" })
|
|
1533
|
+
] })
|
|
1534
|
+
]
|
|
1535
|
+
}
|
|
1536
|
+
),
|
|
1537
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "sm-network-article__actions", children: [
|
|
1538
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
1539
|
+
"button",
|
|
1540
|
+
{
|
|
1541
|
+
type: "button",
|
|
1542
|
+
className: "sm-network-article__queue",
|
|
1543
|
+
"aria-label": queued ? "Queued" : "Add to queue",
|
|
1544
|
+
disabled: queued,
|
|
1545
|
+
onClick: () => command({ action: "enqueue", track }),
|
|
1546
|
+
children: [
|
|
1547
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(AudioIcon, { name: queued ? "check" : "queue" }),
|
|
1548
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: queued ? "Queued" : "Queue" })
|
|
1549
|
+
]
|
|
1550
|
+
}
|
|
1551
|
+
),
|
|
1552
|
+
highlightAvailable && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
1553
|
+
"button",
|
|
1554
|
+
{
|
|
1555
|
+
type: "button",
|
|
1556
|
+
"aria-label": "Follow along: highlight words",
|
|
1557
|
+
"aria-pressed": highlightEnabled,
|
|
1558
|
+
title: "Highlight words as you listen",
|
|
1559
|
+
onClick: () => setHighlightEnabled(!highlightEnabled),
|
|
1560
|
+
children: [
|
|
1561
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(AudioIcon, { name: "highlight" }),
|
|
1562
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "Follow along" }),
|
|
1563
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "sm-network-toggle", "aria-hidden": "true" })
|
|
1564
|
+
]
|
|
1565
|
+
}
|
|
1566
|
+
)
|
|
1567
|
+
] })
|
|
1486
1568
|
] });
|
|
1487
1569
|
}
|
|
1488
|
-
var formatTime = (seconds) => `${Math.floor(seconds / 60)}:${String(Math.floor(seconds % 60)).padStart(2, "0")}`;
|
|
1489
1570
|
function NetworkAudioPlayer({ networkName = "Your listening queue", advertisement, className = "", style, fixed = true, renderArticleLink }) {
|
|
1490
|
-
const { snapshot, remote, hosted, notice, command, openNetworkPlayer } = useNetworkAudio();
|
|
1571
|
+
const { snapshot, remote, hosted, notice, command, openNetworkPlayer, highlightAvailable, highlightEnabled, setHighlightEnabled } = useNetworkAudio();
|
|
1491
1572
|
const [expanded, setExpanded] = (0, import_react2.useState)(false);
|
|
1492
1573
|
const [height, setHeight] = (0, import_react2.useState)(0);
|
|
1493
1574
|
const bar = (0, import_react2.useRef)(null);
|
|
1494
1575
|
const detailsId = (0, import_react2.useId)();
|
|
1495
1576
|
const track = snapshot.queue[snapshot.index];
|
|
1496
1577
|
const playing = snapshot.status === "playing" || snapshot.status === "loading";
|
|
1578
|
+
const nextRate = PLAYBACK_RATES.find((rate) => rate > snapshot.rate) ?? 1;
|
|
1497
1579
|
(0, import_react2.useEffect)(() => {
|
|
1498
1580
|
const element = bar.current;
|
|
1499
1581
|
if (!fixed || !element) return;
|
|
@@ -1512,24 +1594,83 @@ function NetworkAudioPlayer({ networkName = "Your listening queue", advertisemen
|
|
|
1512
1594
|
fixed && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { "aria-hidden": "true", style: { height } }),
|
|
1513
1595
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("section", { ref: bar, className: `sm-network-player ${fixed ? "sm-network-player--fixed" : ""} ${className}`, style, "aria-label": "Network audio player", children: [
|
|
1514
1596
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "sm-network-player__row", children: [
|
|
1515
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { type: "button", className: "sm-network-player__play", "aria-label": playing ? "Pause playback" : "Play playback", onClick: () => command({ action: playing ? "pause" : "play" }), children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1597
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { type: "button", className: "sm-network-player__play", "aria-label": playing ? "Pause playback" : "Play playback", onClick: () => command({ action: playing ? "pause" : "play" }), children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(AudioIcon, { name: playing ? "pause" : "play" }) }),
|
|
1516
1598
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "sm-network-player__story", children: [
|
|
1517
1599
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: remote ? "Playing in network window" : networkName }),
|
|
1518
1600
|
!hosted && renderArticleLink ? renderArticleLink(track) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("a", { href: track.articleUrl, target: "_blank", rel: "noopener noreferrer", children: track.title }),
|
|
1519
1601
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("small", { children: track.publicationName })
|
|
1520
1602
|
] }),
|
|
1521
1603
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "sm-network-player__timeline", children: [
|
|
1522
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("input", { type: "range", min: "0", max: snapshot.duration || 0, step: "0.1", value: Math.min(snapshot.position, snapshot.duration), disabled: !snapshot.duration, "aria-label": "Seek article audio", onChange: (e) => command({ action: "seek", value: Number(e.target.value) }) }),
|
|
1604
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("input", { style: { "--sm-progress": `${snapshot.duration ? Math.min(100, snapshot.position / snapshot.duration * 100) : 0}%` }, type: "range", min: "0", max: snapshot.duration || 0, step: "0.1", value: Math.min(snapshot.position, snapshot.duration), disabled: !snapshot.duration, "aria-label": "Seek article audio", onChange: (e) => command({ action: "seek", value: Number(e.target.value) }) }),
|
|
1523
1605
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { children: [
|
|
1524
1606
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: formatTime(snapshot.position) }),
|
|
1525
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { children: [
|
|
1607
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: "sm-network-player__remaining", "aria-label": `${formatTime(Math.max(0, snapshot.duration - snapshot.position) / snapshot.rate)} remaining`, children: [
|
|
1526
1608
|
formatTime(Math.max(0, snapshot.duration - snapshot.position) / snapshot.rate),
|
|
1527
|
-
" remaining"
|
|
1609
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "sm-network-player__remaining-label", children: " remaining" })
|
|
1528
1610
|
] })
|
|
1529
1611
|
] })
|
|
1530
1612
|
] }),
|
|
1531
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.
|
|
1532
|
-
|
|
1613
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "sm-network-player__shortcuts", role: "group", "aria-label": "Playback shortcuts", children: [
|
|
1614
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
1615
|
+
"button",
|
|
1616
|
+
{
|
|
1617
|
+
type: "button",
|
|
1618
|
+
className: "sm-network-player__rate",
|
|
1619
|
+
"aria-label": `Playback speed ${snapshot.rate}\xD7. ${nextRate > snapshot.rate ? "Speed up" : "Reset"} to ${nextRate}\xD7`,
|
|
1620
|
+
title: `Playback speed: ${snapshot.rate}\xD7. Click for ${nextRate}\xD7`,
|
|
1621
|
+
onClick: () => command({ action: "rate", value: nextRate }),
|
|
1622
|
+
children: [
|
|
1623
|
+
snapshot.rate,
|
|
1624
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "\xD7" })
|
|
1625
|
+
]
|
|
1626
|
+
}
|
|
1627
|
+
),
|
|
1628
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
1629
|
+
"button",
|
|
1630
|
+
{
|
|
1631
|
+
type: "button",
|
|
1632
|
+
className: "sm-network-player__highlight",
|
|
1633
|
+
"aria-label": "Follow along: highlight article words",
|
|
1634
|
+
"aria-pressed": highlightAvailable && highlightEnabled,
|
|
1635
|
+
disabled: !highlightAvailable,
|
|
1636
|
+
title: highlightAvailable ? "Highlight words as you listen" : "Open the playing article to use word highlighting when available",
|
|
1637
|
+
onClick: () => setHighlightEnabled(!highlightEnabled),
|
|
1638
|
+
children: [
|
|
1639
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(AudioIcon, { name: "highlight" }),
|
|
1640
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "Follow along" })
|
|
1641
|
+
]
|
|
1642
|
+
}
|
|
1643
|
+
),
|
|
1644
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1645
|
+
"button",
|
|
1646
|
+
{
|
|
1647
|
+
type: "button",
|
|
1648
|
+
className: "sm-network-player__next",
|
|
1649
|
+
"aria-label": "Next article",
|
|
1650
|
+
title: "Next article",
|
|
1651
|
+
disabled: snapshot.index + 1 >= snapshot.queue.length,
|
|
1652
|
+
onClick: () => command({ action: "select", value: snapshot.index + 1 }),
|
|
1653
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(AudioIcon, { name: "next" })
|
|
1654
|
+
}
|
|
1655
|
+
),
|
|
1656
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
1657
|
+
"button",
|
|
1658
|
+
{
|
|
1659
|
+
type: "button",
|
|
1660
|
+
className: "sm-network-player__queue",
|
|
1661
|
+
"aria-label": expanded ? "Close queue" : `Queue (${snapshot.queue.length})`,
|
|
1662
|
+
"aria-expanded": expanded,
|
|
1663
|
+
"aria-controls": detailsId,
|
|
1664
|
+
onClick: () => setExpanded(!expanded),
|
|
1665
|
+
children: [
|
|
1666
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(AudioIcon, { name: "queue" }),
|
|
1667
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "sm-network-player__queue-label", children: expanded ? "Close queue" : "Queue" }),
|
|
1668
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "sm-network-player__count", children: snapshot.queue.length }),
|
|
1669
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(AudioIcon, { name: "chevron" })
|
|
1670
|
+
]
|
|
1671
|
+
}
|
|
1672
|
+
)
|
|
1673
|
+
] })
|
|
1533
1674
|
] }),
|
|
1534
1675
|
(notice || snapshot.error) && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { role: "status", className: "sm-network-player__notice", children: notice ?? snapshot.error }),
|
|
1535
1676
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { id: detailsId, hidden: !expanded, className: "sm-network-player__details", children: [
|
|
@@ -1538,16 +1679,22 @@ function NetworkAudioPlayer({ networkName = "Your listening queue", advertisemen
|
|
|
1538
1679
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { type: "button", onClick: () => command({ action: "seek", value: snapshot.position + 30 }), children: "Forward 30 seconds" }),
|
|
1539
1680
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { children: [
|
|
1540
1681
|
"Speed ",
|
|
1541
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.
|
|
1542
|
-
rate,
|
|
1543
|
-
|
|
1544
|
-
|
|
1682
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: "sm-network-player__select", children: [
|
|
1683
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("select", { value: snapshot.rate, onChange: (e) => command({ action: "rate", value: Number(e.target.value) }), children: PLAYBACK_RATES.map((rate) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("option", { value: rate, children: [
|
|
1684
|
+
rate,
|
|
1685
|
+
"\xD7"
|
|
1686
|
+
] }, rate)) }),
|
|
1687
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(AudioIcon, { name: "chevron" })
|
|
1688
|
+
] })
|
|
1545
1689
|
] }),
|
|
1546
1690
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { children: [
|
|
1547
1691
|
"Volume ",
|
|
1548
1692
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("input", { type: "range", min: "0", max: "1", step: "0.05", value: snapshot.volume, onChange: (e) => command({ action: "volume", value: Number(e.target.value) }) })
|
|
1549
1693
|
] }),
|
|
1550
|
-
openNetworkPlayer && /* @__PURE__ */ (0, import_jsx_runtime2.
|
|
1694
|
+
openNetworkPlayer && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("button", { type: "button", onClick: openNetworkPlayer, children: [
|
|
1695
|
+
remote ? "Open player window" : "Listen across sites",
|
|
1696
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(AudioIcon, { name: "external" })
|
|
1697
|
+
] }),
|
|
1551
1698
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { type: "button", onClick: () => command({ action: "clear" }), children: "Stop and clear queue" })
|
|
1552
1699
|
] }),
|
|
1553
1700
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "sm-network-player__expanded", children: [
|
package/dist/audio.mjs
CHANGED
|
@@ -1259,6 +1259,7 @@ var NetworkPlayerClient = class {
|
|
|
1259
1259
|
// src/components/network-audio-player.tsx
|
|
1260
1260
|
import { Fragment, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
1261
1261
|
var Context = createContext(null);
|
|
1262
|
+
var NarrationRegistration = createContext(null);
|
|
1262
1263
|
var serverSnapshot = () => EMPTY_SNAPSHOT;
|
|
1263
1264
|
function NetworkAudioProvider({ children, resolveAudio, connection, host, checkpointStorageKey }) {
|
|
1264
1265
|
if (connection && host) throw new Error("Use connection on reader pages and host on the dedicated player route, not both.");
|
|
@@ -1267,6 +1268,16 @@ function NetworkAudioProvider({ children, resolveAudio, connection, host, checkp
|
|
|
1267
1268
|
const [remoteSnapshot, setRemoteSnapshot] = useState2(null);
|
|
1268
1269
|
const [notice, setNotice] = useState2(null);
|
|
1269
1270
|
const [highlightEnabled, setHighlightEnabled] = useState2(false);
|
|
1271
|
+
const [narrationTracks, setNarrationTracks] = useState2(() => /* @__PURE__ */ new Map());
|
|
1272
|
+
const registerNarration = useCallback((key) => {
|
|
1273
|
+
const id = /* @__PURE__ */ Symbol();
|
|
1274
|
+
setNarrationTracks((previous) => new Map(previous).set(id, key));
|
|
1275
|
+
return () => setNarrationTracks((previous) => {
|
|
1276
|
+
const next = new Map(previous);
|
|
1277
|
+
next.delete(id);
|
|
1278
|
+
return next;
|
|
1279
|
+
});
|
|
1280
|
+
}, []);
|
|
1270
1281
|
const client = useRef2(null);
|
|
1271
1282
|
useEffect2(() => {
|
|
1272
1283
|
controller.setResolver(resolveAudio);
|
|
@@ -1330,19 +1341,22 @@ function NetworkAudioProvider({ children, resolveAudio, connection, host, checkp
|
|
|
1330
1341
|
}, [controller]);
|
|
1331
1342
|
const openNetworkPlayer = useCallback(() => client.current?.open(), []);
|
|
1332
1343
|
const activeSnapshot = remoteSnapshot ?? snapshot;
|
|
1333
|
-
|
|
1344
|
+
const activeTrack = activeSnapshot.queue[activeSnapshot.index];
|
|
1345
|
+
const highlightAvailable = !!activeTrack && [...narrationTracks.values()].includes(trackKey(activeTrack));
|
|
1346
|
+
return /* @__PURE__ */ jsx2(Context.Provider, { value: {
|
|
1334
1347
|
snapshot: activeSnapshot,
|
|
1335
1348
|
remote: remoteSnapshot !== null,
|
|
1336
1349
|
hosted: !!host,
|
|
1337
1350
|
notice,
|
|
1338
1351
|
command,
|
|
1339
1352
|
openNetworkPlayer: connection ? openNetworkPlayer : void 0,
|
|
1353
|
+
highlightAvailable,
|
|
1340
1354
|
highlightEnabled,
|
|
1341
1355
|
setHighlightEnabled
|
|
1342
|
-
}, children: [
|
|
1356
|
+
}, children: /* @__PURE__ */ jsxs2(NarrationRegistration.Provider, { value: registerNarration, children: [
|
|
1343
1357
|
/* @__PURE__ */ jsx2(NetworkMediaSession, {}),
|
|
1344
1358
|
children
|
|
1345
|
-
] });
|
|
1359
|
+
] }) });
|
|
1346
1360
|
}
|
|
1347
1361
|
function useNetworkAudio() {
|
|
1348
1362
|
const context = useContext(Context);
|
|
@@ -1401,6 +1415,12 @@ var subscribeCapabilities = () => () => {
|
|
|
1401
1415
|
function useArticleNarration(track, narration) {
|
|
1402
1416
|
const { snapshot, highlightEnabled, setHighlightEnabled } = useNetworkAudio();
|
|
1403
1417
|
const supported = useSyncExternalStore2(subscribeCapabilities, narrationHighlightSupported, () => false);
|
|
1418
|
+
const registerNarration = useContext(NarrationRegistration);
|
|
1419
|
+
const narrationKey = trackKey(track);
|
|
1420
|
+
const available = !!narration && supported;
|
|
1421
|
+
useEffect2(() => {
|
|
1422
|
+
if (available) return registerNarration?.(narrationKey);
|
|
1423
|
+
}, [available, narrationKey, registerNarration]);
|
|
1404
1424
|
const active = snapshot.queue[snapshot.index];
|
|
1405
1425
|
const matching = !!active && trackKey(active) === trackKey(track);
|
|
1406
1426
|
const clock = useRef2({ snapshot, received: 0 });
|
|
@@ -1454,26 +1474,88 @@ function useArticleNarration(track, narration) {
|
|
|
1454
1474
|
}, [matching, highlightEnabled, supported, narration?.targetId, narration?.timingsUrl, track.id, track.publicationId]);
|
|
1455
1475
|
return { highlightAvailable: !!narration && supported, highlightEnabled, setHighlightEnabled, matching };
|
|
1456
1476
|
}
|
|
1457
|
-
function
|
|
1477
|
+
function AudioIcon({ name }) {
|
|
1478
|
+
return /* @__PURE__ */ jsxs2("svg", { className: "sm-network-icon", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.7", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", focusable: "false", children: [
|
|
1479
|
+
name === "play" && /* @__PURE__ */ jsx2("path", { d: "m9 5 11 7-11 7Z", fill: "currentColor", stroke: "none" }),
|
|
1480
|
+
name === "pause" && /* @__PURE__ */ jsx2("path", { d: "M7 5h3v14H7zm7 0h3v14h-3z", fill: "currentColor", stroke: "none" }),
|
|
1481
|
+
name === "queue" && /* @__PURE__ */ jsx2(Fragment, { children: /* @__PURE__ */ jsx2("path", { d: "M4 6h16M4 12h10M4 18h8m7-5v8m-4-4h8" }) }),
|
|
1482
|
+
name === "check" && /* @__PURE__ */ jsx2("path", { d: "m5 12 4 4L19 6" }),
|
|
1483
|
+
name === "highlight" && /* @__PURE__ */ jsx2(Fragment, { children: /* @__PURE__ */ jsx2("path", { d: "m7 14 7-9 5 4-7 9-5-4Zm0 0-3 5h8M16 3l5 4M3 22h17" }) }),
|
|
1484
|
+
name === "next" && /* @__PURE__ */ jsxs2(Fragment, { children: [
|
|
1485
|
+
/* @__PURE__ */ jsx2("path", { d: "m6 5 10 7-10 7Z", fill: "currentColor", stroke: "none" }),
|
|
1486
|
+
/* @__PURE__ */ jsx2("path", { d: "M19 5v14" })
|
|
1487
|
+
] }),
|
|
1488
|
+
name === "chevron" && /* @__PURE__ */ jsx2("path", { d: "m7 10 5 5 5-5" }),
|
|
1489
|
+
name === "external" && /* @__PURE__ */ jsx2("path", { d: "M14 4h6v6m0-6L10 14m10 1v5H4V4h5" })
|
|
1490
|
+
] });
|
|
1491
|
+
}
|
|
1492
|
+
var formatTime = (seconds) => `${Math.floor(seconds / 60)}:${String(Math.floor(seconds % 60)).padStart(2, "0")}`;
|
|
1493
|
+
var PLAYBACK_RATES = [0.5, 0.75, 1, 1.25, 1.5, 1.75, 2, 2.5, 3];
|
|
1494
|
+
function ArticleAudioControls({ track, narration, durationMs, className = "" }) {
|
|
1458
1495
|
const { snapshot, command } = useNetworkAudio();
|
|
1459
1496
|
const { highlightAvailable, highlightEnabled, setHighlightEnabled, matching } = useArticleNarration(track, narration);
|
|
1460
1497
|
const playing = matching && (snapshot.status === "playing" || snapshot.status === "loading");
|
|
1461
1498
|
const queued = snapshot.queue.some((item) => trackKey(item) === trackKey(track));
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
/* @__PURE__ */
|
|
1465
|
-
|
|
1499
|
+
const duration = matching && snapshot.duration > 0 ? snapshot.duration : (durationMs ?? 0) / 1e3;
|
|
1500
|
+
return /* @__PURE__ */ jsxs2("div", { className: `sm-network-article ${className}`, role: "group", "aria-label": "Article audio", children: [
|
|
1501
|
+
/* @__PURE__ */ jsxs2(
|
|
1502
|
+
"button",
|
|
1503
|
+
{
|
|
1504
|
+
type: "button",
|
|
1505
|
+
className: "sm-network-article__listen",
|
|
1506
|
+
"aria-label": playing ? "Pause this story" : "Listen to this story",
|
|
1507
|
+
onClick: () => command(playing ? { action: "pause" } : { action: "playTrack", track }),
|
|
1508
|
+
children: [
|
|
1509
|
+
/* @__PURE__ */ jsx2("span", { className: "sm-network-article__disc", children: /* @__PURE__ */ jsx2(AudioIcon, { name: playing ? "pause" : "play" }) }),
|
|
1510
|
+
/* @__PURE__ */ jsxs2("span", { className: "sm-network-article__caption", children: [
|
|
1511
|
+
/* @__PURE__ */ jsx2("span", { children: playing ? "Pause this story" : "Listen to this story" }),
|
|
1512
|
+
/* @__PURE__ */ jsx2("span", { className: "sm-network-article__duration", children: matching && snapshot.status === "loading" ? "Loading audio\u2026" : duration > 0 ? `${formatTime(duration)} listening time` : "Article audio" })
|
|
1513
|
+
] })
|
|
1514
|
+
]
|
|
1515
|
+
}
|
|
1516
|
+
),
|
|
1517
|
+
/* @__PURE__ */ jsxs2("div", { className: "sm-network-article__actions", children: [
|
|
1518
|
+
/* @__PURE__ */ jsxs2(
|
|
1519
|
+
"button",
|
|
1520
|
+
{
|
|
1521
|
+
type: "button",
|
|
1522
|
+
className: "sm-network-article__queue",
|
|
1523
|
+
"aria-label": queued ? "Queued" : "Add to queue",
|
|
1524
|
+
disabled: queued,
|
|
1525
|
+
onClick: () => command({ action: "enqueue", track }),
|
|
1526
|
+
children: [
|
|
1527
|
+
/* @__PURE__ */ jsx2(AudioIcon, { name: queued ? "check" : "queue" }),
|
|
1528
|
+
/* @__PURE__ */ jsx2("span", { children: queued ? "Queued" : "Queue" })
|
|
1529
|
+
]
|
|
1530
|
+
}
|
|
1531
|
+
),
|
|
1532
|
+
highlightAvailable && /* @__PURE__ */ jsxs2(
|
|
1533
|
+
"button",
|
|
1534
|
+
{
|
|
1535
|
+
type: "button",
|
|
1536
|
+
"aria-label": "Follow along: highlight words",
|
|
1537
|
+
"aria-pressed": highlightEnabled,
|
|
1538
|
+
title: "Highlight words as you listen",
|
|
1539
|
+
onClick: () => setHighlightEnabled(!highlightEnabled),
|
|
1540
|
+
children: [
|
|
1541
|
+
/* @__PURE__ */ jsx2(AudioIcon, { name: "highlight" }),
|
|
1542
|
+
/* @__PURE__ */ jsx2("span", { children: "Follow along" }),
|
|
1543
|
+
/* @__PURE__ */ jsx2("span", { className: "sm-network-toggle", "aria-hidden": "true" })
|
|
1544
|
+
]
|
|
1545
|
+
}
|
|
1546
|
+
)
|
|
1547
|
+
] })
|
|
1466
1548
|
] });
|
|
1467
1549
|
}
|
|
1468
|
-
var formatTime = (seconds) => `${Math.floor(seconds / 60)}:${String(Math.floor(seconds % 60)).padStart(2, "0")}`;
|
|
1469
1550
|
function NetworkAudioPlayer({ networkName = "Your listening queue", advertisement, className = "", style, fixed = true, renderArticleLink }) {
|
|
1470
|
-
const { snapshot, remote, hosted, notice, command, openNetworkPlayer } = useNetworkAudio();
|
|
1551
|
+
const { snapshot, remote, hosted, notice, command, openNetworkPlayer, highlightAvailable, highlightEnabled, setHighlightEnabled } = useNetworkAudio();
|
|
1471
1552
|
const [expanded, setExpanded] = useState2(false);
|
|
1472
1553
|
const [height, setHeight] = useState2(0);
|
|
1473
1554
|
const bar = useRef2(null);
|
|
1474
1555
|
const detailsId = useId2();
|
|
1475
1556
|
const track = snapshot.queue[snapshot.index];
|
|
1476
1557
|
const playing = snapshot.status === "playing" || snapshot.status === "loading";
|
|
1558
|
+
const nextRate = PLAYBACK_RATES.find((rate) => rate > snapshot.rate) ?? 1;
|
|
1477
1559
|
useEffect2(() => {
|
|
1478
1560
|
const element = bar.current;
|
|
1479
1561
|
if (!fixed || !element) return;
|
|
@@ -1492,24 +1574,83 @@ function NetworkAudioPlayer({ networkName = "Your listening queue", advertisemen
|
|
|
1492
1574
|
fixed && /* @__PURE__ */ jsx2("div", { "aria-hidden": "true", style: { height } }),
|
|
1493
1575
|
/* @__PURE__ */ jsxs2("section", { ref: bar, className: `sm-network-player ${fixed ? "sm-network-player--fixed" : ""} ${className}`, style, "aria-label": "Network audio player", children: [
|
|
1494
1576
|
/* @__PURE__ */ jsxs2("div", { className: "sm-network-player__row", children: [
|
|
1495
|
-
/* @__PURE__ */ jsx2("button", { type: "button", className: "sm-network-player__play", "aria-label": playing ? "Pause playback" : "Play playback", onClick: () => command({ action: playing ? "pause" : "play" }), children: /* @__PURE__ */ jsx2(
|
|
1577
|
+
/* @__PURE__ */ jsx2("button", { type: "button", className: "sm-network-player__play", "aria-label": playing ? "Pause playback" : "Play playback", onClick: () => command({ action: playing ? "pause" : "play" }), children: /* @__PURE__ */ jsx2(AudioIcon, { name: playing ? "pause" : "play" }) }),
|
|
1496
1578
|
/* @__PURE__ */ jsxs2("div", { className: "sm-network-player__story", children: [
|
|
1497
1579
|
/* @__PURE__ */ jsx2("span", { children: remote ? "Playing in network window" : networkName }),
|
|
1498
1580
|
!hosted && renderArticleLink ? renderArticleLink(track) : /* @__PURE__ */ jsx2("a", { href: track.articleUrl, target: "_blank", rel: "noopener noreferrer", children: track.title }),
|
|
1499
1581
|
/* @__PURE__ */ jsx2("small", { children: track.publicationName })
|
|
1500
1582
|
] }),
|
|
1501
1583
|
/* @__PURE__ */ jsxs2("div", { className: "sm-network-player__timeline", children: [
|
|
1502
|
-
/* @__PURE__ */ jsx2("input", { type: "range", min: "0", max: snapshot.duration || 0, step: "0.1", value: Math.min(snapshot.position, snapshot.duration), disabled: !snapshot.duration, "aria-label": "Seek article audio", onChange: (e) => command({ action: "seek", value: Number(e.target.value) }) }),
|
|
1584
|
+
/* @__PURE__ */ jsx2("input", { style: { "--sm-progress": `${snapshot.duration ? Math.min(100, snapshot.position / snapshot.duration * 100) : 0}%` }, type: "range", min: "0", max: snapshot.duration || 0, step: "0.1", value: Math.min(snapshot.position, snapshot.duration), disabled: !snapshot.duration, "aria-label": "Seek article audio", onChange: (e) => command({ action: "seek", value: Number(e.target.value) }) }),
|
|
1503
1585
|
/* @__PURE__ */ jsxs2("div", { children: [
|
|
1504
1586
|
/* @__PURE__ */ jsx2("span", { children: formatTime(snapshot.position) }),
|
|
1505
|
-
/* @__PURE__ */ jsxs2("span", { children: [
|
|
1587
|
+
/* @__PURE__ */ jsxs2("span", { className: "sm-network-player__remaining", "aria-label": `${formatTime(Math.max(0, snapshot.duration - snapshot.position) / snapshot.rate)} remaining`, children: [
|
|
1506
1588
|
formatTime(Math.max(0, snapshot.duration - snapshot.position) / snapshot.rate),
|
|
1507
|
-
" remaining"
|
|
1589
|
+
/* @__PURE__ */ jsx2("span", { className: "sm-network-player__remaining-label", children: " remaining" })
|
|
1508
1590
|
] })
|
|
1509
1591
|
] })
|
|
1510
1592
|
] }),
|
|
1511
|
-
/* @__PURE__ */
|
|
1512
|
-
|
|
1593
|
+
/* @__PURE__ */ jsxs2("div", { className: "sm-network-player__shortcuts", role: "group", "aria-label": "Playback shortcuts", children: [
|
|
1594
|
+
/* @__PURE__ */ jsxs2(
|
|
1595
|
+
"button",
|
|
1596
|
+
{
|
|
1597
|
+
type: "button",
|
|
1598
|
+
className: "sm-network-player__rate",
|
|
1599
|
+
"aria-label": `Playback speed ${snapshot.rate}\xD7. ${nextRate > snapshot.rate ? "Speed up" : "Reset"} to ${nextRate}\xD7`,
|
|
1600
|
+
title: `Playback speed: ${snapshot.rate}\xD7. Click for ${nextRate}\xD7`,
|
|
1601
|
+
onClick: () => command({ action: "rate", value: nextRate }),
|
|
1602
|
+
children: [
|
|
1603
|
+
snapshot.rate,
|
|
1604
|
+
/* @__PURE__ */ jsx2("span", { children: "\xD7" })
|
|
1605
|
+
]
|
|
1606
|
+
}
|
|
1607
|
+
),
|
|
1608
|
+
/* @__PURE__ */ jsxs2(
|
|
1609
|
+
"button",
|
|
1610
|
+
{
|
|
1611
|
+
type: "button",
|
|
1612
|
+
className: "sm-network-player__highlight",
|
|
1613
|
+
"aria-label": "Follow along: highlight article words",
|
|
1614
|
+
"aria-pressed": highlightAvailable && highlightEnabled,
|
|
1615
|
+
disabled: !highlightAvailable,
|
|
1616
|
+
title: highlightAvailable ? "Highlight words as you listen" : "Open the playing article to use word highlighting when available",
|
|
1617
|
+
onClick: () => setHighlightEnabled(!highlightEnabled),
|
|
1618
|
+
children: [
|
|
1619
|
+
/* @__PURE__ */ jsx2(AudioIcon, { name: "highlight" }),
|
|
1620
|
+
/* @__PURE__ */ jsx2("span", { children: "Follow along" })
|
|
1621
|
+
]
|
|
1622
|
+
}
|
|
1623
|
+
),
|
|
1624
|
+
/* @__PURE__ */ jsx2(
|
|
1625
|
+
"button",
|
|
1626
|
+
{
|
|
1627
|
+
type: "button",
|
|
1628
|
+
className: "sm-network-player__next",
|
|
1629
|
+
"aria-label": "Next article",
|
|
1630
|
+
title: "Next article",
|
|
1631
|
+
disabled: snapshot.index + 1 >= snapshot.queue.length,
|
|
1632
|
+
onClick: () => command({ action: "select", value: snapshot.index + 1 }),
|
|
1633
|
+
children: /* @__PURE__ */ jsx2(AudioIcon, { name: "next" })
|
|
1634
|
+
}
|
|
1635
|
+
),
|
|
1636
|
+
/* @__PURE__ */ jsxs2(
|
|
1637
|
+
"button",
|
|
1638
|
+
{
|
|
1639
|
+
type: "button",
|
|
1640
|
+
className: "sm-network-player__queue",
|
|
1641
|
+
"aria-label": expanded ? "Close queue" : `Queue (${snapshot.queue.length})`,
|
|
1642
|
+
"aria-expanded": expanded,
|
|
1643
|
+
"aria-controls": detailsId,
|
|
1644
|
+
onClick: () => setExpanded(!expanded),
|
|
1645
|
+
children: [
|
|
1646
|
+
/* @__PURE__ */ jsx2(AudioIcon, { name: "queue" }),
|
|
1647
|
+
/* @__PURE__ */ jsx2("span", { className: "sm-network-player__queue-label", children: expanded ? "Close queue" : "Queue" }),
|
|
1648
|
+
/* @__PURE__ */ jsx2("span", { className: "sm-network-player__count", children: snapshot.queue.length }),
|
|
1649
|
+
/* @__PURE__ */ jsx2(AudioIcon, { name: "chevron" })
|
|
1650
|
+
]
|
|
1651
|
+
}
|
|
1652
|
+
)
|
|
1653
|
+
] })
|
|
1513
1654
|
] }),
|
|
1514
1655
|
(notice || snapshot.error) && /* @__PURE__ */ jsx2("p", { role: "status", className: "sm-network-player__notice", children: notice ?? snapshot.error }),
|
|
1515
1656
|
/* @__PURE__ */ jsxs2("div", { id: detailsId, hidden: !expanded, className: "sm-network-player__details", children: [
|
|
@@ -1518,16 +1659,22 @@ function NetworkAudioPlayer({ networkName = "Your listening queue", advertisemen
|
|
|
1518
1659
|
/* @__PURE__ */ jsx2("button", { type: "button", onClick: () => command({ action: "seek", value: snapshot.position + 30 }), children: "Forward 30 seconds" }),
|
|
1519
1660
|
/* @__PURE__ */ jsxs2("label", { children: [
|
|
1520
1661
|
"Speed ",
|
|
1521
|
-
/* @__PURE__ */
|
|
1522
|
-
rate,
|
|
1523
|
-
|
|
1524
|
-
|
|
1662
|
+
/* @__PURE__ */ jsxs2("span", { className: "sm-network-player__select", children: [
|
|
1663
|
+
/* @__PURE__ */ jsx2("select", { value: snapshot.rate, onChange: (e) => command({ action: "rate", value: Number(e.target.value) }), children: PLAYBACK_RATES.map((rate) => /* @__PURE__ */ jsxs2("option", { value: rate, children: [
|
|
1664
|
+
rate,
|
|
1665
|
+
"\xD7"
|
|
1666
|
+
] }, rate)) }),
|
|
1667
|
+
/* @__PURE__ */ jsx2(AudioIcon, { name: "chevron" })
|
|
1668
|
+
] })
|
|
1525
1669
|
] }),
|
|
1526
1670
|
/* @__PURE__ */ jsxs2("label", { children: [
|
|
1527
1671
|
"Volume ",
|
|
1528
1672
|
/* @__PURE__ */ jsx2("input", { type: "range", min: "0", max: "1", step: "0.05", value: snapshot.volume, onChange: (e) => command({ action: "volume", value: Number(e.target.value) }) })
|
|
1529
1673
|
] }),
|
|
1530
|
-
openNetworkPlayer && /* @__PURE__ */
|
|
1674
|
+
openNetworkPlayer && /* @__PURE__ */ jsxs2("button", { type: "button", onClick: openNetworkPlayer, children: [
|
|
1675
|
+
remote ? "Open player window" : "Listen across sites",
|
|
1676
|
+
/* @__PURE__ */ jsx2(AudioIcon, { name: "external" })
|
|
1677
|
+
] }),
|
|
1531
1678
|
/* @__PURE__ */ jsx2("button", { type: "button", onClick: () => command({ action: "clear" }), children: "Stop and clear queue" })
|
|
1532
1679
|
] }),
|
|
1533
1680
|
/* @__PURE__ */ jsxs2("div", { className: "sm-network-player__expanded", children: [
|
package/docs/network-audio.md
CHANGED
|
@@ -84,6 +84,7 @@ players for the same article.
|
|
|
84
84
|
import { ArticleAudioControls } from '@scalemule/nextjs/audio'
|
|
85
85
|
|
|
86
86
|
<ArticleAudioControls
|
|
87
|
+
durationMs={article.audio?.duration_ms}
|
|
87
88
|
track={{
|
|
88
89
|
id: article.id,
|
|
89
90
|
publicationId,
|
|
@@ -105,6 +106,8 @@ in different publications do not collide. The queue deduplicates entries and
|
|
|
105
106
|
holds up to 100 articles. Finishing an article advances to the next one.
|
|
106
107
|
Unavailable audio stops with a retry/choose-another message.
|
|
107
108
|
|
|
109
|
+
The compact bar exposes a playback-speed shortcut (cycles upward through the available rates, then resets to 1×) and a Follow along toggle. The expanded Speed selector retains all rates, including 0.5× and 0.75×. The player highlighting shortcut is enabled only when the active article has mounted narration controls in this document; it shares the article toggle’s preference.
|
|
110
|
+
|
|
108
111
|
`useArticleNarration(track, narration)` attaches the same behavior to custom
|
|
109
112
|
controls. Highlighting is opt-in, applies only to the active article, clears
|
|
110
113
|
while the reader document is hidden, and detaches on unmount. The preference
|
|
@@ -192,8 +195,8 @@ screens, keyboard controls, volume, speed, seek, skipping forward/backward,
|
|
|
192
195
|
queue selection/removal and clearing the queue. Media Session play/pause/seek is
|
|
193
196
|
registered where supported. Customize `--sm-player-paper`, `--sm-player-ink`,
|
|
194
197
|
`--sm-player-muted`, `--sm-player-line`, `--sm-player-accent`, `--sm-player-soft`,
|
|
195
|
-
and `--sm-player-z-index`. Typography
|
|
196
|
-
`--font-inter`. Supply an appropriate palette for dark themes.
|
|
198
|
+
and `--sm-player-z-index`. Typography uses `--sm-player-serif` and `--sm-player-sans`, falling back to
|
|
199
|
+
`--font-editorial` and `--font-inter`. The article panel uses the same palette variables. Supply an appropriate palette for dark themes.
|
|
197
200
|
|
|
198
201
|
Persistence is off by default. Where reader preferences permit it, set
|
|
199
202
|
`checkpointStorageKey` to an application/network **and user-scoped** key.
|
package/package.json
CHANGED