@micrio/client 5.4.17 → 5.4.18

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/micrio.min.d.ts CHANGED
@@ -4,7 +4,7 @@ declare module '@micrio/client' {
4
4
  * Defines the current version of the Micrio library.
5
5
  * This constant is used internally and exposed statically via `HTMLMicrioElement.VERSION`.
6
6
  */
7
- export const VERSION = "5.4.17";
7
+ export const VERSION = "5.4.18";
8
8
  /**
9
9
  * Loads an image texture asynchronously. Adds the request to the queue
10
10
  * and returns a Promise that resolves with the TextureBitmap or rejects on error.
@@ -34,6 +34,55 @@ declare module '@micrio/client' {
34
34
  Vimeo = 2
35
35
  }
36
36
  export { isLegacyViews };
37
+ /**
38
+ * Media utilities for source parsing, type detection, and player management.
39
+ * @author Marcel Duin <marcel@micr.io>
40
+ */
41
+ /** YouTube no-cookies host */
42
+ export const YOUTUBE_HOST = "https://www.youtube-nocookie.com";
43
+ /**
44
+ * Parsed media source information.
45
+ */
46
+ export interface ParsedMediaSource {
47
+ /** The detected media type */
48
+ type: MediaType;
49
+ /** The frame type for iframe embeds (YouTube/Vimeo) */
50
+ frameType?: FrameType;
51
+ /** The normalized/processed source URL */
52
+ src?: string;
53
+ /** Original source URL */
54
+ originalSrc?: string;
55
+ /** YouTube video ID (if applicable) */
56
+ youtubeId?: string;
57
+ /** Vimeo video ID (if applicable) */
58
+ vimeoId?: string;
59
+ /** Vimeo hash token (if applicable) */
60
+ vimeoToken?: string;
61
+ /** Cloudflare video ID (if applicable) */
62
+ cloudflareId?: string;
63
+ /** Micrio embed data [id, width?, height?, lang?] */
64
+ micrioEmbed?: string[];
65
+ /** Start time extracted from URL (seconds) */
66
+ startTime?: number;
67
+ /** Whether the source is a Cloudflare stream */
68
+ isCloudflare: boolean;
69
+ /** M3U8 URL for HLS streams */
70
+ hlsSrc?: string;
71
+ }
72
+ /**
73
+ * Parses a media source URL and determines its type and configuration.
74
+ */
75
+ export function parseMediaSource(src: string | undefined, tour: Models.ImageData.VideoTour | null, useNativeFrames?: boolean, currentTime?: number): ParsedMediaSource;
76
+ /**
77
+ * Checks if the browser natively supports HLS playback.
78
+ */
79
+ export function hasNativeHLS(el?: HTMLMediaElement): boolean;
80
+ /**
81
+ * Returns a shared Audio element instance for iOS.
82
+ * This is a workaround for iOS audio playback restrictions where user
83
+ * interaction is required per audio element.
84
+ */
85
+ export function getIOSAudioElement(): HTMLAudioElement;
37
86
  /**
38
87
  * Global utility functions used throughout the Micrio application.
39
88
  * Re-exports all utility modules for convenient importing.
@@ -52,7 +101,8 @@ declare module '@micrio/client' {
52
101
  export { loadSerialTour } from "ts/utils/tour";
53
102
  export { getIdVal, idIsV5 } from "ts/utils/id";
54
103
  export { getSpaceVector } from "ts/utils/space";
55
- export { hasNativeHLS } from "ts/utils/media";
104
+ export { hasNativeHLS, parseMediaSource, getIOSAudioElement, YOUTUBE_HOST } from "ts/utils/media";
105
+ export type { ParsedMediaSource } from "ts/utils/media";
56
106
  /**
57
107
  * Global utility functions used throughout the Micrio application.
58
108
  * This file re-exports all utilities from the modular utils/ directory.
@@ -2952,6 +3002,176 @@ declare module '@micrio/client' {
2952
3002
  /** Cleans up resources when the parent Embed component is unmounted. */
2953
3003
  unmount(): void;
2954
3004
  }
