import { Component , h , Method , Prop } from '@stencil/core' ; import { isString } from '../../../utils/unit' ; import { ViewType } from '../../core/player/ViewType' ; import { withComponentRegistry } from '../../core/player/withComponentRegistry' ; import { MediaCrossOriginOption , MediaFileProvider , MediaPreloadOption , } from '../file/MediaFileProvider' ; import { audioRegex } from '../file/utils' ; import { withProviderConnect } from '../ProviderConnect' ; slot @ Component ( { tag : 'vm-audio' , } ) export class Audio implements MediaFileProvider < HTMLMediaElement > { private fileProvider ! : HTMLVmFileElement ; internal @ Prop ( ) willAttach = false ; inheritdoc @ Prop ( ) crossOrigin ? : MediaCrossOriginOption ; inheritdoc @ Prop ( ) preload ? : MediaPreloadOption = 'metadata' ; inheritdoc @ Prop ( ) disableRemotePlayback ? : boolean ; /**
     * The title of the current media.
     */ @ Prop ( ) mediaTitle ? : string ; constructor ( ) { withComponentRegistry ( this ) ; if ( ! this . willAttach ) withProviderConnect ( this ) ; } internal @ Method ( ) async getAdapter ( ) { const adapter = ( await this . fileProvider ?. getAdapter ( ) ) ?? { } ; adapter . canPlay = async ( type ) => isString ( type ) && audioRegex . test ( type ) ; return adapter ; } render ( ) { return ( < vm - file noConnect willAttach = { this . willAttach } crossOrigin = { this . crossOrigin } preload = { this . preload } disableRemotePlayback = { this . disableRemotePlayback } mediaTitle = { this . mediaTitle } viewType = { ViewType . Audio } ref = { ( el ) => { this . fileProvider = el ; } } > < slot /> < /vm-file>); } }