Skip to content
Snippets Groups Projects
Commit 23d8de96 authored by 42loop's avatar 42loop
Browse files

some new features as file list, ...

parent becd3e59
Branches
No related tags found
No related merge requests found
......@@ -7,6 +7,9 @@ import threading
import time
import socket
import glob
import fnmatch
import os
from lib import client as mqtt
__addon__ = xbmcaddon.Addon()
......@@ -28,6 +31,11 @@ def getmedia(dir):
all.extend(glob.glob(dir+'*.MP3'))
all.extend(glob.glob(dir+'*.MPG'))
all.extend(glob.glob(dir+'*.MPEG'))
for root, dirnames, filenames in os.walk('/media'):
for filename in filenames:
if filename.lower().endswith(('.mov', '.m4v', '.mp4', '.mpg', '.mpeg')):
all.append(os.path.join(root, filename))
all.sort()
# xbmc.log(str(all))
......@@ -88,26 +96,16 @@ def publish(suffix,val,more):
def publishstat(suffix,val,more):
global topic,mqc
robj={}
robj["val"]=val
if more is not None:
robj.update(more)
jsonstr=json.dumps(robj)
fulltopic="stat/"+topic+suffix
mqttlogging("MQTT: Publishing @"+fulltopic+": "+jsonstr)
mqc.publish(fulltopic,jsonstr,qos=0,retain=True)
mqttlogging("MQTT: Publishing @"+fulltopic+": "+val)
mqc.publish(fulltopic,val,qos=0,retain=True)
def publishmedialist(suffix,val,more):
global topic,mqc
robj={}
robj["val"]=val
if more is not None:
robj.update(more)
jsonstr=json.dumps(robj)
fulltopic="media/"+topic+suffix
mqttlogging("MQTT: Publishing @"+fulltopic+": "+jsonstr)
mqc.publish(fulltopic,jsonstr,qos=0,retain=True)
mqttlogging("MQTT: Publishing @"+fulltopic+": "+val)
mqc.publish(fulltopic,val,qos=0,retain=True)
#
......@@ -199,6 +197,7 @@ class MQTTPlayer(xbmc.Player):
def onPlayBackStarted(self):
setplaystate(1,"started")
publishstat()
def onPlayBackPaused(self):
setplaystate(2,"paused")
......@@ -208,9 +207,11 @@ class MQTTPlayer(xbmc.Player):
def onPlayBackEnded(self):
setplaystate(0,"ended")
publishstat()
def onPlayBackStopped(self):
setplaystate(0,"stopped")
publishstat()
def onPlayBackSeek(self):
publishprogress()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment