Add preview script.

Update issue #459
Basic script added.
This commit is contained in:
John Maguire 2011-01-25 16:48:12 +00:00
parent f929a88473
commit c4f4ee6fe5
2 changed files with 49 additions and 0 deletions

41
scripts/preview/main.py Normal file
View File

@ -0,0 +1,41 @@
import clementine
from PyQt4.QtCore import QTimer
from PyQt4.QtGui import QAction
class Plugin:
def __init__(self):
self.timer = QTimer(None)
self.timer.setInterval(10000)
self.timer.timeout.connect(self.Timeout)
self.timer.setSingleShot(True)
self.action = QAction("Preview mode", None)
self.action.setCheckable(True)
self.action.triggered.connect(self.Enabled)
clementine.ui.AddAction("playlist_menu", self.action)
clementine.player.Playing.connect(self.Playing)
clementine.player.Paused.connect(self.Stopped)
clementine.player.Stopped.connect(self.Stopped)
self.enabled = False
def Enabled(self, enabled):
self.enabled = enabled
if enabled:
if clementine.player.GetState() == 2: # Playing
self.timer.start()
else:
self.timer.stop()
def Playing(self):
if self.enabled:
self.timer.start()
def Stopped(self):
self.timer.stop()
def Timeout(self):
if clementine.player.GetState() == 2:
clementine.player.Next()
plugin = Plugin()

View File

@ -0,0 +1,8 @@
[Script]
name=Preview
description=Adds an option to preview songs.
author=John Maguire <john.maguire@gmail.com>
url=http://www.clementine-player.org
language=python
script_file=main.py