Plays a link's preview in the global player, as the provider's embed or as a queue of Bandcamp streams. RichContentCard and JournalCard call it when their thumbnail is clicked.
Checks whether rc can be played, for the cards to offer a play button. In
native mode a Bandcamp page plays even without an embed, since its streams
are resolved from the page itself.
Returns a function that plays a link's preview in its provider's embed. When
the deployment sets GERBEUR_BANDCAMP_PLAYER=native, a Bandcamp page is
resolved into its mp3 streams instead and played as a queue, which autoplays
and plays an album through. If that fails (offline, a preorder, Bandcamp
changing its markup), the embed plays, and a page without one (an artist's
root, a /music index) plays nothing.
Passed to playRichContent and canPlayRichContent by RichContentCard
and JournalCard. It is a dump's RichContent, its thumbnail replaced by the
dump's own when it has one.
- embedUrl: string
-
siteName: string
Shown under the title in the player's header.
-
thumbnailUrl: string
Shown in the player's header, unless Bandcamp has album art of its own.
- title: string
-
type: string
The provider, as in
RichContent.type. -
url: string
The page, which native Bandcamp playback resolves.
Returned by usePlayRichContent to the cards that play a link.
-
pending: boolean
True while a Bandcamp page is being resolved.
-
playRichContent: () => Promise<boolean>rc: PlayableRichContent,dumpHref?: string
Plays
rc, its title in the player linking to the dump pagedumpHref. Resolves to false when nothing could play, so the caller can open the link instead.
Usage
import * as mod from "src/hooks/player/usePlayRichContent.ts";