Class: MPV::Session

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/mpv/session.rb

Overview

Represents a combined mpv "server" and "client" communicating over JSON IPC.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path: File.join('/tmp', Utils.tmpsock), user_args: []) ⇒ Session

Returns a new instance of Session.

Parameters:

  • path (String) (defaults to: File.join('/tmp', Utils.tmpsock))

    the path of the socket to create (defaults to a tmpname in /tmp)

  • user_args (Array<String>) (defaults to: [])

    additional arguments to use when spawning mpv



24
25
26
27
28
29
30
31
32
# File 'lib/mpv/session.rb', line 24

def initialize(path: File.join('/tmp', Utils.tmpsock), user_args: [])
  @socket_path = path

  @server = Server.new(path: @socket_path, user_args: user_args)

  sleep 0.1 until File.exist?(@socket_path)

  @client = Client.new(@socket_path)
end

Instance Attribute Details

#clientMPV::Client (readonly)

Returns the client communicating with mpv.

Returns:



18
19
20
# File 'lib/mpv/session.rb', line 18

def client
  @client
end

#serverMPV::Server (readonly)

Returns the server object responsible for the mpv process.

Returns:

  • (MPV::Server)

    the server object responsible for the mpv process



15
16
17
# File 'lib/mpv/session.rb', line 15

def server
  @server
end

#socket_pathString (readonly)

Returns the path of the socket being used for communication.

Returns:

  • (String)

    the path of the socket being used for communication



12
13
14
# File 'lib/mpv/session.rb', line 12

def socket_path
  @socket_path
end

Instance Method Details

#callbacksArray<Proc>

Returns callback procs that will be invoked whenever mpv emits an event.

Returns:

  • (Array<Proc>)

    callback procs that will be invoked whenever mpv emits an event

See Also:



42
# File 'lib/mpv/session.rb', line 42

def_delegators :@client, :callbacks

#commandHash

Returns mpv's response to the command.

Returns:

  • (Hash)

    mpv's response to the command

See Also:



52
# File 'lib/mpv/session.rb', line 52

def_delegators :@client, :command

#get_propertyObject

Returns the value of the property.

Returns:

  • (Object)

    the value of the property

See Also:



57
# File 'lib/mpv/session.rb', line 57

def_delegators :@client, :get_property

#quit!void

This method returns an undefined value.

See Also:



47
# File 'lib/mpv/session.rb', line 47

def_delegators :@client, :quit!

#running?Boolean

Returns whether or not the mpv process is running.

Returns:

  • (Boolean)

    whether or not the mpv process is running

See Also:



37
# File 'lib/mpv/session.rb', line 37

def_delegators :@server, :running?

#set_propertyHash

Returns mpv's response.

Returns:

  • (Hash)

    mpv's response

See Also:



62
# File 'lib/mpv/session.rb', line 62

def_delegators :@client, :set_property