class CameraGlassesApp extends AppServer {
protected async onSession(session: AppSession, sessionId: string, userId: string) {
const caps = session.capabilities;
if (!caps?.hasCamera) {
await session.audio.speak('Camera not available');
return;
}
// Audio welcome
await session.audio.speak('Camera app ready');
// Button to capture
session.events.onButtonPress(async (data) => {
if (data.button === 'select') {
await this.capturePhoto(session);
}
});
// Voice commands
session.events.onTranscription(async (data) => {
if (!data.isFinal) return;
const text = data.text.toLowerCase();
if (text.includes('photo')) {
await this.capturePhoto(session);
} else if (text.includes('stream')) {
await this.startStreaming(session);
}
});
}
private async capturePhoto(session: AppSession) {
await session.audio.speak('Capturing');
// LED feedback
if (session.capabilities?.hasLight) {
await session.led.blink({
color: 'white',
ontime: 100,
offtime: 100,
count: 2
});
}
const photo = await session.camera.requestPhoto({
saveToGallery: true
});
await session.audio.speak('Photo saved');
}
private async startStreaming(session: AppSession) {
await session.audio.speak('Starting stream');
await session.camera.startManagedStream({
video: {
resolution: '1280x720',
framerate: 30
}
});
await session.audio.speak('Streaming');
}
}