fixed shared piano

This commit is contained in:
Jeff Emmett 2025-09-04 17:54:39 +02:00
parent 356a262114
commit 8fa8c388d9
4 changed files with 29 additions and 15 deletions

View File

@ -5,6 +5,7 @@
<title>Jeff Emmett</title> <title>Jeff Emmett</title>
<meta charset="UTF-8" /> <meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<meta http-equiv="Permissions-Policy" content="midi=*, microphone=*, camera=*, autoplay=*">
<link rel="preconnect" href="https://fonts.googleapis.com" /> <link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin /> <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link <link

View File

@ -53,7 +53,7 @@ export class SharedPianoShape extends BaseBoxShapeUtil<ISharedPianoShape> {
const handleIframeError = useCallback(() => { const handleIframeError = useCallback(() => {
setIsLoading(false) setIsLoading(false)
setError("Failed to load Shared Piano") setError("Failed to load Shared Piano. Please check your browser permissions for MIDI and audio access.")
}, []) }, [])
const handleToggleMinimize = (e: React.MouseEvent) => { const handleToggleMinimize = (e: React.MouseEvent) => {
@ -74,9 +74,10 @@ export class SharedPianoShape extends BaseBoxShapeUtil<ISharedPianoShape> {
position: "absolute", position: "absolute",
top: 8, top: 8,
right: 8, right: 8,
zIndex: 1000, zIndex: 10,
display: "flex", display: "flex",
gap: 4, gap: 4,
pointerEvents: "auto",
}} }}
> >
<button <button
@ -108,6 +109,8 @@ export class SharedPianoShape extends BaseBoxShapeUtil<ISharedPianoShape> {
borderRadius: "8px", borderRadius: "8px",
border: "1px solid var(--color-panel)", border: "1px solid var(--color-panel)",
backgroundColor: "var(--color-background)", backgroundColor: "var(--color-background)",
zIndex: 1,
pointerEvents: "auto",
}} }}
> >
{controls} {controls}
@ -129,7 +132,7 @@ export class SharedPianoShape extends BaseBoxShapeUtil<ISharedPianoShape> {
🎹 Shared Piano 🎹 Shared Piano
</div> </div>
) : ( ) : (
<> <div style={{ position: "relative", width: "100%", height: "100%", zIndex: 1 }}>
{isLoading && ( {isLoading && (
<div <div
style={{ style={{
@ -142,7 +145,8 @@ export class SharedPianoShape extends BaseBoxShapeUtil<ISharedPianoShape> {
alignItems: "center", alignItems: "center",
justifyContent: "center", justifyContent: "center",
background: "var(--color-background)", background: "var(--color-background)",
zIndex: 1, zIndex: 3,
pointerEvents: "auto",
}} }}
> >
<div style={{ textAlign: "center" }}> <div style={{ textAlign: "center" }}>
@ -164,7 +168,8 @@ export class SharedPianoShape extends BaseBoxShapeUtil<ISharedPianoShape> {
alignItems: "center", alignItems: "center",
justifyContent: "center", justifyContent: "center",
background: "var(--color-background)", background: "var(--color-background)",
zIndex: 1, zIndex: 3,
pointerEvents: "auto",
}} }}
> >
<div style={{ textAlign: "center", color: "var(--color-text)" }}> <div style={{ textAlign: "center", color: "var(--color-text)" }}>
@ -206,14 +211,19 @@ export class SharedPianoShape extends BaseBoxShapeUtil<ISharedPianoShape> {
borderRadius: "8px", borderRadius: "8px",
opacity: isLoading ? 0 : 1, opacity: isLoading ? 0 : 1,
transition: "opacity 0.3s ease", transition: "opacity 0.3s ease",
position: "absolute",
top: 0,
left: 0,
zIndex: 2,
pointerEvents: "auto",
}} }}
onLoad={handleIframeLoad} onLoad={handleIframeLoad}
onError={handleIframeError} onError={handleIframeError}
title="Chrome Music Lab Shared Piano" title="Chrome Music Lab Shared Piano"
allow="microphone; camera" allow="microphone; camera; midi; autoplay; encrypted-media; fullscreen"
sandbox="allow-scripts allow-same-origin allow-forms allow-popups allow-popups-to-escape-sandbox" sandbox="allow-scripts allow-same-origin allow-forms allow-popups allow-popups-to-escape-sandbox allow-modals"
/> />
</> </div>
)} )}
</div> </div>
) )

View File

@ -395,7 +395,7 @@ export class VideoChatShape extends BaseBoxShapeUtil<IVideoChatShape> {
console.log('📝 addTranscriptionMessage called'); console.log('📝 addTranscriptionMessage called');
console.log('Sender:', sender); console.log('Sender:', sender);
console.log('Message:', message); console.log('Message:', message);
console.log('Current transcription history length:', shape.props.transcriptionHistory.length); console.log('Current transcription history length:', shape.props.transcriptionHistory?.length || 0);
const newMessage = { const newMessage = {
sender, sender,
@ -410,7 +410,7 @@ export class VideoChatShape extends BaseBoxShapeUtil<IVideoChatShape> {
type: shape.type, type: shape.type,
props: { props: {
...shape.props, ...shape.props,
transcriptionHistory: [...shape.props.transcriptionHistory, newMessage] transcriptionHistory: [...(shape.props.transcriptionHistory || []), newMessage]
} }
}); });
@ -645,7 +645,7 @@ export class VideoChatShape extends BaseBoxShapeUtil<IVideoChatShape> {
)} )}
{/* Transcription History */} {/* Transcription History */}
{shape.props.transcriptionHistory.length > 0 && ( {shape.props.transcriptionHistory && shape.props.transcriptionHistory.length > 0 && (
<div <div
style={{ style={{
position: "absolute", position: "absolute",

View File

@ -5,7 +5,10 @@ export type ISharedPianoShape = TLBaseShape<
{ {
w: number w: number
h: number h: number
isPlaying: boolean isMinimized?: boolean
interactionState?: {
scrollPosition?: { x: number; y: number }
}
} }
> >
@ -14,9 +17,9 @@ export class SharedPianoShape extends BaseBoxShapeUtil<ISharedPianoShape> {
getDefaultProps(): ISharedPianoShape["props"] { getDefaultProps(): ISharedPianoShape["props"] {
return { return {
w: 400, w: 800,
h: 200, h: 600,
isPlaying: false, isMinimized: false,
} }
} }