星期二, 7月 22, 2008

[Boo]Play automatically after Banshee launched - part 2

每次都從第一首播放,實在太沒意思,所以在播放前切換為 Shuffle 模式,播放時,就會隨機挑選一首開始播放,然後再關閉 Shuffle 模式。


import System
import System.IO
import Banshee.ServiceStack
import Banshee.PlaybackController

def AutoPlay() as bool:
ServiceManager.PlaybackController.ShuffleMode = PlaybackShuffleMode.Song
ServiceManager.PlayerEngine.Play()
ServiceManager.PlaybackController.ShuffleMode = PlaybackShuffleMode.Linear

def OnClientStarted( client as Client ):
Hyena.Log.Information( "engine is playing now..." )
GLib.Timeout.Add(1500, AutoPlay)
Banshee.ServiceStack.Application.ClientStarted -= OnClientStarted

Hyena.Log.Information( "autoplay script is loaded." )

Banshee.ServiceStack.Application.ClientStarted += OnClientStarted


p.s. 上次有提到要作自動記錄播放與自動播放記錄曲目的功能,我的確是做了,只是在播放完指定曲目後,又跳回第一首,這表示我還得繼續研究原始碼才行,所以暫時不釋出。

沒有留言: