Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
P
py-vlcclient
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
rasky
py-vlcclient
Commits
996aad90
Commit
996aad90
authored
Jun 15, 2012
by
Michael Mayr
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Code Cleanup
parent
b63c9337
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
23 deletions
+30
-23
Readme.rst
Readme.rst
+5
-1
vlcclient.py
vlcclient.py
+25
-22
No files found.
Readme.rst
View file @
996aad90
...
...
@@ -17,10 +17,14 @@ it when starting VLC::
$ vlc --intf telnet
or with network access:
$ vlc --intf telnet --lua-config "telnet={host='0.0.0.0:4212'}"
or via the menus (depending on your platform, mostly View ->
Add Interface -> Telnet).
For exampl
e::
Example usag
e::
>>> from vlcclient import VLCClient
>>> vlc = VLCClient("::1")
...
...
vlcclient.py
View file @
996aad90
...
...
@@ -3,16 +3,18 @@
VLCClient
~~~~~~~~~
This module allows to control a VLC instance to be controlled
via telnet. You need to enable the telnet interface, e.g. start
This module allows to control a VLC instance through a python interface.
You need to enable the telnet interface, e.g. start
VLC like this:
$ vlc --intf telnet
To start VLC with allowed remote admin:
$ vlc --intf telnet --lua-config "telnet={host='0.0.0.0:4212'}"
Replace --intf with --extraintf to start telnet and the regular GUI
More information about the telnet interface:
http://wiki.videolan.org/Documentation:Streaming_HowTo/VLM
...
...
@@ -71,7 +73,7 @@ class VLCClient(object):
self
.
telnet
.
close
()
self
.
telnet
=
None
def
send_command
(
self
,
line
):
def
_
send_command
(
self
,
line
):
"""Sends a command to VLC and returns the text reply.
This command may block."""
self
.
telnet
.
write
(
line
+
"
\n
"
)
...
...
@@ -90,16 +92,16 @@ class VLCClient(object):
#
def
help
(
self
):
"""Returns the full command reference"""
return
self
.
send_command
(
"help"
)
return
self
.
_
send_command
(
"help"
)
def
status
(
self
):
"""current playlist status"""
self
.
_require_version
(
"status"
,
"2.0.0"
)
return
self
.
send_command
(
"status"
)
return
self
.
_
send_command
(
"status"
)
def
info
(
self
):
"""information about the current stream"""
return
self
.
send_command
(
"info"
)
return
self
.
_
send_command
(
"info"
)
#
# Playlist
...
...
@@ -107,43 +109,43 @@ class VLCClient(object):
def
add
(
self
,
filename
):
"""Add a file to the playlist and play it.
This command always succeeds."""
return
self
.
send_command
(
"add {0}"
.
format
(
filename
))
return
self
.
_
send_command
(
"add {0}"
.
format
(
filename
))
def
enqueue
(
self
,
filename
):
"""Add a file to the playlist. This command always succeeds."""
return
self
.
send_command
(
"enqueue {0}"
.
format
(
filename
))
return
self
.
_
send_command
(
"enqueue {0}"
.
format
(
filename
))
def
seek
(
self
,
second
):
"""Jump to a position at the current stream if supported."""
return
self
.
send_command
(
"seek {0}"
.
format
(
second
))
return
self
.
_
send_command
(
"seek {0}"
.
format
(
second
))
def
play
(
self
):
"""Start/Continue the current stream"""
return
self
.
send_command
(
"play"
)
return
self
.
_
send_command
(
"play"
)
def
pause
(
self
):
"""Pause playing"""
return
self
.
send_command
(
"pause"
)
return
self
.
_
send_command
(
"pause"
)
def
stop
(
self
):
"""Stop stream"""
return
self
.
send_command
(
"stop"
)
return
self
.
_
send_command
(
"stop"
)
def
rewind
(
self
):
"""Rewind stream"""
return
self
.
send_command
(
"rewind"
)
return
self
.
_
send_command
(
"rewind"
)
def
next
(
self
):
"""Play next item in playlist"""
return
self
.
send_command
(
"next"
)
return
self
.
_
send_command
(
"next"
)
def
prev
(
self
):
"""Play previous item in playlist"""
return
self
.
send_command
(
"prev"
)
return
self
.
_
send_command
(
"prev"
)
def
clear
(
self
):
"""Clear all items in playlist"""
return
self
.
send_command
(
"clear"
)
return
self
.
_
send_command
(
"clear"
)
#
# Volume
...
...
@@ -151,17 +153,17 @@ class VLCClient(object):
def
volume
(
self
,
vol
=
None
):
"""Get the current volume or set it"""
if
vol
:
return
self
.
send_command
(
"volume {0}"
.
format
(
vol
))
return
self
.
_
send_command
(
"volume {0}"
.
format
(
vol
))
else
:
return
self
.
send_command
(
"volume"
)
.
strip
()
return
self
.
_
send_command
(
"volume"
)
.
strip
()
def
volup
(
self
,
steps
=
1
):
"""Increase the volume"""
return
self
.
send_command
(
"volup {0}"
.
format
(
steps
))
return
self
.
_
send_command
(
"volup {0}"
.
format
(
steps
))
def
voldown
(
self
,
steps
=
1
):
"""Decrease the volume"""
return
self
.
send_command
(
"voldown {0}"
.
format
(
steps
))
return
self
.
_
send_command
(
"voldown {0}"
.
format
(
steps
))
class
WrongPasswordError
(
Exception
):
pass
...
...
@@ -196,5 +198,6 @@ def main():
print
command
()
except
OldServerVersion
as
e
:
print
"Error:"
,
e
if
__name__
==
'__main__'
:
main
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment