mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-20 18:22:25 +00:00
LIVE loads YouTube only after Play, and stops when its view is hidden
Selecting a station no longer builds the player: the LIVE section and the Cockpit's LIVE page show a poster with Play under the line that YouTube sees the viewer's IP address, as SECURITY.md asks of third-party media. The player goes when the section collapses, Context collapses or closes, the Cockpit leaves its LIVE page, or the Cockpit is entered or left, so nothing plays unseen. A selection that moves straight on to another entry of the same station (the Cockpit stepping between views) keeps the player instead of rebuilding it. SECURITY.md also lists the ISS telemetry relay.
This commit is contained in:
1 parent
71d57481b7
commit
1e2332eeb6
14 files changed
+314
-108
No files matched your search
+1
-1
@@ -37,7 +37,7 @@ How to read this:
|
||||
| **NASA 3D Resources** (`public/models/iss.glb`) | The ISS drawn as a 3D model when the camera is near it (satellites layer): NASA/JSC IGOAL's "International Space Station (ISS) (D)" (https://science.nasa.gov/3d-resources/international-space-station-iss-d-igoal/), reduced and re-rigged as `public/models/README.md` records. Its moving parts are computed by the app unless the telemetry relay in the next row is switched on: arrays and radiators from the Sun's position, the Ku-band dishes toward the TDRS fleet's nominal slots (41°W, 171°W, 85°E), the robotic arms as an illustrative sway | NASA media, not subject to copyright in the United States; NASA's Images and Media Usage Guidelines (https://www.nasa.gov/nasa-brand-center/images-and-media) ask that use not imply endorsement and that the insignia not be used | "ISS model: NASA 3D Resources" |
|
||||
| **Project model** (`public/models/tiangong.glb`) | Tiangong drawn as a 3D model when the camera is near it (satellites layer): an original model of the station's T configuration (Tianhe, Wentian, Mengtian, a Shenzhou forward and nadir, a Tianzhou aft) made for God's Eye View from primitives with procedurally generated textures; dimensions from Wang, Zhang & Wang 2023, "Design and Application Prospect of China's Tiangong Space Station", Space: Science & Technology (https://doi.org/10.34133/space.0035, CC BY 4.0) and eoPortal's Tiangong page, the approximate parts listed in `public/models/README.md`. Its moving parts are computed by the app: the wings from the Sun's position, the high-gain antenna toward the Tianlian II nominal slots (79.9°E, 171.04°E, 10.5°E), the two arms as an illustrative sway; China publishes no live telemetry for the station | MIT, with the rest of the project's own work (`LICENSE`): an original asset with no third-party geometry, textures or images; the published dimensions are facts taken from a CC BY 4.0 paper and eoPortal | "Tiangong model: made for God's Eye View; dimensions from Wang, Zhang & Wang 2023 (CC BY 4.0) and eoPortal" |
|
||||
| **NASA ISSLive telemetry** (`push.lightstreamer.com`, adapter set `ISSLIVE`) | **Off by default.** With `ISS_TELEMETRY_ENABLED=1` the server holds one connection to NASA's public ISS telemetry stream, open only while a browser has the ISS model on screen, and relays the latest joint angles at `/api/iss-telemetry`: the two alpha joints, the eight array beta joints, the two radiator joints and the Ku-band dish (Canadarm2's joints are relayed but not used yet). While the station has signal the ISS model takes those angles in place of the computed ones. The app stores nothing from it | The public subset of ISS telemetry NASA released as the ISSLive project, served for NASA by Lightstreamer. No terms of use are published for the feed, so it is opt-in and no request is made by default | "ISS joint telemetry: NASA ISSLive, via Lightstreamer" |
|
||||
| **NASA ISS live streams on YouTube** (`youtube-nocookie.com/embed/ROboUHfPUrU`, `.../M3HKLzjvKPc`) | NASA's official live video from the ISS, two broadcasts ("Live High-Definition Views from the International Space Station" from the exterior cameras, and the live video with space-to-ground audio), offered in a LIVE section of Context, and on the Cockpit briefing's LIVE page, while the ISS is selected on the map and played, muted, in YouTube's own embedded player, which loads as soon as the station is selected; collapsing the section hides the player without stopping it; the app stores nothing from it (`src/data/liveStreams.js`) | NASA video, not subject to copyright in the United States, distributed through YouTube under YouTube's Terms of Service, which permit embedding with the public embeddable player; the privacy-enhanced host is used and the viewer's IP address reaches YouTube as soon as the station is selected | "NASA video, via YouTube", with a link to the stream's own page |
|
||||
| **NASA ISS live streams on YouTube** (`youtube-nocookie.com/embed/ROboUHfPUrU`, `.../M3HKLzjvKPc`) | NASA's official live video from the ISS, two broadcasts ("Live High-Definition Views from the International Space Station" from the exterior cameras, and the live video with space-to-ground audio), offered in a LIVE section of Context, and on the Cockpit briefing's LIVE page, while the ISS is selected on the map, and played, muted, in YouTube's own embedded player only after the viewer presses Play; collapsing the section, closing Context or leaving the Cockpit page removes the player; the app stores nothing from it (`src/data/liveStreams.js`) | NASA video, not subject to copyright in the United States, distributed through YouTube under YouTube's Terms of Service, which permit embedding with the public embeddable player; the player API script loads from `www.youtube.com` and the video from the privacy-enhanced host `www.youtube-nocookie.com`, and the viewer's IP address reaches YouTube only once they press Play, under a line that says so | "NASA video, via YouTube", with a link to the stream's own page |
|
||||
| **The Space Devs — Launch Library 2 v2.3** | Recent launch, payload, stage, and recovery metadata for Space Missions (30d) | [The Space Devs terms of use](https://github.com/TheSpaceDevs/Tutorials/blob/main/faqs/faq_TSD.md#terms-of-use): data may be used and shared in any form; avoid forwarding it without added value; attribution is encouraged (not mandatory). [Official API limits](https://ll.thespacedevs.com/docs/): 15 unauthenticated calls/hour; optional token | "Launch Library 2 — The Space Devs" (courtesy attribution) |
|
||||
| **Esri World Imagery** (ArcGIS Online tile service) | The keyless satellite basemap — the default landing when no Google/ion credential is configured, and the "Esri Satellite" map stack | [Esri Master Agreement](https://www.esri.com/en-us/legal/terms/full-master-agreement): the public World Imagery service is usable in public-facing apps with attribution; no key is required for this classic endpoint, but Esri governs and can change access — an app at scale should review current ArcGIS Location Platform terms | "Powered by Esri — Source: Esri, Maxar, Earthstar Geographics, and the GIS User Community" (provider carries the service's own credit line) |
|
||||
| **USGS** | Earthquakes | U.S. public domain | "Data courtesy of the U.S. Geological Survey" |
|
||||
|
||||
@@ -72,6 +72,8 @@ The data proxies under `server/providers/` are written so the browser cannot tur
|
||||
- **Live HLS is bounded and origin-pinned.** Registered HTTP(S) HLS sources use a Node puller that rejects redirects and off-origin playlist references, bounds playlists to 256 KiB and segment bodies to 8 MiB while streaming, and aborts timed-out or released sessions. At most two sessions retain 12 segments/24 MiB each, plus bounded download buffers. Stores are memory-only and idle sessions expire after 15 seconds. RTMP/ffmpeg execution is not enabled. Locally configured source URLs remain an operator trust boundary.
|
||||
- **Radio is not an audio relay.** `/api/radio/stations` contacts only allowlisted Radio Browser HTTPS hosts and paths, rejects redirects, rejects any hostname with a loopback/private/link-local/metadata/non-public A or AAAA result, and pins each TLS connection to a validated address. It returns normalized public HTTPS stream URLs; `/api/radio/click/:uuid` applies the same destination policy and accepts only station IDs from the current bounded catalog. The browser then connects directly to the broadcaster after an explicit playback action, so the broadcaster sees the listener's IP address. GEV never proxies, caches, records, or redistributes audio.
|
||||
- **Québec 511 video plays in the browser, opt-in and after Play.** With `CCTV_QUEBEC_VIDEO_ENABLED=1`, `/api/cctv/sources` lists, for each MTQ camera, one URL built server-side from its numeric id on `https://www.quebec511.info/Carte/Fenetres/camera.ashx`; the overlay accepts no other host, path or format. The browser loads that clip only after the viewer presses Play for the selected camera, so Québec 511 sees the viewer's IP address, and the panel says so before Play. Selecting a camera by click, auto-hop, a scene or voice never loads it, and switching cameras stops playback. GEV never proxies, caches or reads the video's pixels. With the flag unset (the default) the browser makes no request to Québec 511.
|
||||
- **Station live video plays only after Play.** The LIVE section of Context and the Cockpit briefing's LIVE page load YouTube's player (the IFrame API from `www.youtube.com`, the video on `www.youtube-nocookie.com`) only after the viewer presses Play, under a line saying that YouTube sees their IP address. Selecting a station by click, a share link that follows it, a scene or voice shows the poster and loads nothing. The player goes when the section is collapsed, Context is closed or collapsed, the Cockpit leaves its LIVE page, the Cockpit is entered or left, or the selection moves to an object without that stream. GEV never proxies, caches or reads the video's pixels.
|
||||
- **The ISS telemetry relay is opt-in, keyless and read-only.** With `ISS_TELEMETRY_ENABLED=1`, `/api/iss-telemetry` answers from one shared WebSocket the server opens to NASA's public ISSLive feed (`wss://push.lightstreamer.com`), only while a browser has asked in the last two minutes; every byte from the feed is parsed as untrusted text, frames over 64 KB are dropped, and only the listed joint and clock items are kept. The route uses the keyless same-site checks and a per-client rate limit; with the flag unset (the default) it answers `{ configured: false }` and the server opens no socket.
|
||||
- **No verbatim client headers upstream.** The CCTV media route is the one route that relays a request header (`Range`, for video seeking). It is parsed and canonicalized before it is forwarded: one `bytes=` range only, with every accepted form — explicit span, open-ended and suffix — bounded to the same 64 MiB ceiling the relay applies to a declared response body. Multi-range, malformed, inverted and non-`bytes` values are dropped and the request proceeds without a `Range`, as RFC 7233 §3.1 prescribes. Bounding the request bounds what is asked for: a response that declares no length — live streamed media, or a chunked body from an upstream that ignores the `Range` — has no ceiling. An upstream request the browser has stopped waiting for is cancelled rather than left running, whether the viewer leaves before the headers arrive or during the body.
|
||||
- **The Data Library proxy fetches manifest upstreams only.** `/api/library/data/<id>`, `/api/library/tile/<id>/<z>/<x>/<y>` and `/api/library/index/<id>` (a partitioned GeoParquet entry's file index, built from an S3 ListObjectsV2 listing and one ranged footer read per file, cached in memory for the entry's `cacheSeconds`) resolve the id against the validated manifests in `src/library/entries/`; the browser never supplies a URL, and every derived request must stay on the manifest's https host. Redirects are refused, dataset bodies are capped while streaming at the manifest's `maxBytes` (at most 32 MiB) and tiles at 2 MiB of `image/png`, `image/jpeg` or `image/webp`, responses are cached in memory only (at most 512 tiles), requests are rate-limited per client, and upstream error text is never returned. A keyed entry must be proxied; its key is read from this server's environment through the key registry and its routes refuse cross-site and forwarded requests like the other cost-bearing routes. Browser-direct entries are fetched by the browser with no cookies or referrer.
|
||||
- **Transit fetches registered feeds only.** `/api/transit/vehicles/<id>` resolves the id against `src/data/transitFeeds.js`; the browser never supplies a URL, and a feed that is registered but disabled does not resolve at all. Redirects are followed manually and each hop is validated against the feed's own https origin before it is requested, so an off-origin or downgraded hop is refused rather than contacted. Bodies are capped at 8 MB, the protobuf is decoded server-side under entity-count and string-length ceilings, a differential feed is refused, and snapshots live 15 s in memory with no disk cache. A per-feed admission limiter and a failure cooldown ladder bound what this process can ask of any operator.
|
||||
|
||||
+6
-4
@@ -55,7 +55,8 @@ function photonEndpointSetting(value) {
|
||||
* Content-Security-Policy for every document the dev/preview server serves.
|
||||
* No inline script is permitted, and the only foreign script origins are the
|
||||
* three that the Bhote Koshi event's embedded media needs (YouTube, Facebook
|
||||
* and X), which frame-src matches for their players and posts. 'unsafe-eval' is
|
||||
* and X), which frame-src matches for their players and posts; the stations'
|
||||
* LIVE video uses the same YouTube player, after the viewer presses Play. 'unsafe-eval' is
|
||||
* required: Knockout (bundled inside @cesium/widgets) resolves the global
|
||||
* object with `(0, eval)("this")` at module load, and without it the Cesium
|
||||
* widget never initializes (verified in headless Chrome). It also covers
|
||||
@@ -66,9 +67,10 @@ function photonEndpointSetting(value) {
|
||||
*/
|
||||
export const BROWSER_CSP = [
|
||||
"default-src 'self'",
|
||||
// The Bhote Koshi event's embedded media: the YouTube player API, the
|
||||
// Facebook video SDK and X's post widget (src/data/bhoteKoshiEmbeddedMedia.js);
|
||||
// and the Maps JavaScript API that Street Level's Google Street View runs on.
|
||||
// The Bhote Koshi event's embedded media: the YouTube player API (also the
|
||||
// stations' LIVE video, src/data/youtubeLivePlayer.js), the Facebook video
|
||||
// SDK and X's post widget (src/data/bhoteKoshiEmbeddedMedia.js); and the
|
||||
// Maps JavaScript API that Street Level's Google Street View runs on.
|
||||
"script-src 'self' 'unsafe-eval' blob: https://www.youtube.com https://connect.facebook.net https://platform.twitter.com https://maps.googleapis.com",
|
||||
"style-src 'self' 'unsafe-inline' https://fonts.googleapis.com",
|
||||
"font-src 'self' data: https://fonts.gstatic.com",
|
||||
|
||||
+21
-16
@@ -2081,27 +2081,32 @@ which no stream is listed for yet), and the keys are read again every 2 s while
|
||||
something is selected, since a docked entry is judged so only once both
|
||||
orbits have been compared. The section shows the subject, the stream's name
|
||||
with two arrows when there are several, a screen and a status line. It
|
||||
starts collapsed, and the player loads as soon as a station is selected:
|
||||
`youtubeLivePlayer.js` builds YouTube's player on the privacy-enhanced host,
|
||||
muted, with the IFrame API, and reads its state back (the views ask for the
|
||||
stream whenever one is chosen and nothing plays, `src/ui/liveScreen.js`).
|
||||
The section's +/- only hides and shows the body; the stream plays on, muted,
|
||||
underneath. ON AIR with a blinking red dot while it plays; an amber dot
|
||||
while it starts; an offline card ("Stream is offline", with Try again) when
|
||||
starts collapsed, and nothing loads on selection: the screen is a poster
|
||||
with Play, under the line "Video plays from YouTube, which sees your IP
|
||||
address." Play is the one thing that loads the player:
|
||||
`youtubeLivePlayer.js` builds YouTube's player (the IFrame API from
|
||||
`www.youtube.com`, the video on `www.youtube-nocookie.com`), muted, and reads
|
||||
its state back. Collapsing the section, collapsing or closing Context, or the
|
||||
section leaving the page removes the player, so nothing plays unseen. ON AIR
|
||||
with a blinking red dot while it plays; LOADING with an amber dot while it
|
||||
starts; an offline card ("Stream is offline", with Try again) when
|
||||
the player reports the video ended, errored or did not start within 25 s,
|
||||
which is how an off-air broadcast shows; "This stream cannot play here" when
|
||||
the owner refuses embedding or the API does not load. Stepping to another
|
||||
stream hands a playing one over; a new selection, clearing it or turning the
|
||||
layer off removes the player. In the Cockpit the rail is hidden, so the
|
||||
stream hands a playing one over; a selection that moves to an object
|
||||
without that stream, clearing it or turning the layer off removes the
|
||||
player, while another entry of the same station (a module, a docked vehicle,
|
||||
the Cockpit stepping between views) keeps it. In the Cockpit the rail is hidden, so the
|
||||
briefing card gains a fourth page, LIVE (SIG / NEWS / LOCAL / LIVE,
|
||||
`CockpitLivePage.vue`), with the same subject line, arrows, screen, states
|
||||
and credit; it is offered only while the ridden subject has a stream, and
|
||||
with none the briefing keeps its three pages. There is one player: on entry
|
||||
it is built again in the page's screen, on exit in the section's (an embedded
|
||||
player cannot change parents without reloading). Previous, Next and the tabs
|
||||
reach the LIVE page; the automatic 9-second cycle never turns to it and
|
||||
waits while it is shown. The credit links the owner and the stream's own
|
||||
page, and the section's note says the video plays from YouTube.
|
||||
and credit, and the same poster with Play under the IP line; it is offered
|
||||
only while the ridden subject has a stream, and with none the briefing keeps
|
||||
its three pages. There is one player: entering or leaving the Cockpit
|
||||
removes it (an embedded player cannot change parents without reloading, and
|
||||
the view it was in is hidden), and so does leaving the LIVE page; the view
|
||||
now shown offers Play again. Previous, Next and the tabs reach the LIVE page;
|
||||
the automatic 9-second cycle never turns to it and waits while it is shown.
|
||||
The credit links the owner and the stream's own page.
|
||||
The model is NASA/JSC IGOAL's current-configuration station, reduced to 3 MB
|
||||
with its joints kept as nodes (`public/models/README.md`), fetched only once
|
||||
the camera nears its range, and drawn as an item of a `models` set of the
|
||||
|
||||
@@ -65,9 +65,9 @@ export function youtubeWatchUrl(videoId) {
|
||||
|
||||
/**
|
||||
* The parameters the live player is created with: starts on creation (the
|
||||
* player is built as soon as a subject with a stream is selected), muted so
|
||||
* the browser lets it, inline on phones, no related videos, and the page's
|
||||
* origin so the player API may be spoken to.
|
||||
* player is built only when the viewer presses Play), muted so the browser
|
||||
* lets it start once the player API has loaded, inline on phones, no related
|
||||
* videos, and the page's origin so the player API may be spoken to.
|
||||
* @param {string} origin The page's origin.
|
||||
* @returns {Record<string, string|number>}
|
||||
*/
|
||||
|
||||
@@ -71,6 +71,7 @@ function fixture(t) {
|
||||
playLive: () => liveActed.push(['play']),
|
||||
stopLive: () => liveActed.push(['stop']),
|
||||
retryLive: () => liveActed.push(['retry']),
|
||||
hideLive: (where) => liveActed.push(['hide', where]),
|
||||
});
|
||||
const offerLive = async (view) => {
|
||||
liveStore.publish(
|
||||
@@ -209,7 +210,12 @@ test('with a stream the LIVE page is the fourth, reached by the arrows and its t
|
||||
assert.ok($('#cockpit-live-previous'));
|
||||
assert.ok($('#cockpit-live-next'));
|
||||
assert.equal(text('#cockpit-live-badge-text'), 'OFF');
|
||||
assert.equal(text('#cockpit-live-status'), 'Starting…');
|
||||
assert.equal(text('#cockpit-live-status'), 'Click to play');
|
||||
assert.ok($('#cockpit-live-play'), 'Play, under the IP notice');
|
||||
assert.match(
|
||||
page.querySelector('.cockpit-live-privacy').textContent,
|
||||
/sees your IP address/,
|
||||
);
|
||||
assert.equal(
|
||||
$('#cockpit-live-watch-link').getAttribute('href'),
|
||||
'https://www.youtube.com/watch?v=ROboUHfPUrU',
|
||||
@@ -221,15 +227,14 @@ test('with a stream the LIVE page is the fourth, reached by the arrows and its t
|
||||
assert.equal(text('#cockpit-brief-position'), '1 / 4');
|
||||
});
|
||||
|
||||
test('the LIVE page asks for the stream as soon as it is offered, and its controls reach LiveControls', async (t) => {
|
||||
test('the LIVE page loads the stream only on Play, stops it when left, and its controls reach LiveControls', async (t) => {
|
||||
const { $, owner, offerLive, liveActed } = fixture(t);
|
||||
await offerLive({});
|
||||
assert.deepEqual(
|
||||
liveActed,
|
||||
[['play']],
|
||||
'the player starts on selection, whichever page is shown',
|
||||
);
|
||||
assert.deepEqual(liveActed, [], 'riding the station loads no player');
|
||||
showBriefPage.call(owner, 3);
|
||||
await nextTick();
|
||||
$('#cockpit-live-play').click();
|
||||
assert.deepEqual(liveActed, [['play']]);
|
||||
await offerLive({ state: 'playing' });
|
||||
const page = $('[data-cockpit-brief-page="live"]');
|
||||
assert.equal($('#cockpit-live-badge-text').textContent, 'ON AIR');
|
||||
@@ -245,6 +250,12 @@ test('the LIVE page asks for the stream as soon as it is offered, and its contro
|
||||
$('#cockpit-live-next').click();
|
||||
$('#cockpit-live-previous').click();
|
||||
assert.deepEqual(liveActed, [['play'], ['cycle', 1], ['cycle', -1]]);
|
||||
// Leaving the page stops what plays there.
|
||||
showBriefPage.call(owner, 0);
|
||||
await nextTick();
|
||||
assert.deepEqual(liveActed.at(-1), ['hide', 'cockpit']);
|
||||
showBriefPage.call(owner, 3);
|
||||
await nextTick();
|
||||
await offerLive({ state: 'offline', reason: 'timeout' });
|
||||
const card = page.querySelector('.live-card');
|
||||
assert.equal(card.classList.contains('offline'), true);
|
||||
|
||||
+67
-22
@@ -27,12 +27,14 @@ export const LIVE_SUBJECT_REFRESH_MS = 2000;
|
||||
* Own the live video: which object is selected (the tracking layers'
|
||||
* `gev:awareness-subject-selected`), which streams the list attaches to it,
|
||||
* and the one player. The views (the LIVE section in Context and the Cockpit
|
||||
* briefing's LIVE page) render what this publishes and ask for the stream to
|
||||
* start (`playLive`) as soon as one is chosen; the player is built into
|
||||
* whichever view is shown, the section's outside the Cockpit and the page's
|
||||
* inside it, and built again in the other when the Cockpit is entered or
|
||||
* left (an embedded player cannot change parents without reloading). It goes
|
||||
* when the selection changes or clears.
|
||||
* briefing's LIVE page) render what this publishes, and the player is built
|
||||
* only when the viewer presses Play in one of them (`playLive`): YouTube sees
|
||||
* the viewer's IP address, so selecting a station by click, a link, a scene
|
||||
* or voice never loads it. The player is built into the view that is shown,
|
||||
* the section's outside the Cockpit and the page's inside it, and goes when
|
||||
* that view is hidden (the section collapsed, Context closed, the Cockpit
|
||||
* page left: `hideLive`), when the Cockpit is entered or left, and when the
|
||||
* selection moves to an object without that stream or clears.
|
||||
*/
|
||||
export class LiveControls {
|
||||
/**
|
||||
@@ -72,6 +74,8 @@ export class LiveControls {
|
||||
this.cockpitActive =
|
||||
documentRef?.body?.classList?.contains?.('cockpit-mode') === true;
|
||||
this.timer = null;
|
||||
/** The stop held back for one tick after a clear (see `_onCleared`). */
|
||||
this.clearGrace = null;
|
||||
this.listeners = new AbortController();
|
||||
const { signal } = this.listeners;
|
||||
const target = globalRef.addEventListener ? globalRef : null;
|
||||
@@ -95,48 +99,88 @@ export class LiveControls {
|
||||
playLive: () => this.play(),
|
||||
stopLive: () => this.stop(),
|
||||
retryLive: () => this.play({ restart: true }),
|
||||
hideLive: (where) => this.hide(where),
|
||||
});
|
||||
store.publish(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* A new selection. A player that is on keeps playing when the new subject
|
||||
* offers the same stream (another entry of the same station: a module, a
|
||||
* docked vehicle, the Cockpit stepping between views on it); otherwise it
|
||||
* goes.
|
||||
*/
|
||||
_onSelected(detail) {
|
||||
if (this.destroyed || !detail?.layerId || detail.id == null) return;
|
||||
const same =
|
||||
this.subject &&
|
||||
this.subject.layerId === detail.layerId &&
|
||||
String(this.subject.id) === String(detail.id);
|
||||
this._cancelClearGrace();
|
||||
this.subject = {
|
||||
layerId: detail.layerId,
|
||||
id: detail.id,
|
||||
label: String(detail.label ?? detail.id),
|
||||
};
|
||||
if (!same) this.stop();
|
||||
if (this.player) {
|
||||
const offered = liveStreamsFor(this._subjectKeys(), this.streams);
|
||||
if (offered.some((stream) => stream.id === this.playerStreamId))
|
||||
this.currentId = this.playerStreamId;
|
||||
else this.stop();
|
||||
}
|
||||
this._refresh();
|
||||
this._arm();
|
||||
}
|
||||
|
||||
/**
|
||||
* The selection cleared. With a player on, the stop waits one tick: the
|
||||
* Cockpit stepping between views on a station clears the selection and
|
||||
* selects the next entry at once, and a player for the same stream should
|
||||
* not be torn down and rebuilt between the two.
|
||||
*/
|
||||
_onCleared(detail) {
|
||||
if (this.destroyed || !this.subject) return;
|
||||
if (detail?.layerId && detail.layerId !== this.subject.layerId) return;
|
||||
this.subject = null;
|
||||
this.stop();
|
||||
this._disarm();
|
||||
if (this.player && this.globalRef.setTimeout) {
|
||||
this._cancelClearGrace();
|
||||
this.clearGrace = this.globalRef.setTimeout(() => {
|
||||
this.clearGrace = null;
|
||||
if (this.destroyed || this.subject) return;
|
||||
this.stop();
|
||||
this._refresh();
|
||||
}, 0);
|
||||
return;
|
||||
}
|
||||
this.stop();
|
||||
this._refresh();
|
||||
}
|
||||
|
||||
_cancelClearGrace() {
|
||||
if (this.clearGrace !== null)
|
||||
this.globalRef.clearTimeout?.(this.clearGrace);
|
||||
this.clearGrace = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* The Cockpit went on or off: the view shown changed, so a player that is
|
||||
* loading or playing is built again in the host now shown. With no such
|
||||
* host in the page the player goes, and the view starts it again once its
|
||||
* screen is there.
|
||||
* The Cockpit went on or off: the view the player was in is hidden now,
|
||||
* so the player goes. The view now shown offers Play again.
|
||||
*/
|
||||
_onCockpitMode(active) {
|
||||
if (this.destroyed || active === this.cockpitActive) return;
|
||||
this.cockpitActive = active;
|
||||
if (this.player === null) return;
|
||||
const host = this._host();
|
||||
if (host && host === this.playerHost) return;
|
||||
if (!this.play({ restart: true })) this.stop();
|
||||
this.stop();
|
||||
}
|
||||
|
||||
/**
|
||||
* A view was hidden (`section`: the LIVE section collapsed or Context
|
||||
* closed; `cockpit`: the briefing left its LIVE page or went): the player
|
||||
* goes if it was in that view's screen, so nothing plays unseen.
|
||||
* @param {'section'|'cockpit'} where
|
||||
* @returns {boolean} True when a player was removed.
|
||||
*/
|
||||
hide(where) {
|
||||
const id =
|
||||
where === 'cockpit' ? COCKPIT_LIVE_PLAYER_HOST_ID : LIVE_PLAYER_HOST_ID;
|
||||
if (!this.player || this.playerHost?.id !== id) return false;
|
||||
return this.stop();
|
||||
}
|
||||
|
||||
/** The element the player belongs in now: the Cockpit page's, or the section's. */
|
||||
@@ -254,8 +298,8 @@ export class LiveControls {
|
||||
|
||||
/**
|
||||
* Start the chosen stream in the host now shown: the one call that loads
|
||||
* the player. A player already loading or playing that stream in that host
|
||||
* is left alone, so the views may ask whenever they see nothing playing;
|
||||
* the player, made only by the viewer's Play (or Try again). A player
|
||||
* already loading or playing that stream in that host is left alone;
|
||||
* `restart` (Try again) builds a fresh one regardless.
|
||||
* @returns {boolean} True when a player is loading or playing afterwards.
|
||||
*/
|
||||
@@ -309,6 +353,7 @@ export class LiveControls {
|
||||
|
||||
destroy() {
|
||||
if (this.destroyed) return;
|
||||
this._cancelClearGrace();
|
||||
this.stop();
|
||||
this.destroyed = true;
|
||||
this._disarm();
|
||||
|
||||
@@ -59,6 +59,19 @@ function fixture({
|
||||
const timer = intervals.find((entry) => entry.id === id);
|
||||
if (timer) timer.cleared = true;
|
||||
};
|
||||
const timeouts = [];
|
||||
globalRef.setTimeout = (callback, ms) => {
|
||||
timeouts.push({ callback, ms, done: false });
|
||||
return timeouts.length;
|
||||
};
|
||||
globalRef.clearTimeout = (id) => {
|
||||
if (timeouts[id - 1]) timeouts[id - 1].done = true;
|
||||
};
|
||||
/** Run the timeouts due now, as the next tick would. */
|
||||
const tick = () => {
|
||||
for (const timeout of timeouts.splice(0))
|
||||
if (!timeout.done) timeout.callback();
|
||||
};
|
||||
const host = { id: LIVE_PLAYER_HOST_ID };
|
||||
const cockpitHost = { id: COCKPIT_LIVE_PLAYER_HOST_ID };
|
||||
const documentRef = {
|
||||
@@ -125,6 +138,7 @@ function fixture({
|
||||
layouts,
|
||||
intervals,
|
||||
running,
|
||||
tick,
|
||||
host,
|
||||
cockpitHost,
|
||||
};
|
||||
@@ -276,12 +290,37 @@ test('clearing the selection takes the section down; another layer clearing does
|
||||
f.dispatch('gev:awareness-subject-cleared', { layerId: 'flights' });
|
||||
assert.equal(f.view().count, 2, 'another layer clearing is not ours');
|
||||
f.dispatch('gev:awareness-subject-cleared', { layerId: 'satellites' });
|
||||
assert.equal(f.running().length, 0, 'the timer stops with the selection');
|
||||
// The stop waits a tick, for a selection that moves straight on.
|
||||
assert.equal(f.players[0].destroyed, 0);
|
||||
f.tick();
|
||||
assert.equal(f.view(), null);
|
||||
assert.equal(f.players[0].destroyed, 1);
|
||||
assert.equal(f.running().length, 0, 'the timer stops with the selection');
|
||||
});
|
||||
|
||||
test("entering the Cockpit builds the player again in the briefing page's screen, and leaving it in the section's", () => {
|
||||
test('a selection that moves straight on to an entry with the same stream keeps the player', () => {
|
||||
const f = fixture();
|
||||
f.setKeys(['station:test']);
|
||||
f.select();
|
||||
f.store.act('playLive');
|
||||
// The Cockpit stepping to the next view on the station: cleared, then the
|
||||
// next entry selected, in one go.
|
||||
f.dispatch('gev:awareness-subject-cleared', { layerId: 'satellites' });
|
||||
f.select({ id: 49044, label: 'ISS (NAUKA)' });
|
||||
f.tick();
|
||||
assert.equal(f.players.length, 1, 'not rebuilt');
|
||||
assert.equal(f.players[0].destroyed, 0);
|
||||
assert.equal(f.view().label, 'ISS (NAUKA)');
|
||||
assert.equal(f.view().current.id, 'one');
|
||||
// One without that stream stops it.
|
||||
f.dispatch('gev:awareness-subject-cleared', { layerId: 'satellites' });
|
||||
f.setKeys(['station:other']);
|
||||
f.select({ id: 99999, label: 'OTHER' });
|
||||
f.tick();
|
||||
assert.equal(f.players[0].destroyed, 1);
|
||||
});
|
||||
|
||||
test('entering or leaving the Cockpit removes the player: the view now shown offers Play again', () => {
|
||||
const f = fixture();
|
||||
f.setKeys(['station:test']);
|
||||
f.select();
|
||||
@@ -289,20 +328,43 @@ test("entering the Cockpit builds the player again in the briefing page's screen
|
||||
f.players[0].options.onChange({ state: 'playing', reason: null });
|
||||
f.dispatch('gev:cockpit-mode-changed', { active: true });
|
||||
assert.equal(f.players[0].destroyed, 1, 'the rail is hidden in the Cockpit');
|
||||
assert.equal(f.players.length, 2);
|
||||
assert.equal(f.players[1].options.host, f.cockpitHost);
|
||||
assert.equal(f.players[1].options.videoId, 'AAAAAAAAAAA');
|
||||
assert.equal(f.view().state, 'loading', 'a fresh player starts again');
|
||||
assert.equal(f.players.length, 1, 'nothing is built by itself');
|
||||
assert.equal(f.view().state, 'idle');
|
||||
// The same state again changes nothing.
|
||||
f.dispatch('gev:cockpit-mode-changed', { active: true });
|
||||
assert.equal(f.players.length, 2);
|
||||
// playLive from the hidden section's view finds the Cockpit's screen too.
|
||||
assert.equal(f.players.length, 1);
|
||||
// Play in the Cockpit's page builds it in that page's screen.
|
||||
assert.equal(f.store.act('playLive'), true);
|
||||
assert.equal(f.players.length, 2);
|
||||
assert.equal(f.players[1].options.host, f.cockpitHost);
|
||||
f.dispatch('gev:cockpit-mode-changed', { active: false });
|
||||
assert.equal(f.players[1].destroyed, 1);
|
||||
assert.equal(f.players.length, 3);
|
||||
assert.equal(f.players[2].options.host, f.host);
|
||||
assert.equal(f.players.length, 2);
|
||||
});
|
||||
|
||||
test('a view that is hidden removes the player only when it is in that view', () => {
|
||||
const f = fixture();
|
||||
f.setKeys(['station:test']);
|
||||
f.select();
|
||||
f.store.act('playLive');
|
||||
assert.equal(f.store.act('hideLive', 'cockpit'), false, 'not in the page');
|
||||
assert.equal(f.players[0].destroyed, 0);
|
||||
assert.equal(f.store.act('hideLive', 'section'), true);
|
||||
assert.equal(f.players[0].destroyed, 1);
|
||||
assert.equal(f.view().state, 'idle');
|
||||
assert.equal(f.store.act('hideLive', 'section'), false, 'nothing left');
|
||||
});
|
||||
|
||||
test('selecting a station with streams builds no player until Play', () => {
|
||||
const f = fixture();
|
||||
f.setKeys(['station:test']);
|
||||
f.select();
|
||||
f.select({ origin: 'pick' });
|
||||
f.dispatch('gev:cockpit-mode-changed', { active: true });
|
||||
f.dispatch('gev:cockpit-mode-changed', { active: false });
|
||||
assert.equal(f.players.length, 0);
|
||||
assert.equal(f.view().state, 'idle');
|
||||
f.store.act('playLive');
|
||||
assert.equal(f.players.length, 1);
|
||||
});
|
||||
|
||||
test('the Cockpit going on or off with nothing playing builds nothing', () => {
|
||||
|
||||
+36
-15
@@ -29,6 +29,7 @@ function fixture(t) {
|
||||
playLive: () => acted.push(['play']),
|
||||
stopLive: () => acted.push(['stop']),
|
||||
retryLive: () => acted.push(['retry']),
|
||||
hideLive: (where) => acted.push(['hide', where]),
|
||||
});
|
||||
const chrome = usePanelChromeStore(pinia);
|
||||
const token = chrome.connect({ toggle() {}, pin() {} });
|
||||
@@ -66,7 +67,7 @@ function fixture(t) {
|
||||
);
|
||||
await settle();
|
||||
};
|
||||
return { $, publish, acted, setOpen };
|
||||
return { $, publish, acted, setOpen, chrome, token };
|
||||
}
|
||||
|
||||
test('without a view the section is hidden and shows OFF', (t) => {
|
||||
@@ -81,7 +82,7 @@ test('without a view the section is hidden and shows OFF', (t) => {
|
||||
assert.deepEqual(acted, [], 'nothing to start');
|
||||
});
|
||||
|
||||
test('a view shows the subject and the stream, and starts it at once, with the section collapsed', async (t) => {
|
||||
test('a view shows the subject, the stream and Play under the IP notice, and loads nothing by itself', async (t) => {
|
||||
const { $, publish, acted } = fixture(t);
|
||||
await publish({});
|
||||
const panel = $('live-panel');
|
||||
@@ -96,17 +97,30 @@ test('a view shows the subject and the stream, and starts it at once, with the s
|
||||
'https://www.youtube.com/watch?v=ROboUHfPUrU',
|
||||
);
|
||||
assert.equal($('live-watch-link').getAttribute('rel'), 'noopener noreferrer');
|
||||
assert.deepEqual(acted, [['play']], 'the stream starts on selection');
|
||||
// Loading and playing change nothing further.
|
||||
assert.deepEqual(acted, [], 'selecting the station loads no player');
|
||||
// The notice that YouTube sees the viewer's IP address comes before Play.
|
||||
const notice = panel.querySelector('.live-privacy');
|
||||
const play = $('live-play-btn');
|
||||
assert.ok(notice && play);
|
||||
assert.match(notice.textContent, /sees your IP address/);
|
||||
assert.equal(
|
||||
notice.compareDocumentPosition(play) & Node.DOCUMENT_POSITION_FOLLOWING,
|
||||
Node.DOCUMENT_POSITION_FOLLOWING,
|
||||
'the notice is above Play',
|
||||
);
|
||||
assert.equal($('live-status').textContent, 'Click to play');
|
||||
play.click();
|
||||
assert.deepEqual(acted, [['play']], 'Play is what loads the player');
|
||||
// Loading and playing hide Play and ask for nothing more.
|
||||
await publish({ state: 'loading' });
|
||||
assert.equal($('live-play-btn'), null);
|
||||
await publish({ state: 'playing' });
|
||||
assert.deepEqual(acted, [['play']]);
|
||||
});
|
||||
|
||||
test('a different stream chosen while idle starts too', async (t) => {
|
||||
const { publish, acted } = fixture(t);
|
||||
test('a different stream chosen while idle waits for Play too', async (t) => {
|
||||
const { $, publish, acted } = fixture(t);
|
||||
await publish({});
|
||||
assert.deepEqual(acted, [['play']]);
|
||||
await publish({
|
||||
current: {
|
||||
id: 'iss-crew',
|
||||
@@ -118,19 +132,26 @@ test('a different stream chosen while idle starts too', async (t) => {
|
||||
},
|
||||
index: 1,
|
||||
});
|
||||
assert.deepEqual(acted, [['play'], ['play']]);
|
||||
assert.deepEqual(acted, []);
|
||||
assert.ok($('live-play-btn'));
|
||||
});
|
||||
|
||||
test('collapsing or opening the section neither stops nor restarts the stream', async (t) => {
|
||||
const { $, publish, acted, setOpen } = fixture(t);
|
||||
test('collapsing the section, or Context, stops the player; opening it starts nothing', async (t) => {
|
||||
const { $, publish, acted, setOpen, chrome, token } = fixture(t);
|
||||
await setOpen(true);
|
||||
await publish({ state: 'playing' });
|
||||
assert.deepEqual(acted, [], 'already playing: nothing to start');
|
||||
await setOpen(false);
|
||||
assert.deepEqual(acted, [], 'the +/- only hides the body');
|
||||
assert.ok($('live-player-host'), 'the player keeps its element');
|
||||
assert.deepEqual(acted, [['hide', 'section']], 'nothing plays unseen');
|
||||
assert.ok($('live-player-host'), 'the screen keeps its element');
|
||||
await setOpen(true);
|
||||
assert.deepEqual(acted, []);
|
||||
assert.deepEqual(acted, [['hide', 'section']], 'opening starts nothing');
|
||||
chrome.publish(token, 'global-context-panel', { collapsed: true });
|
||||
await settle();
|
||||
assert.deepEqual(acted, [
|
||||
['hide', 'section'],
|
||||
['hide', 'section'],
|
||||
]);
|
||||
});
|
||||
|
||||
test('while playing the badge says ON AIR with the blinking dot, and there is no card', async (t) => {
|
||||
@@ -151,10 +172,10 @@ test('while playing the badge says ON AIR with the blinking dot, and there is no
|
||||
assert.equal($('live-status').textContent, 'Live');
|
||||
});
|
||||
|
||||
test('starting shows the waiting dot', async (t) => {
|
||||
test('starting shows the waiting dot and says LOADING', async (t) => {
|
||||
const { $, publish } = fixture(t);
|
||||
await publish({ state: 'loading' });
|
||||
assert.equal($('live-badge-text').textContent, 'OFF');
|
||||
assert.equal($('live-badge-text').textContent, 'LOADING');
|
||||
assert.equal(
|
||||
$('live-panel').querySelector('.live-dot').classList.contains('waiting'),
|
||||
true,
|
||||
|
||||
+15
-20
@@ -1,13 +1,14 @@
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { computed, nextTick, watch } from 'vue';
|
||||
import { computed } from 'vue';
|
||||
import { t } from '../i18n/index.js';
|
||||
import { useLiveStore } from './stores/live.js';
|
||||
|
||||
/**
|
||||
* What the LIVE section in Context and the Cockpit briefing's LIVE page
|
||||
* share: the live store's view, its state read as words, and the rule that
|
||||
* starts the stream. Each view calls this from its setup and renders the
|
||||
* result; the controls call LiveControls through `act`.
|
||||
* share: the live store's view and its state read as words. Each view calls
|
||||
* this from its setup and renders the result; the controls call LiveControls
|
||||
* through `act`. Nothing here starts the stream: the views show Play while
|
||||
* it is `idle`, and the player is loaded only when the viewer presses it.
|
||||
*/
|
||||
export function useLiveScreen() {
|
||||
const store = useLiveStore();
|
||||
@@ -17,7 +18,12 @@ export function useLiveScreen() {
|
||||
const loading = computed(() => view.value?.state === 'loading');
|
||||
const offline = computed(() => view.value?.state === 'offline');
|
||||
const unavailable = computed(() => view.value?.state === 'unavailable');
|
||||
const badgeText = computed(() => (playing.value ? t('ON AIR') : t('OFF')));
|
||||
const idle = computed(
|
||||
() => Boolean(view.value) && view.value.state === 'idle',
|
||||
);
|
||||
const badgeText = computed(() =>
|
||||
playing.value ? t('ON AIR') : loading.value ? t('LOADING') : t('OFF'),
|
||||
);
|
||||
const statusText = computed(() => {
|
||||
switch (view.value?.state) {
|
||||
case 'playing':
|
||||
@@ -26,28 +32,17 @@ export function useLiveScreen() {
|
||||
return t('Stream is offline');
|
||||
case 'unavailable':
|
||||
return t('This stream cannot play here');
|
||||
default:
|
||||
case 'loading':
|
||||
return t('Starting…');
|
||||
default:
|
||||
return t('Click to play');
|
||||
}
|
||||
});
|
||||
|
||||
// Start the stream as soon as one is chosen and nothing plays, once the
|
||||
// screen is in the page (the player is built into it). Which screen is
|
||||
// LiveControls' choice, and asking from both views starts nothing twice.
|
||||
// A stream that went offline or cannot play stays as it is until Try again.
|
||||
watch(
|
||||
[() => view.value?.current?.id ?? null, () => view.value?.state ?? null],
|
||||
async ([streamId, state]) => {
|
||||
if (!streamId || state !== 'idle') return;
|
||||
await nextTick();
|
||||
act('playLive');
|
||||
},
|
||||
{ immediate: true, flush: 'post' },
|
||||
);
|
||||
|
||||
return {
|
||||
view,
|
||||
act,
|
||||
idle,
|
||||
playing,
|
||||
loading,
|
||||
offline,
|
||||
|
||||
@@ -140,6 +140,36 @@
|
||||
.live-screen:not(.active) .live-player-host {
|
||||
display: none;
|
||||
}
|
||||
/* The poster's Play: the only way the player is loaded. */
|
||||
.live-play {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
margin: auto;
|
||||
width: max-content;
|
||||
height: max-content;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
min-width: 44px;
|
||||
min-height: 44px;
|
||||
padding: 8px 18px;
|
||||
border: 1px solid rgba(255, 255, 255, 0.45);
|
||||
border-radius: 4px;
|
||||
background: rgba(0, 7, 12, 0.72);
|
||||
color: #f4fbff;
|
||||
font: inherit;
|
||||
font-size: 12px;
|
||||
letter-spacing: 0.1em;
|
||||
cursor: pointer;
|
||||
}
|
||||
.live-play:hover,
|
||||
.live-play:focus-visible {
|
||||
border-color: #ff3b3b;
|
||||
outline: none;
|
||||
}
|
||||
.live-play .material-symbols-outlined {
|
||||
font-size: 20px;
|
||||
}
|
||||
.live-card {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
|
||||
@@ -85,7 +85,7 @@ function leaveSignals() {
|
||||
<a class="cockpit-weather-credit" href="https://open-meteo.com/" target="_blank" rel="noopener">{{ t('Weather data by Open-Meteo.com') }}</a>
|
||||
</section>
|
||||
<section data-cockpit-brief-page="live" :aria-label="t('Live video')" :hidden="b.pageId !== 'live'">
|
||||
<CockpitLivePage v-if="live" />
|
||||
<CockpitLivePage v-if="live" :shown="b.pageId === 'live'" />
|
||||
</section>
|
||||
</div>
|
||||
<footer class="cockpit-signal-footer">
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<script setup>
|
||||
import { onBeforeUnmount, watch } from 'vue';
|
||||
import { t } from '../../../i18n/index.js';
|
||||
import { useLiveScreen } from '../../liveScreen.js';
|
||||
|
||||
@@ -6,11 +7,18 @@ import { useLiveScreen } from '../../liveScreen.js';
|
||||
// card's measure, for the ridden subject's streams. The briefing renders it
|
||||
// only while a stream is on offer. LiveControls builds the player into
|
||||
// `#cockpit-live-player-host` while the Cockpit is on (the right rail, and
|
||||
// the section's screen with it, is hidden there), and the page's controls
|
||||
// call LiveControls through the live store, as the section's do.
|
||||
// the section's screen with it, is hidden there), only when the viewer
|
||||
// presses Play, under the notice that YouTube sees their IP address. The
|
||||
// page's controls call LiveControls through the live store, as the section's
|
||||
// do. Leaving the page, or the page going, stops the player.
|
||||
const props = defineProps({
|
||||
/** Whether the briefing shows this page now. */
|
||||
shown: { type: Boolean, default: true },
|
||||
});
|
||||
const {
|
||||
view,
|
||||
act,
|
||||
idle,
|
||||
playing,
|
||||
loading,
|
||||
offline,
|
||||
@@ -18,6 +26,13 @@ const {
|
||||
badgeText,
|
||||
statusText,
|
||||
} = useLiveScreen();
|
||||
watch(
|
||||
() => props.shown,
|
||||
(now) => {
|
||||
if (!now) act('hideLive', 'cockpit');
|
||||
},
|
||||
);
|
||||
onBeforeUnmount(() => act('hideLive', 'cockpit'));
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -31,9 +46,11 @@ const {
|
||||
<span id="cockpit-live-stream-title" class="live-stream-title" aria-live="polite">{{ t(view.current.title) }}<small v-if="view.count > 1"> · {{ view.index + 1 }}/{{ view.count }}</small></span>
|
||||
<button v-if="view.count > 1" id="cockpit-live-next" type="button" class="live-step" @click="act('cycleLive', 1)" :aria-label="t('Next stream')" :title="t('Next stream')"><span class="material-symbols-outlined" aria-hidden="true">chevron_right</span></button>
|
||||
</div>
|
||||
<p class="live-privacy cockpit-live-privacy">{{ t('Video plays from YouTube, which sees your IP address.') }}</p>
|
||||
<!-- The player's element stays put across re-renders: LiveControls mounts the player in it. -->
|
||||
<div class="live-screen" :class="{ active: playing || loading }">
|
||||
<div id="cockpit-live-player-host" class="live-player-host"></div>
|
||||
<button v-if="idle" id="cockpit-live-play" type="button" class="live-play" @click="act('playLive')"><span class="material-symbols-outlined" aria-hidden="true">play_arrow</span>{{ t('Play') }}</button>
|
||||
<div v-if="offline || unavailable" class="live-card" :class="{ offline, unavailable }">
|
||||
<span class="live-card-dot" aria-hidden="true"></span>
|
||||
<strong>{{ offline ? t('Stream is offline') : t('This stream cannot play here') }}</strong>
|
||||
|
||||
@@ -1,20 +1,24 @@
|
||||
<script setup>
|
||||
import { computed } from 'vue';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { computed, onBeforeUnmount, watch } from 'vue';
|
||||
import { t } from '../../../i18n/index.js';
|
||||
import RailPanel from '../../rail/RailPanel.vue';
|
||||
import { vClassToggle } from '../../rail/classToggle.js';
|
||||
import { useLiveScreen } from '../../liveScreen.js';
|
||||
import { usePanelChromeStore } from '../../stores/panelChrome.js';
|
||||
|
||||
// The LIVE section inside Context: the live streams attached to the selected
|
||||
// object (LiveControls publishes them), one at a time in the platform's own
|
||||
// player. It is there only while the selection has a stream, and the stream
|
||||
// starts as soon as one is chosen (useLiveScreen). The section starts
|
||||
// collapsed; its +/- hides and shows the body, and the player plays on,
|
||||
// muted, underneath. Its controls call LiveControls through the store.
|
||||
// player. It is there only while the selection has a stream. The player is
|
||||
// loaded only when the viewer presses Play, under the notice that YouTube
|
||||
// sees their IP address; collapsing the section, collapsing Context, or the
|
||||
// section leaving the page stops it. Its controls call LiveControls through
|
||||
// the store.
|
||||
const PANEL_ID = 'live-panel';
|
||||
const {
|
||||
view,
|
||||
act,
|
||||
idle,
|
||||
playing,
|
||||
loading,
|
||||
offline,
|
||||
@@ -22,6 +26,17 @@ const {
|
||||
badgeText,
|
||||
statusText,
|
||||
} = useLiveScreen();
|
||||
// Nothing plays unseen: a hidden section gives up its player.
|
||||
const { panels } = storeToRefs(usePanelChromeStore());
|
||||
const hidden = computed(
|
||||
() =>
|
||||
(panels.value[PANEL_ID]?.collapsed ?? true) ||
|
||||
panels.value['global-context-panel']?.collapsed === true,
|
||||
);
|
||||
watch(hidden, (now) => {
|
||||
if (now) act('hideLive', 'section');
|
||||
});
|
||||
onBeforeUnmount(() => act('hideLive', 'section'));
|
||||
const liveWords = computed(() => ({
|
||||
expandLabel: t('Expand Live section'),
|
||||
collapseLabel: t('Collapse Live section'),
|
||||
@@ -40,9 +55,11 @@ const liveWords = computed(() => ({
|
||||
<span id="live-stream-title" class="live-stream-title" aria-live="polite">{{ t(view.current.title) }}<small v-if="view.count > 1"> · {{ view.index + 1 }}/{{ view.count }}</small></span>
|
||||
<button v-if="view.count > 1" id="live-next-btn" type="button" class="live-step" @click="act('cycleLive', 1)" :aria-label="t('Next stream')" :title="t('Next stream')"><span class="material-symbols-outlined" aria-hidden="true">chevron_right</span></button>
|
||||
</div>
|
||||
<p class="live-privacy">{{ t('Video plays from YouTube, which sees your IP address.') }}</p>
|
||||
<!-- The player's element stays put across re-renders: LiveControls mounts the player in it. -->
|
||||
<div class="live-screen" :class="{ active: playing || loading }">
|
||||
<div id="live-player-host" class="live-player-host"></div>
|
||||
<button v-if="idle" id="live-play-btn" type="button" class="live-play" @click="act('playLive')"><span class="material-symbols-outlined" aria-hidden="true">play_arrow</span>{{ t('Play') }}</button>
|
||||
<div v-if="offline || unavailable" class="live-card" :class="{ offline, unavailable }">
|
||||
<span class="live-card-dot" aria-hidden="true"></span>
|
||||
<strong>{{ offline ? t('Stream is offline') : t('This stream cannot play here') }}</strong>
|
||||
@@ -51,7 +68,6 @@ const liveWords = computed(() => ({
|
||||
</div>
|
||||
<p id="live-status" class="live-status" role="status" aria-live="polite">{{ statusText }}</p>
|
||||
<p class="live-credit"><a :href="view.current.ownerUrl" target="_blank" rel="noopener noreferrer">{{ view.current.owner }}</a> · <a id="live-watch-link" :href="view.current.watchUrl" target="_blank" rel="noopener noreferrer">{{ t('Open on YouTube') }}</a></p>
|
||||
<p class="live-privacy">{{ t('Video plays from YouTube, which sees your IP address.') }}</p>
|
||||
</template>
|
||||
</RailPanel>
|
||||
</template>
|
||||
Reference in new issue
Block a user