@vocalstack/player 0.1.0-alpha.0 → 0.1.0-alpha.10

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/README.md CHANGED
@@ -21,14 +21,57 @@ export function Video() {
21
21
 
22
22
  | Prop | Default | |
23
23
  |---|---|---|
24
- | `id` | required | A share code. Or, with `token`, a transcription id. |
25
- | `token` | none | A browser token (or a function returning one) for a private transcription. Never pass an API key to a browser. |
24
+ | `id` | | A share code. Or, with `token`, a transcription id. With neither `id` nor `src`, the player opens on a box where the visitor pastes any video link and transcribes it in their own VocalStack account. |
25
+ | `src` | | A video or audio link (YouTube, Vimeo, an mp3 or any media URL) instead of `id`. If the visitor has already transcribed it with VocalStack, it plays. If not, they are asked whether to start transcribing it. With `token`, the link is looked up in that account instead. |
26
+ | `token` | | A browser token (or a function returning one) for a private transcription. Never pass an API key to a browser. |
26
27
  | `mode` | `'video'` | `'video'` for the full player, `'transcript'` for the reading view with a player. |
27
- | `layout` | `'embed'` | `'embed'` sizes to its container (16:9 for video); `'page'` fills the page. |
28
- | `initial` | none | `{ lang, cc, translateAudio, clonedVoices, removeBackground, labels, words, startAt }` |
28
+ | `layout` | `'embed'` | `'embed'` sizes to its container (16:9 for video). `'page'` fills the page. |
29
+ | `settings` | | Settings you control. Changing a value updates the player. See below. |
30
+ | `initial` | | The same settings, applied once at the start. The viewer can change them afterwards. |
31
+ | `onSettingsChange` | | Called with all the settings whenever the viewer changes one. |
32
+ | `controls` | all on | `{ language, subtitles, audio, export, share, fullscreen, settings }`. Pass `false` to hide one. |
33
+ | `autoplay` | `true` | Starts muted where the browser requires it. |
34
+ | `startAt` | | Start time in seconds. |
29
35
  | `endCard` | on | At the end of a video, offers to transcribe another link in the visitor's own VocalStack account. Pass `false` to turn it off. |
30
36
  | `baseUrl` | `https://api.vocalstack.com` | |
31
- | `onSource`, `onProgress`, `onError` | none | Callbacks for the loaded transcription, the transcription progress (0-100, `null` when done), and errors. |
37
+ | `onSource`, `onProgress`, `onError` | | Called with the loaded transcription, the transcription progress (0-100, `null` when done), and errors. |
38
+ | `onPlayback` | | Called about ten times a second while anything changes, with `{ t, dur, playing, idx, seekN, lang }`: the time in seconds, the length, whether it plays, the index of the current line, a counter that grows on every seek, and the language shown. |
39
+ | `ref` | | A `PlayerHandle`: `seek(t)`, `play()`, `pause()`, `toggle()`. |
40
+ | `compact` | `false` | Small controls at any width, and no title, summary or share card when paused. For a player inside a side column or card. |
41
+ | `poster` | | An image shown behind the player before a video is chosen or before the visitor connects. |
42
+
43
+ ### Settings
44
+
45
+ ```ts
46
+ {
47
+ lang?: string | null; // translate into this language code; null = as spoken
48
+ subtitles?: boolean; // captions over the video
49
+ speakerLabels?: boolean; // who is speaking, before each line
50
+ wordHighlight?: boolean; // follow each word as it is spoken
51
+ translateAudio?: boolean; // hear the translation read aloud
52
+ voices?: 'cloned' | 'synthetic';
53
+ removeBackground?: boolean; // play only the speech
54
+ }
55
+ ```
56
+
57
+ ```tsx
58
+ <VocalStackPlayer
59
+ id="r4m4srrrhi24"
60
+ settings={{ lang: 'es', speakerLabels: true, voices: 'cloned' }}
61
+ controls={{ export: false, share: false }}
62
+ onSettingsChange={(s) => console.log(s)}
63
+ />
64
+
65
+ <VocalStackPlayer src="https://www.youtube.com/watch?v=QWCLiPOgeuw" />
66
+ ```
67
+
68
+ Follow and drive it from your page:
69
+
70
+ ```tsx
71
+ const player = useRef<PlayerHandle>(null);
72
+ <VocalStackPlayer ref={player} id="r4m4srrrhi24" onPlayback={(s) => setAt(s.t)} />
73
+ <button onClick={() => player.current?.seek(42)}>Jump to 0:42</button>
74
+ ```
32
75
 
33
76
  Theme it by overriding the CSS variables on `.vsp`, for example `--vsp-radius`, `--brand` and `--vs-font-sans`.
34
77
 
@@ -27,6 +27,7 @@ export declare const FOLLOW_DRIFT_S = 0.5;
27
27
  export declare const FOLLOW_AHEAD = 3;
28
28
  export declare function lineAt(lines: readonly FollowLine[], t: number): number;
29
29
  export declare function followTarget(lines: readonly FollowLine[], clips: ReadonlyMap<number, readonly FollowClip[]>, t: number): FollowTarget;
30
+ export declare function mayRunOn(lines: readonly FollowLine[], t: number, playingSid: number | null): boolean;
30
31
  export declare function upcomingSrcs(lines: readonly FollowLine[], clips: ReadonlyMap<number, readonly FollowClip[]>, t: number, n?: number): string[];
31
32
  export interface FollowState {
32
33
  missing: number | null;
@@ -5,10 +5,13 @@ export interface Started {
5
5
  token: string;
6
6
  expiresAt: string | null;
7
7
  }
8
- export type PopupStatus = 'signing-in' | 'consent' | 'checking' | 'starting';
8
+ export type PopupStatus = 'signing-in' | 'consent' | 'looking' | 'confirm' | 'checking' | 'starting';
9
9
  export declare function openPopup(appUrl: string | undefined, ask: {
10
10
  url?: string;
11
11
  transcription?: string;
12
- }, onStatus?: (s: PopupStatus) => void): Promise<Started | null>;
12
+ ask?: boolean;
13
+ connect?: boolean;
14
+ }, onStatus?: (s: PopupStatus) => void): Promise<Started | 'connected' | null>;
13
15
  export declare function startFromEmbed(appUrl: string | undefined, url: string, onStatus?: (s: PopupStatus) => void): Promise<Started | null>;
14
- export declare function refreshToken(appUrl: string | undefined, transcriptionId: string): Promise<Started | null>;
16
+ export declare function wasConnected(appUrl: string | undefined): boolean;
17
+ export declare function rememberConnected(appUrl: string | undefined): void;
@@ -26,10 +26,14 @@ export interface PlayerSource {
26
26
  sharedBy: string | null;
27
27
  }
28
28
  export declare function usePlayerApi(): PlayerApi;
29
- export declare function PlayerApiProvider({ value, children }: {
30
- value: PlayerApi;
29
+ export type PlayerApiProviderProps = {
31
30
  children: ReactNode;
32
- }): import("react").JSX.Element;
31
+ } & ({
32
+ value: PlayerApi;
33
+ } | (Partial<ApiOptions> & {
34
+ value?: undefined;
35
+ }));
36
+ export declare function PlayerApiProvider(props: PlayerApiProviderProps): import("react").JSX.Element;
33
37
  export declare function isTranscriptionId(id: string): boolean;
34
38
  export type TokenSource = string | (() => string | undefined | null | Promise<string | undefined | null>);
35
39
  export interface Listen {
@@ -38,10 +42,12 @@ export interface Listen {
38
42
  token: string;
39
43
  }
40
44
  export interface ApiOptions {
41
- id: string;
45
+ id?: string | null;
42
46
  token?: TokenSource | null;
43
47
  baseUrl?: string | null;
44
48
  listen?: Listen | null;
49
+ listenerToken?: string | null;
50
+ client?: VocalStack | null;
45
51
  }
46
52
  export declare function useApi(o: ApiOptions): PlayerApi;
47
53
  export declare function withMedia(api: PlayerApi, media: string | null): PlayerApi;
@@ -0,0 +1,4 @@
1
+ import { type TokenSource } from './context';
2
+ export declare function useLookup(src: string | null, token: TokenSource | null, baseUrl: string | null): {
3
+ id: string;
4
+ } | null | undefined;
package/dist/index.d.ts CHANGED
@@ -1,6 +1,12 @@
1
1
  import './styles.css';
2
- export { VocalStackPlayer, type VocalStackPlayerProps, type PlayerSettings } from './ui/VocalStackPlayer';
2
+ export { VocalStackPlayer, type VocalStackPlayerProps, type PlayerSettings, type PlayerControls, type PlayerHandle, type PlaybackState } from './ui/VocalStackPlayer';
3
3
  export type { EndCardOptions } from './ui/EndCard';
4
- export type { PlayerSource, TokenSource } from './data/context';
4
+ export { PlayerApiProvider, usePlayerApi, useApi, type PlayerApi, type PlayerApiProviderProps, type ApiOptions, type PlayerSource, type TokenSource, type Listen } from './data/context';
5
5
  export type { ErrorLike } from './data/errors';
6
- export { setErrorReporter } from './core/audio';
6
+ export { setErrorReporter, type MediaCred } from './core/audio';
7
+ export { useTranscript } from './data/transcript';
8
+ export { useTxPlayer, useTxVoice, useDuck, useFlash, useYtLead, useFindPull, YtFollow, MuteButton, TxLines, TxFind, lineWords, spokenWordOf, pictureT, lineEnd, PAUSE_D, PLAY_D, NO_SEEK, PUB_SIDE, type TxPlayer, type YtLead, type VoiceSheetHooks, type VoiceSheetCtx, type NoCloneNote } from './ui/core';
9
+ export { Transport, ReplayScrub, ExportPanel, SummaryPanel, SpeakerCast, VoiceSheetBody, useSummaryIn, useViewportTranslation, useArchiveVoice, useVoiceCatalogue, type AvailableVoice, type CastMember, type SummaryState } from './ui/shared';
10
+ export { FullVideo, MiniPlayer, PanelSeek, browserFull, realFull, setFullTarget, type PlayerPos, type PlayerTransport, type VoicesBtn } from './ui/full';
11
+ export { useBackgroundBed, useSeparatedTrack, bedNote, trackPlan, REMOVE_BG_LABEL, REMOVE_BG_NOTE, type BedState, type TrackPlan, type Separated } from './core/background';
12
+ export { snapPosition, placePosition, type PlayPos } from './core/playPosition';