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: Dir::Tmpname.make_tmpname("/tmp/mpv", ".sock"), user_args: []) ⇒ Session

Returns a new instance of Session.

Parameters:

  • path (String) (defaults to: Dir::Tmpname.make_tmpname("/tmp/mpv", ".sock"))

    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



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

def initialize(path: Dir::Tmpname.make_tmpname("/tmp/mpv", ".sock"),
               user_args: [])
  @socket_path = path

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

  until File.exist?(@socket_path)
    sleep 0.1
  end

  @client = Client.new(@socket_path)
end

Instance Attribute Details

#clientMPV::Client (readonly)

Returns the client communicating with mpv.

Returns:



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

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



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

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



10
11
12
# File 'lib/mpv/session.rb', line 10

def socket_path
  @socket_path
end

Instance Method Details

#callbacksArray<MPV::Callback>

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

Returns:

  • (Array<MPV::Callback>)

    callback objects that will be invoked whenever mpv emits an event

See Also:



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

def_delegators :@client, :callbacks

#commandHash

Returns mpv's response to the command.

Returns:

  • (Hash)

    mpv's response to the command

See Also:



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

def_delegators :@client, :command

#get_propertyObject

Returns the value of the property.

Returns:

  • (Object)

    the value of the property

See Also:



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

def_delegators :@client, :get_property

#quit!void

This method returns an undefined value.

See Also:



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

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:



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

def_delegators :@server, :running?

#set_propertyHash

Returns mpv's response.

Returns:

  • (Hash)

    mpv's response

See Also:



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

def_delegators :@client, :set_property