Documentation
    Preparing search index...

    Function createMediaService

    • Create a media NAP service handler with navigator.mediaSession integration.

      Implements the 5 napplet->shell media.* request types defined in @napplet/nap/media. Only media.session.create produces a reply envelope (media.session.create.result) — the remaining four (session.update, session.destroy, state, capabilities) are fire-and-forget per the NAP spec.

      Unknown media.* actions produce a <type>.error envelope so napplets are never left hanging on a malformed request.

      Parameters

      • options: MediaServiceOptions = {}

        Optional host callbacks for session lifecycle + state, plus mediaSessionTarget and documentTarget for test injection, and an optional hostBridge for native-OS media backend delegation.

      Returns ServiceHandler & { destroy(): void }

      A ServiceHandler (with destroy()) to register with the runtime

      import { createMediaService } from '@kehto/services';

      const media = createMediaService();
      runtime.registerService('media', media);
      // Later, on shell teardown:
      media.destroy();