Options
All
  • Public
  • Public/Protected
  • All
Menu

Class AppleTV

Hierarchy

  • EventEmitter
    • AppleTV

Index

Constructors

constructor

  • new AppleTV(service: Service, socket?: Socket): AppleTV

Properties

address

address: string

connection

connection: Connection

credentials

credentials: Credentials

name

name: string

pairingId

pairingId: string = uuid()

port

port: number

uid

uid: string

Static defaultMaxListeners

defaultMaxListeners: number

Methods

addListener

  • addListener(event: string | symbol, listener: (...args: any[]) => void): this
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

closeConnection

  • closeConnection(): void

emit

  • emit(event: string | symbol, ...args: any[]): boolean
  • Parameters

    • event: string | symbol
    • Rest ...args: any[]

    Returns boolean

eventNames

  • eventNames(): Array<string | symbol>
  • Returns Array<string | symbol>

getMaxListeners

  • getMaxListeners(): number

listenerCount

  • listenerCount(type: string | symbol): number
  • Parameters

    • type: string | symbol

    Returns number

listeners

  • listeners(event: string | symbol): Function[]
  • Parameters

    • event: string | symbol

    Returns Function[]

messageOfType

  • messageOfType(type: Type, timeout?: number): Promise<Message>
  • Wait for a single message of a specified type.

    Parameters

    • type: Type

      The type of the message to wait for.

    • Default value timeout: number = 5

      The timeout (in seconds).

    Returns Promise<Message>

    A promise that resolves to the Message.

off

  • off(event: string | symbol, listener: (...args: any[]) => void): this
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

on

  • on(event: string | symbol, listener: (...args: any[]) => void): this
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

once

  • once(event: string | symbol, listener: (...args: any[]) => void): this
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

openConnection

  • Opens a connection to the AppleTV over the MRP protocol.

    Parameters

    • Optional credentials: Credentials

      The credentials object for this AppleTV

    Returns Promise<AppleTV>

    A promise that resolves to the AppleTV object.

pair

  • pair(): Promise<(pin: string) => Promise<AppleTV>>
  • Pair with an already discovered AppleTV.

    Returns Promise<(pin: string) => Promise<AppleTV>>

    A promise that resolves to the AppleTV object.

prependListener

  • prependListener(event: string | symbol, listener: (...args: any[]) => void): this
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

prependOnceListener

  • prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

rawListeners

  • rawListeners(event: string | symbol): Function[]
  • Parameters

    • event: string | symbol

    Returns Function[]

removeAllListeners

  • removeAllListeners(event?: string | symbol): this
  • Parameters

    • Optional event: string | symbol

    Returns this

removeListener

  • removeListener(event: string | symbol, listener: (...args: any[]) => void): this
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

requestArtwork

  • requestArtwork(width?: number, height?: number): Promise<Buffer>
  • Requests the current artwork from the Apple TV.

    Parameters

    • Default value width: number = 400

      Image width

    • Default value height: number = 400

      Image height

    Returns Promise<Buffer>

    A Promise that resolves to a Buffer of data.

requestPlaybackQueue

sendKeyCommand

  • Send a key command to the AppleTV.

    Parameters

    • key: Key

      The key to press.

    Returns Promise<AppleTV>

    A promise that resolves to the AppleTV object after the message has been sent.

sendMessage

  • sendMessage(definitionFilename: string, messageType: string, body: {}, waitForResponse: boolean, priority?: number): Promise<Message>
  • Send a Protobuf message to the AppleTV. This is for advanced usage only.

    Parameters

    • definitionFilename: string

      The Protobuf filename of the message type.

    • messageType: string

      The name of the message.

    • body: {}

      The message body

    • waitForResponse: boolean

      Whether or not to wait for a response before resolving the Promise.

    • Default value priority: number = 0

    Returns Promise<Message>

    A promise that resolves to the response from the AppleTV.

setMaxListeners

  • setMaxListeners(n: number): this
  • Parameters

    • n: number

    Returns this

waitForSequence

  • waitForSequence(sequence: number, timeout?: number): Promise<Message>

Static key

  • key(string: string): Key
  • Convert a string representation of a key to the correct enum type.

    Parameters

    • string: string

      The string.

    Returns Key

    The key enum value.

Static listenerCount

  • listenerCount(emitter: EventEmitter, event: string | symbol): number
  • deprecated

    since v4.0.0

    Parameters

    • emitter: EventEmitter
    • event: string | symbol

    Returns number

Generated using TypeDoc