3005
+ /**
3006
+ * Media player type definitions and interfaces.
3007
+ * @author Marcel Duin <marcel@micr.io>
3008
+ */
3009
+ /**
3010
+ * Common interface for all media player adapters.
3011
+ * Abstracts the differences between HTML5, YouTube, Vimeo, and HLS players.
3012
+ */
3013
+ export interface MediaPlayerAdapter {
3014
+ /** Play the media */
3015
+ play(): Promise<void>;
3016
+ /** Pause the media */
3017
+ pause(): void;
3018
+ /** Get current playback time in seconds */
3019
+ getCurrentTime(): Promise<number>;
3020
+ /** Set current playback time in seconds */
3021
+ setCurrentTime(time: number): void;
3022
+ /** Get total duration in seconds */
3023
+ getDuration(): Promise<number>;
3024
+ /** Check if media is currently paused */
3025
+ isPaused(): Promise<boolean>;
3026
+ /** Set muted state */
3027
+ setMuted(muted: boolean): void;
3028
+ /** Set volume (0-1) */
3029
+ setVolume(volume: number): void;
3030
+ /** Clean up resources */
3031
+ destroy(): void;
3032
+ /** Whether this adapter requires manual time updates via interval */
3033
+ readonly requiresTimeTick: boolean;
3034
+ }
3035
+ /**
3036
+ * Event callbacks for player state changes.
3037
+ */
3038
+ export interface PlayerEventCallbacks {
3039
+ onPlay?: () => void;
3040
+ onPause?: () => void;
3041
+ onEnded?: () => void;
3042
+ onSeeking?: () => void;
3043
+ onSeeked?: () => void;
3044
+ onTimeUpdate?: (time: number) => void;
3045
+ onDurationChange?: (duration: number) => void;
3046
+ onError?: (error: Error) => void;
3047
+ onBuffering?: () => void;
3048
+ onReady?: () => void;
3049
+ onBlocked?: () => void;
3050
+ }
3051
+ /**
3052
+ * Configuration for creating a player adapter.
3053
+ */
3054
+ export interface PlayerConfig {
3055
+ width: number;
3056
+ height: number;
3057
+ autoplay?: boolean;
3058
+ loop?: boolean;
3059
+ muted?: boolean;
3060
+ volume?: number;
3061
+ startTime?: number;
3062
+ }
3063
+ /**
3064
+ * HTML5 Media Element adapter.
3065
+ * Wraps native <audio> and <video> elements with a common interface.
3066
+ * @author Marcel Duin <marcel@micr.io>
3067
+ */
3068
+ /**
3069
+ * Adapter for native HTML5 audio/video elements.
3070
+ */
3071
+ export class HTML5PlayerAdapter implements MediaPlayerAdapter {
3072
+ private element;
3073
+ private callbacks;
3074
+ readonly requiresTimeTick = false;
3075
+ constructor(element: HTMLMediaElement, callbacks?: PlayerEventCallbacks);
3076
+ private attachEventListeners;
3077
+ play(): Promise<void>;
3078
+ pause(): void;
3079
+ getCurrentTime(): Promise<number>;
3080
+ setCurrentTime(time: number): void;
3081
+ getDuration(): Promise<number>;
3082
+ isPaused(): Promise<boolean>;
3083
+ setMuted(muted: boolean): void;
3084
+ setVolume(volume: number): void;
3085
+ destroy(): void;
3086
+ }
3087
+ /**
3088
+ * Adapter for HLS.js streaming video.
3089
+ * Extends HTML5PlayerAdapter since HLS.js attaches to a video element.
3090
+ */
3091
+ export class HLSPlayerAdapter implements MediaPlayerAdapter {
3092
+ private element;
3093
+ private hlsSrc;
3094
+ private callbacks;
3095
+ readonly requiresTimeTick = false;
3096
+ private hls;
3097
+ private html5Adapter;
3098
+ private destroyed;
3099
+ constructor(element: HTMLVideoElement, hlsSrc: string, callbacks?: PlayerEventCallbacks);
3100
+ /**
3101
+ * Loads HLS.js and attaches to the video element.
3102
+ */
3103
+ initialize(): Promise<void>;
3104
+ play(): Promise<void>;
3105
+ pause(): void;
3106
+ getCurrentTime(): Promise<number>;
3107
+ setCurrentTime(time: number): void;
3108
+ getDuration(): Promise<number>;
3109
+ isPaused(): Promise<boolean>;
3110
+ setMuted(muted: boolean): void;
3111
+ setVolume(volume: number): void;
3112
+ destroy(): void;
3113
+ }
3114
+ /**
3115
+ * Adapter for YouTube IFrame Player API.
3116
+ */
3117
+ export class YouTubePlayerAdapter implements MediaPlayerAdapter {
3118
+ private frame;
3119
+ private config;
3120
+ private callbacks;
3121
+ readonly requiresTimeTick = true;
3122
+ private player;
3123
+ private destroyed;
3124
+ constructor(frame: HTMLIFrameElement, config: PlayerConfig, callbacks?: PlayerEventCallbacks);
3125
+ /**
3126
+ * Loads the YouTube API and initializes the player.
3127
+ */
3128
+ initialize(): Promise<void>;
3129
+ private handleStateChange;
3130
+ play(): Promise<void>;
3131
+ pause(): void;
3132
+ getCurrentTime(): Promise<number>;
3133
+ setCurrentTime(time: number): void;
3134
+ getDuration(): Promise<number>;
3135
+ isPaused(): Promise<boolean>;
3136
+ setMuted(muted: boolean): void;
3137
+ setVolume(_volume: number): void;
3138
+ destroy(): void;
3139
+ }
3140
+ /**
3141
+ * Adapter for Vimeo Player API.
3142
+ */
3143
+ export class VimeoPlayerAdapter implements MediaPlayerAdapter {
3144
+ private frame;
3145
+ private config;
3146
+ private callbacks;
3147
+ readonly requiresTimeTick = false;
3148
+ private player;
3149
+ private destroyed;
3150
+ constructor(frame: HTMLIFrameElement, config: PlayerConfig, callbacks?: PlayerEventCallbacks);
3151
+ /**
3152
+ * Loads the Vimeo API and initializes the player.
3153
+ */
3154
+ initialize(): Promise<void>;
3155
+ play(): Promise<void>;
3156
+ pause(): void;
3157
+ getCurrentTime(): Promise<number>;
3158
+ setCurrentTime(time: number): void;
3159
+ getDuration(): Promise<number>;
3160
+ isPaused(): Promise<boolean>;
3161
+ setMuted(muted: boolean): void;
3162
+ setVolume(volume: number): void;
3163
+ destroy(): void;
3164
+ }
3165
+ /**
3166
+ * Media player adapters module.
3167
+ * Provides unified interfaces for different media player types.
3168
+ * @author Marcel Duin <marcel@micr.io>
3169
+ */
3170
+ export type { MediaPlayerAdapter, PlayerEventCallbacks, PlayerConfig } from "ts/media/types";
3171
+ export { HTML5PlayerAdapter } from "ts/media/html5-adapter";
3172
+ export { YouTubePlayerAdapter } from "ts/media/youtube-adapter";
3173
+ export { VimeoPlayerAdapter } from "ts/media/vimeo-adapter";
3174
+ export { HLSPlayerAdapter } from "ts/media/hls-adapter";
2955
3175
  }declare module "svelte/store" {
2956
3176
  /** Callback to inform of a value updates.
2957
3177
  */