hammerspoon2-docs
    Preparing search index...

    Class HSVideo

    Bridge type for working with video playback in JavaScript HSVideo wraps an AVQueuePlayer and can be embedded in an hs.ui.window via .video(), or driven entirely from JavaScript with play(), pause(), seek(), loop(), and volume.

    Each entry may be a local file path (~ is expanded) or a remote URL string. Multiple entries are queued and play back to back, in order.

    // A single local file
    const clip = HSVideo.fromURLs(["~/Movies/clip.mp4"])

    // A playlist mixing a local file and a remote stream
    const playlist = HSVideo.fromURLs(["~/Movies/intro.mp4", "https://example.com/video.mp4"])
    const clip = HSVideo.fromURLs(["~/Movies/clip.mp4"])
    clip.volume = 0.5
    clip.loop(true)
    clip.play()
    // ... later ...
    clip.seek(30)
    clip.pause()

    Gapless looping (via AVPlayerLooper) is only supported when the playlist contains a single URL. Calling loop(true) on a multi-URL playlist has no effect (the playlist just plays through once) and logs a warning.

    Index

    Constructors

    Properties

    Methods

    Constructors

    Properties

    volume: number

    The playback volume, from 0.0 (silent) to 1.0 (full volume)

    Methods

    • Enable or disable gapless looping Only supported when this HSVideo was created from a single-URL playlist. Enabling loop on a multi-URL playlist has no effect and logs a warning.

      Parameters

      • enabled: boolean

        Pass true to loop playback indefinitely

      Returns HSVideo

      Self for chaining

    • Start (or resume) playback

      Returns HSVideo

      Self for chaining

    • Seek to a specific position

      Parameters

      • seconds: number

        The position to seek to, in seconds

      Returns HSVideo

      Self for chaining

    • Load a playlist of videos to play back to back, in order

      Parameters

      • urls: string[]

        Each entry is a local file path (~ is expanded) or a remote URL string

      Returns HSVideo | null

      An HSVideo object, or null if the list is empty or an entry couldn't be resolved