this isn't so hard to do if i completely ignore making a GUI...
copy and paste this into a default.py file, and start it with autoexec.py
read the comments in the file, they explain how to use it.
@ timdog82001 - you're probably going to be more concerned with the sfx part. be warned though, the one wav file I tried to play with this method sounded awful, and it made the GUI slow. It was a 11,025Hz 16bit PCM I grabbed from
here.
if you use partymode, it will act just like partymode always does and change the activewindow to now playing, so it's probably not what you guys want to do.
Code:
"""
media is what you want playing.
-Note: for partymode you should leave it as media="", and set playercontrol1="Partymode(music)"
-Note: if you use a playlist, it will start over everytime. the script will NOT remember where it left off.
This can be a playlist, music, or video file or an Url.
ex. media="C:\\Program Files\\XBMC\\userdata\\playlists\\music\\sampleplaylist.m3u"
ex. media="F:\\Media\\Music\\Primus\\Pork Soda\\01 - Pork Chop's Little Ditty.mp3"
playercontrol1 & playercontrol2 control how playlists behave.
options are: "Random", "RepeatOne", "RepeatAll", or "Partymode(music)"
ex. to repeat all songs in a playlist do this:
playercontrol1="RepeatAll"
playercontrol2="Random"
ex. to repeat all songs in a playlist in order, do this:
playercontrol1="RepeatAll"
playercontrol2=""
ex. for partymode leave media as media=""
playercontrol1="Partymode(music)"
sfx is for when you want a short ambient file to always play in the background.
it won't show up anywhere as playing.
this was intended for short sound effects, so don't get mad if you crash a lot with this enabled. i've only done limited testing
needs to be a full path to a .wav
"""
media="C:\\test.wav"
# This can be a playlist, music, or video file or an Url.
playercontrol1=""
playercontrol2=""
# "Random", "RepeatOne", "RepeatAll", "Partymode(music)", "Partymode(path to .xsp file)"
sfx=True
# True or False | Note that there are no quotes around True or False
# media needs to be a path to a .wav file if this is true
####################################
#Don't mess with anything down here#
#unless you know what you're doing #
####################################
import xbmc,xbmcgui
from os import path
xbmc.executehttpapi('SetResponseFormat¶meter=WebHeader;False;WebFooter;False')
if (media!="" and not path.isfile(media)):
xbmcgui.Dialog().ok('Invalid Path','Path to media not found')
y=1
while y==1:
rawResponse=xbmc.executehttpapi('getcurrentlyplaying')
if rawResponse=='<li>Filename:[Nothing Playing]':
if(media==""):
if (playercontrol1=="Partymode(music)" or playercontrol2=="Partymode(music)"):
xbmc.executebuiltin('XBMC.PlayerControl(Partymode(music))')
xbmc.sleep(5000)
elif(sfx==True):
try:
xbmc.playSFX(media)
except:
xbmc.log('playSFX failed')
else:
xbmc.Player().play(media)
if playercontrol1!="":
xbmc.executebuiltin('XBMC.PlayerControl('+playercontrol1+')')
if playercontrol2!="":
xbmc.executebuiltin('XBMC.PlayerControl('+playercontrol2+')')
xbmc.sleep(5000)
else:
xbmc.sleep(2000)