def SetRepeat(c,playerid,repeat): print "repeat:", repeat if repeat=="one": vlc.command("pl_loop") elif repeat=="all": vlc.command("pl_repeat") c.repeat= repeat
def SetMute(c,mute): c.muted= not c.muted if c.muted: vlc.command("volume",val=0) else: vlc.command("volume",val=256*(c.volume/100.0)) c.VolumeChanged() return "OK"
def Seek(c,playerid,value): if type(value)==dict: pos= time2seconds(value) elif type(value)==float: pos= value*c.duration//100 print value,pos vlc.command("seek",val=pos) r= c.Get(["totaltime","percentage","time"] ) print r return r
def Open(c,playlistid=None, position=None, **o): if playlistid==None or position==None: position= len(c.items) if c.Add(0,o)!="OK": print "cannot add item:", o return {} print "playlist one position:", position print "nodes:", c.getnodes() if not len(c.nodes): return {} vlc.command("pl_play", id= c.getid(position)) return c.items[position]
def Add(c,playlistid,item): items= plugin.get( **item ) or \ AudioLibrary.Get( **item ) if type(items)!=list: print "not list:",items return "Not found" for i in items: print i i["type"]="song" vlc.command("in_enqueue", input= quote(i["file"],safe='') ) c.items.append( i ) yamc.event.post().Playlist.OnAdd( i, playlistid= playlistid, position= len(c.items) ) c.dirty= True return "OK"
def PlayPause(c,playerid,**k): if k.has_key("play"): if k["play"] and c.speed==1: return "OK" if not k["play"] and c.speed==0: return "OK" s=vlc.command("pl_pause") if s["state"]=="paused": c.speed= 0 elif s["state"]=="playing": c.speed= 1 c.OnPlay() return "OK"
def reverse(): vlc.command("seek",val="-5%") def volumeminus(): Application.SetVolume( Application.volume-16 )
def forward(): vlc.command("seek",val="+5%") def reverse(): vlc.command("seek",val="-5%")
def SetVolume(c,volume): c.volume=volume vlc.command("volume",val=256*(c.volume/100.0)) c.VolumeChanged()
def SetShuffle(c,playerid,shuffle): vlc.command("pl_random") return "OK"
def GoTo(c,playerid, to ): vlc.command("pl_play",id=Playlist.getnodes()[to] ) c.position= to return "OK"
def SetSpeed(c,playerid,speed): if speed==1: vlc.command("pl_play")
def Stop(c,playerid): vlc.command("pl_stop") return "OK"
def Minus(c): vlc.command("pl_previous") c.position= Playlist.position( **vlc.status) c.OnPlay( **Playlist.items[c.position] ) Playlist.dirty= True
def Plus(c): vlc.command("pl_next") c.position= Playlist.position( **vlc.status() ) print "plus:", c.position c.OnPlay( **Playlist.items[c.position] ) Playlist.dirty= True
def Clear(c,playlistid): vlc.command("pl_empty") c.items=[] c.dirty= True return "OK"