Writing a script, wondering about XBMC conventions
#1
So I'm writing a script to resume an audio or video playlist from roughly where it left off, even if XBMC is shut off without warning. This is quite useful for the Xbox I mounted in my car. I actually already have the script working, but since I'm new to the community, I don't know a few things.

My script saves the currently playing playlist, file, and position to a data file, sleeps for 10 seconds, then repeats. When XBMC is started, it checks the saved info, puts it all into a new playlist, starts playing from the last saved position, then starts saving the info again.

My questions are these:

1) Where is a good place to save the data? Right now I have it going to Q:\scripts, but maybe it would be better to put my saved data in Q:\UserData\? Maybe another place?

2) My script is running constantly (though it should only be using CPU time every 10 seconds or so). Is this considered an OK way to do things? If not, how could I set up my script so that it runs on a very regular schedule?
Reply
#2
1) Use userdata over script path. script path might be read only on some systems. Also use special://userdata, and translatePath() if you are using a local path definition. use sub structure special://userdata/addon_data/<script folder name> to avoid a mess in userdata root.
As far as I know, this is the most correct way

2) If it doesn't bother the user I guess it must be considered okay. If your script locks up the computer every 10 seconds people probably won't use your script, but 10 seconds is nothing compared to most program loops.

You can use the alarmclock function to schedule the script one time everytime it starts, but I don't see that as a better solution. I'm not 100% sure if it support executing scripts either
Reply
#3
if the script is sleeping the thread is totally harmless (up to some memory usage)
Reply

Logout Mark Read Team Forum Stats Members Help
Writing a script, wondering about XBMC conventions0