Kodi Community Forum

Full Version: Background music in a loop on a specific window
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi all,

I am trying to create a window, which, when opens, will play a specific file - preferably in a loop. Sort of like background music...

I tried to do the following:

<onclick>PlayMedia(~Desktop/file.mp3</onclick>
<onclick>ActivateWindow(1110)</onclick> <!-- this is a my custom window -->

However - I get an error:

Code:
16:18:58.228 T:140735956284352   ERROR: CAudioDecoder: Unable to Init Codec while loading file sounds/file.mp3
16:18:58.228 T:140735956284352 WARNING: PAPlayer::QueueNextFileEx - Failed to create the decoder
16:18:58.229 T:140735956284352   ERROR: PlayMedia could not play media: sounds/file.mp3
16:18:58.821 T:140735956284352   ERROR: Init: Error opening file sounds/file.mp3

The file definitely exists - in skin/media/sounds/file.mp3. I also tried it in skin/sounds/file.mp3 but no luck.

Also, the above would not stop the music when I exit the window - can I use something like <onfocus> ?

Thanks
CJ
- move the playback to custom window/dialog
as an <onload>PlayMedia(special://skin/media/sounds/file.mp3/)
<onunload>stop</onunload>
Ah excellent! That works!

Now I am trying to make it repeat (preferably gaplessly). I tried adding this:

<onload>PlayerControl(repeat)</onload>

...but it doesn't repeat. I read that only playlists are repeatable and not individual tracks, so I tried passing path to the playlist but getting this error.

ERROR: PlayMedia could not play media: special://skin/media/sounds/pl.m3u

Inside the m3u file is:

#EXTM3U
special://skin/media/sounds/file.mp3

Any ideas on this?
There an action command

PlayerControl(RepeatAll)

Try to set it also onlosd after the play command

(maybe an delay is needed, but test first)
Thanks. The PlayerControl is after the Play command - RepeatAll doesn't seem to do anything.
Can't seem to edit my own posts... How can I delay the PlayerControl after Play?
Your account is still too new for full account privileges. Smile
Try


<onload>AlarmClock(playmeinloop,PlayMedia(special://skin/media/sounds/file.mp3/),**use the length of your file in seconds here**,silent,loop)</onunload> <!-- add after 1st onload play command force playback in loop at the time expiration -->

<onunload>CancelAlarm(playmeinloop,true)</onunload> <!-- put after stop onunload, cancel loop on exit -->



Source
Thank you! That's perfect - it works Smile Just need to make sure my loop is exactly n seconds long so there are no perceptible gaps.
I am going to ask another question... Say after 19 seconds, I would like to automatically play a particular file. In my case, it would be a selected file from the list... It would display my custom window (sort of intro, if you like) and then automatically play. Is that possible and how?

I know that play button has an ID of 8 but what's the equivalent action?