Class: MPV::Session
- Inherits:
-
Object
- Object
- MPV::Session
- 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
-
#client ⇒ MPV::Client
readonly
The client communicating with mpv.
-
#server ⇒ MPV::Server
readonly
The server object responsible for the mpv process.
-
#socket_path ⇒ String
readonly
The path of the socket being used for communication.
Instance Method Summary collapse
-
#callbacks ⇒ Array<Proc>
Callback procs that will be invoked whenever mpv emits an event.
-
#command ⇒ Hash
Mpv's response to the command.
-
#get_property ⇒ Object
The value of the property.
-
#initialize(path: File.join('/tmp', Utils.tmpsock), user_args: []) ⇒ Session
constructor
A new instance of Session.
- #quit! ⇒ void
-
#running? ⇒ Boolean
Whether or not the mpv process is running.
-
#set_property ⇒ Hash
Mpv's response.
Constructor Details
#initialize(path: File.join('/tmp', Utils.tmpsock), user_args: []) ⇒ Session
Returns a new instance of Session.
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
#client ⇒ MPV::Client (readonly)
Returns the client communicating with mpv.
18 19 20 |
# File 'lib/mpv/session.rb', line 18 def client @client end |
#server ⇒ MPV::Server (readonly)
Returns the server object responsible for the mpv process.
15 16 17 |
# File 'lib/mpv/session.rb', line 15 def server @server end |
#socket_path ⇒ String (readonly)
Returns 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
#callbacks ⇒ Array<Proc>
Returns callback procs that will be invoked whenever mpv emits an event.
42 |
# File 'lib/mpv/session.rb', line 42 def_delegators :@client, :callbacks |
#command ⇒ Hash
Returns mpv's response to the command.
52 |
# File 'lib/mpv/session.rb', line 52 def_delegators :@client, :command |
#get_property ⇒ Object
Returns the value of the property.
57 |
# File 'lib/mpv/session.rb', line 57 def_delegators :@client, :get_property |
#quit! ⇒ void
This method returns an undefined value.
47 |
# File 'lib/mpv/session.rb', line 47 def_delegators :@client, :quit! |
#running? ⇒ Boolean
Returns whether or not the mpv process is running.
37 |
# File 'lib/mpv/session.rb', line 37 def_delegators :@server, :running? |
#set_property ⇒ Hash
Returns mpv's response.
62 |
# File 'lib/mpv/session.rb', line 62 def_delegators :@client, :set_property |