可插入的回放队列服务
tinnitus的Python项目详细描述
Info: | See <https://github.com/strangedev/tinnitus>. |
---|---|
Author: | Noah Hummel <strangedev@posteo.net> |
Date: | 2017-02-21 |
Revision: | 3 |
耳鸣是一种媒体播放器和播放队列。
它分为两部分,服务和远程。一旦tinnitusd服务运行,python远程可以用来 操作队列并控制回放。tinnitusd使用可插入的后端,这使得扩展变得容易。 耳鸣是线程安全的,这意味着它可以被任意数量的远程用户同时访问。
注意
运行服务
安装耳鸣后,您可以使用以下命令启动服务:
tinnitusd [port]
port是一个可选参数,默认情况下,tinnitus在端口18861上运行。
如果您已将耳鸣安装到virtualenv,请确保首先激活它。
遥控器
要在您自己的项目中使用远程,请将tinnitus安装到您正在开发项目的同一环境中。
然后,您可以使用带有ContextManager协议的遥控器:
fromtinnitusimportremotewithremote()asr:print(r.status())
您还可以将遥控器配置为使用不同的网络配置:
importtinnitustinnitus.configure(host="localhost",port=1337)
支持的操作有:
^{pr 4}$ | Adds an audio resource to the queue. ^{tt2}$ is an int identifying each resource unqiuely. ^{tt3}$ is a str containing the resource’s location (and protocol) ^{tt4}$ is the name of the backend which should handle the resource |
^{pr 5}$ | Removes an audio resource from the queue. ^{tt2}$ is an int identifying each resource unqiuely. |
^{pr 6}$ | Removes all resources from the queue. |
^{pr 7}$ | Returns the ^{tt2}$ of the currently playing resource. |
^{pr 8}$ | Returns the ^{tt2}$ s of all queued resources as a list. |
^{pr 9}$ | Starts playback, if the backend is paused or stopped. |
^{pr 10}$ | Pauses playback, if the backend is playing. |
^{pr 11}$ | Stops playback, if the backend is playing or stopped. |
^{pr 12}$ | Skips forward to the next queued resource and starts playing. |
^{pr 13}$ | Returns the backend’s status as either PLAYING, PAUSED or STOPPED. The Status enum is defined in ^{tt8}$ |
^{pr 14}$ | Returns a boolean indicating whether the resource specified by ^{tt3}$ is available for playback with the specified backend. Note: This method does not indicate whether the backend is appropriate for the resource. Note: This feature is optional, the remote may return NotImplemented if it is not supported by the backend. |
可插拔后端
回放由可插拔的后端处理。插件是python脚本,可以位于任何地方。
耳鸣默认带有一个使用libvlc的简单后端。它既多才多艺,又是一个范例 对于插件结构。
要创建名为my_backend的插件,请执行以下步骤:
如果您以前没有设置插件目录,或者希望创建单独的插件目录:
- 在系统的任何地方创建插件目录,例如~/tinnitus_plugins/。
- 使用附带的tinnitus-include命令将tinnitud指向您的目录:
tinnitus-include add ~/tinnitus_plugins
你可以使用任意数量的插件目录。要列出所有已使用的插件目录,请使用:
tinnitus-include list
要从tinnitusd中删除插件目录,例如~/tinnitus_plugins/,请使用:
tinnitus-include rem ~/tinnitus_plugins
如果已经创建了如上所述的插件目录,则可以创建名为^{tt14}的文件$ 在你的插件目录中。
您的插件应公开以下方法,以便服务识别:
^{pr 18}$ | Called before the plugin is used for the first time. Use this method to perform any initialisation, if needed. ^{tt15}$ is a method which your plugin should call once a resource has reached it’s end, save it somewhere. |
^{pr 19}$ | Called when a resource is loaded for playback. It passes the resources to your plugin so that your plugin can perform any setup needed to play the resource with the given mrl. ^{tt3}$ is the resources location (and protocol) |
^{pr 20}$ | Called when your plugin should start playing the resource given by ^{tt17}$. Note: The method should be non-blocking. |
^{pr 21}$ | Called when your plugin should pause playback of the resource. Note: The method should be non-blocking. |
^{pr 22}$ | Called when your plugin should stop playback of the resource. Note: The method should be non-blocking. |
您的插件还可以选择公开这些方法中的任何一种,以支持更多的远程功能:
^{pr 23}$ | Returns a boolean indicating whether the resource specified by ^{tt3}$ is available for playback. For example, if ^{tt3}$ points to a local file, your plugin should check if the local file exits. This feature is exposed as remote.available(). If your plugin doesn’t implement this method, the return value will default to NotImplemented. |