{"record":{"id":"9adfe149af735c91","repo":"remotion-dev/remotion","slug":"expected-player-event-emitter-context","errorCode":null,"errorMessage":"Expected Player event emitter context","messagePattern":"Expected Player event emitter context","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"packages/player/src/use-player-methods.ts","lineNumber":43,"sourceCode":"\tconst {\n\t\tsetPlaying,\n\t\tframeRef,\n\t\taudioAndVideoTags,\n\t\tisPlaying: readIsPlaying,\n\t\tisBuffering,\n\t} = useContext(Internals.SetTimelineContext);\n\tconst audioContext = useContext(Internals.SharedAudioContext);\n\tconst audioTagsContext = useContext(Internals.SharedAudioTagsContext);\n\tconst environment = useRemotionEnvironment();\n\tconst video = Internals.useVideo();\n\tconst config = Internals.useUnsafeVideoConfig();\n\tconst emitter = useContext(PlayerEventEmitterContext);\n\tconst playStart = useRef(0);\n\tconst fallbackFrame = useRef<number | null>(null);\n\tconst nextPlayIsAutoPlayAttempt = useRef(false);\n\n\tif (!emitter) {\n\t\tthrow new TypeError('Expected Player event emitter context');\n\t}\n\n\tconst getCurrentFrame = useCallback(() => {\n\t\tif (!video) {\n\t\t\treturn (\n\t\t\t\tfallbackFrame.current ??\n\t\t\t\t(typeof window === 'undefined'\n\t\t\t\t\t? 0\n\t\t\t\t\t: (window.remotion_initialFrame ?? 0))\n\t\t\t);\n\t\t}\n\n\t\tconst unclamped =\n\t\t\tframeRef.current[video.id] ??\n\t\t\t(environment.isPlayer\n\t\t\t\t? 0\n\t\t\t\t: Internals.Timeline.getFrameForComposition(video.id));\n","sourceCodeStart":25,"sourceCodeEnd":61,"githubUrl":"https://github.com/remotion-dev/remotion/blob/a6a7485a9aeb04219510fbe4874f8941486424df/packages/player/src/use-player-methods.ts#L25-L61","documentation":"usePlayerMethods retrieves the Player event emitter from PlayerEventEmitterContext; this context is only provided inside @remotion/player's <Player>. If the hook runs without a provider, emitter is undefined and a TypeError is thrown telling you the Player event emitter context is missing.","triggerScenarios":"Calling usePlayerMethods (or hooks building on it, like usePlayer) in a component rendered outside a <Player> from @remotion/player — e.g. inside a plain Remotion composition render, a Storybook story, or a test without the provider.","commonSituations":"Using player-only hooks (play/pause/seek) inside compositions rendered by the Remotion CLI/studio renderer instead of inside a <Player>; missing @remotion/player version alignment so the context object differs; rendering controls outside the Player tree.","solutions":["Render the component inside a <Player> from @remotion/player","Move play/pause/seek logic into components within the Player's React tree","Use useVideoPlayerContext only under Player; for studio/CLI rendering, gate player hooks behind an is-player check","Align @remotion/player and @remotion/core versions so context modules match"],"exampleFix":"// before\nconst controls = usePlayer(); // rendered outside <Player>\n// after\n<Player component={MyVideo} ...>\n  <PlayerControls/> {/* inside Player tree, context provided */}\n</Player>","handlingStrategy":"type-guard","validationCode":"// Only mount player-control components under <Player>\nif (!insidePlayerTree) return <StaticControls/>;","typeGuard":"const hasPlayerEmitter = (e: PlayerEventEmitter | undefined): e is PlayerEventEmitter =>\n  e !== undefined && typeof e.addEventListener === 'function';","tryCatchPattern":"try {\n  const controls = usePlayerMethods(video);\n} catch (e) {\n  if (e instanceof TypeError && e.message.includes('Player event emitter context')) {\n    // render non-player fallback controls\n  } else throw e;\n}","preventionTips":["Call usePlayerMethods/usePlayer only in components inside <Player>","Keep @remotion/player and @remotion/core versions aligned","Do not share player-control components between Player and studio/CLI renders without gating","Structure the tree so controls are children of Player"],"tags":["react","context","player","hooks"],"backgroundTag":"context-not-initialized","analyzedSha":"a6a7485a9aeb04219510fbe4874f8941486424df","analyzedAt":"2026-09-02T16:25:19.997Z","contentChangedAt":"2026-09-02T16:25:19.997Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}