Repository navigation
Feature: SoundCloud Audio provider - #9524
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
✅ Deploy Preview for vjs-registry ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for vjs10-site ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
Claude review: no high-confidence bugs found. |
@videojs/cdn
@videojs/cli
@videojs/core
@videojs/element
@videojs/html
@videojs/media
@videojs/react
@videojs/spf
@videojs/store
@videojs/utils
video.js
@videojs/cloudflare-video
@videojs/dash-video
@videojs/hlsjs-video
@videojs/mux-audio
@videojs/mux-video
@videojs/native-hls-video
@videojs/playerjs-video
@videojs/shaka-video
@videojs/soundcloud-audio
@videojs/spotify-audio
@videojs/tiktok-video
@videojs/twitch-video
@videojs/vimeo-video
@videojs/wistia-video
@videojs/youtube-video
@videojs/google-cast
@videojs/mux-data
commit: |
📦 Bundle Size Report🎨 @videojs/html
Small changes (12, ≤ 300 B)
Presets (7)
Media (20)
Players (5)
Skins (53)
UI Components (62)
⚛️ @videojs/react
Small changes (21, ≤ 300 B)
Presets (7)
Media (24)
Extensions (2)
Players (5)
Skins (34)
UI Components (39)
🧩 @videojs/core — 1 small size change
Entries (76)
🏷️ @videojs/element — no changesEntries (2)
📦 @videojs/store — no changesEntries (3)
🔧 @videojs/utils — no changesEntries (13)
📦 @videojs/cdn — 1 small size change
📦 @videojs/cloudflare-video — no changes📦 @videojs/dash-video — no changes📦 @videojs/google-cast — no changes📦 @videojs/hlsjs-video — no changes📦 @videojs/media
Entries (3)
📦 @videojs/mux — no changes📦 @videojs/mux-audio — no changesEntries (2)
📦 @videojs/mux-data — no changes📦 @videojs/mux-video — no changesEntries (2)
📦 @videojs/native-hls-video — no changes📦 @videojs/playerjs-video — no changes📦 @videojs/shaka-video — no changes📦 @videojs/soundcloud-audio
📦 @videojs/spf — no changesEntries (62)
📦 @videojs/spotify-audio — no changes📦 @videojs/tiktok-video — 1 small size change
📦 @videojs/twitch-video — 1 small size change
📦 @videojs/other — no changesEntries (3)
📦 @videojs/vimeo-video — no changes📦 @videojs/wistia-video — no changesEntries (2)
📦 @videojs/youtube-video — no changesℹ️ How to interpretEach entry is independently bundled, minified, and brotli-compressed. Initial size includes its static import graph; lazy dynamic chunks are reported separately. Entries are not additive because their dependency graphs overlap. Preset rows represent realistic combined bundles. Changes of 300 B or less across initial, lazy, and total size are collapsed, not discarded. Run |
luwes
left a comment
There was a problem hiding this comment.
mentioned internally, a missing controls attribute on the media tag should hide the native controls in this case the Soundcloud controls.
|
Claude review: no high-confidence bugs found. |
luwes
left a comment
There was a problem hiding this comment.
Thanks for this, it's thorough and well tested. I compared the package against the other embed adapters (spotify-audio, playerjs-video, tiktok-video), and there are a few structure and scope things to sort out before merge.
Drop short-link support for now. on.soundcloud.com links are the only reason the adapter makes a network call. The redirect behind a short link has no CORS headers, so the page can't read where it points, and the PR resolves it through SoundCloud's oEmbed endpoint instead. That one optional URL format brings a lot with it:
- an async step before the widget loads, with its own attach/load guards (
adapter.ts446-478) - a
fetchand a module-level cache insidesource.ts, which has no I/O or state in any other embed adapter - a new
MEDIA_ERR_NETWORKerror path - a
connect-srcrequirement in the CSP guide
Users can paste the full soundcloud.com/... URL instead, which the widget plays directly. Let's leave short links out of this PR and add them in a follow-up if people ask for them. The inline comments list the places to change.
Rebase onto the 10.2.0 release. main has released 10.2.0 (#9489) since this branch was cut. The new package and its manifest entry are still 10.1.0, but every package is in one linked-versions release-please group.
Remove the unused src/globals.d.ts.
Otherwise the layout lines up well with the other adapters: the parser in packages/media, the HTML and React wrappers, the site demos, the sandbox templates, and the workspace wiring.
fc8d4e2 to
2133c55
Compare
2133c55 to
2fdd678
Compare
One test transformed every framework, skin, and style variant under a single 30 second limit, and timed out when the full suite ran in parallel.
Track, set, private, short link, API, and widget embed URLs resolve to the soundcloud type. Profiles and other pages that list sounds resolve to null.
Speaks the widget postMessage protocol directly. The official api.js client rewrites every parameter but start_track to true or false on load, so it cannot carry color. A set plays as one source and ends after its last track.
Add <soundcloud-audio> and SoundCloudAudio, plus the CDN entry. The widget stays visible and takes clicks with or without controls, because it carries the uploader and SoundCloud attribution that SoundCloud's terms require.
The source picker covers the URL shapes the adapter reads differently, plus a missing track and a profile URL that fail on purpose.
The API terms ask for credit and links back from apps that use the API. They do not cover the widget. The widget stays visible because it is the part of the page that credits the uploader and SoundCloud. The docs now list the widget rules from the SoundCloud Terms of Use.
A start time such as #t=1%3A30 was ignored, because the URL hash keeps the colon encoded. The value is now decoded before it is read, as Media Fragments URIs ask.
With no source, or a source that failed to load, setting currentTime fired seeking and left seeking true, because no widget ever reported the seek. The time is now only stored, as on an audio element with no source.
When the wait for the duration ran out, the media reported the sound as private, removed, or blocked. A sound the widget cannot play already sends its own error, so a wait that runs out is a slow load. It now ends with MEDIA_ERR_NETWORK.
source.engine.soundcloud.referrerPolicy reached the iframe only as a prop of the React component. The HTML element never applied it. The media now sets it on the iframe before each widget load, and reloads a widget rendered without it.
A widget error after the sound loaded was kept as a fatal error. play() then did nothing until the source changed, while the skin still showed the widget playing the next track of a set. The error is now announced as non-fatal and not kept, and the media asks the widget if it paused.
…Data The player reads title and poster from contentData, but the media reported none. The media now reports the title and a 500px artwork of the track the widget plays. The data changes with each track of a set and clears across a source change.
The page said the large artwork layout needs 300 pixels but did not show how to set it. It now gives a height example for each framework.
The old privacy text said that the widget sets cookies when it loads. A clean browser shows no cookies, but the widget writes localStorage. The SoundCloud Privacy Policy is now the source for that text.
A media element without `controls` shows no native controls, so the SoundCloud widget is now hidden in that case and the skin drives playback, as with Spotify. A hidden widget still loads and plays. With `controls`, the widget shows as before. The docs tell a page that hides the widget to give the credit to the uploader and SoundCloud itself.
Short links were the only reason for a network call in the package. The redirect behind a short link has no CORS headers, so the adapter used SoundCloud's oEmbed endpoint, with a fetch, a module cache, an async load step, a network error path, and a connect-src note in the CSP guide. A full soundcloud.com URL plays directly, so short links now resolve to no adapter and report an unrecognized source.
Nothing in the package reads __DEV__, as in spotify-audio, which has no such file.
2fdd678 to
be3fa74
Compare
Closes #9310
Refs #9368
Summary
This adds a SoundCloud provider. You can now play SoundCloud tracks and sets with
<soundcloud-audio>in HTML andSoundCloudAudioin React. The new@videojs/soundcloud-audiopackage drives the SoundCloud Widget. The Video.js audio skin controls it like a native<audio>element.What it supports
soundcloud.comandm.soundcloud.com.on.soundcloud.com. The widget refuses them, so the media resolves them first through the SoundCloud oEmbed endpoint.api.soundcloud.comtracks and playlists. The id can be a number or a URN such assoundcloud:tracks:293.w.soundcloud.com/player/?url=...). Their widget parameters are kept.#t=90,#t=1:30or#t=1m30s.resolveAdapterTypereturnssoundcloudfor these URLs. It returnsnullfor profiles and other pages that list sounds.The media reports play, pause, seeking, volume, mute, duration, time, buffered ranges, ended and errors. A set plays as one source. When the widget moves to the next track, the duration changes and the time starts again from zero.
endedfires only after the last track. Clicks inside the widget show in the skin too.Widget parameters go under
source.engine.soundcloud. They are typed and documented, andcoloris one of them. Unknown parameters still pass through.The widget has no playback rate, picture in picture, fullscreen or text tracks. The media leaves those members out, so the skin hides those controls.
How it works
The adapter speaks the widget
postMessageprotocol directly, likeplayerjs-videodoes. It does not loadapi.js. Inapi.js,widget.load()turns every parameter exceptstart_trackintotrueorfalse. That breakscolor. Also, the widget never becomes ready whenapi.jsloads after the iframe.Each widget document reports
readywith an id that holds the time it started. The adapter only accepts a document that started after its last navigation. So a quick change of source never mixes two documents. When the iframe reloads by itself, for example after you move it in the page, the media starts over like a new load.Other fixes in this PR
Found but not fixed here
controls, it becomes a very large pill over the widget. The compat and scaffold skins use a centered card and look fine. This needs a design decision.EMPTY_TIME_RANGESbefore playback, and the buffer feature only listens when the media does not return it at attach. Wistia and SoundCloud return their own empty range instead. The same check also drives live detection, so this needs its own PR.Testing
resolveAdapterType, the adapter with a fake widget, the HTML element, the React component and the playback rate feature.pnpm test,pnpm lint,pnpm typecheckandpnpm -F site check:api-stabilitypass.