How to play videos automatically after boot on a loop?
#1
Hi all,

I have recently installed Xbian on my RPi B+.
I want it to play my videos (in a folder) automatically after boot in an infinite loop.

I found a solution here , which suggests the following code:

Code:
# Autoplay videodirectory
import os, xbmc

# set path to dir you want to play
path="E:\\videos"

dirList=os.listdir(path)

videoList = xbmc.PlayList(xbmc.PLAYLIST_VIDEO)
videoList.clear()

for fname in dirList:
    videoList.add(path + "\\" + fname)

# shuffle playlist
videoList.shuffle()

# put playlist on repeat
xbmc.executebuiltin("xbmc.playercontrol(RepeatAll)")

# play playlist
xbmc.Player().play(videoList)

I saved this code as :

Code:
/home/xbian/.kodi/userdata/autoexec.py

However, after reboot, the system got frozen and now it never boots.
After I plug the power cord, nothing comes at all! Just a black screen!!

Here are my questions:

1. Is this code correct?
2. Have I saved this code (autoexec.py) in the correct location?
3. Are there any other alternative solutions for "videos play at startup on infinite loop"?
4. Now that my system is frozen, how can I access the contents of my SD card?

Thanks for your time and support.
Reply
#2
(2015-06-05, 15:57)OMID-313 Wrote: 1. Is this code correct?

No, the code is written to use Windows paths, you need to change the code to use a path that will work for your system (ie. access local storage, nfs:// or smb:// paths instead of E:\)

(2015-06-05, 15:57)OMID-313 Wrote: 2. Have I saved this code (autoexec.py) in the correct location?

Yep.

(2015-06-05, 15:57)OMID-313 Wrote: 3. Are there any other alternative solutions for "videos play at startup on infinite loop"?

Some skins support playing a playlist at startup, eg. Confluence Modified (I think).

(2015-06-05, 15:57)OMID-313 Wrote: 4. Now that my system is frozen, how can I access the contents of my SD card?

What do you mean by frozen, does the Pi respond to a network ping? Can you connect with ssh? If so, just delete or rename your autoexec.py file.
Texture Cache Maintenance Utility: Preload your texture cache for optimal UI performance. Remotely manage media libraries. Purge unused artwork to free up space. Find missing media. Configurable QA check to highlight metadata issues. Aid in diagnosis of library and cache related problems.
Reply
#3
(2015-06-05, 16:27)Milhouse Wrote:
(2015-06-05, 15:57)OMID-313 Wrote: 1. Is this code correct?

No, the code is written to use Windows paths, you need to change the code to use a path that will work for your system (ie. access local storage, nfs:// or smb:// paths instead of E:\)

(2015-06-05, 15:57)OMID-313 Wrote: 2. Have I saved this code (autoexec.py) in the correct location?

Yep.

(2015-06-05, 15:57)OMID-313 Wrote: 3. Are there any other alternative solutions for "videos play at startup on infinite loop"?

Some skins support playing a playlist at startup, eg. Confluence Modified (I think).

(2015-06-05, 15:57)OMID-313 Wrote: 4. Now that my system is frozen, how can I access the contents of my SD card?

What do you mean by frozen, does the Pi respond to a network ping? Can you connect with ssh? If so, just delete or rename your autoexec.py file.

Thank you very much @Milhouse for your detailed reply.

Here are some points:

1. Of course I have changed the path. I remember I had saved the following path:
Code:
path="/home/xbian/My_Videos"
Now, is this correct?
Or shall I use nfs:// or smb:// !!? (What are they!!!?)

2. When I say it's frozen, I mean nothing comes at all! The screen is always black. I unplug/plug , and again everything is black. I wait for 5 minutes, but it's all black!!
Actually, I haven't tried SSH before, and unfortunately, I don't know the IP of my Xbian/RPi. Would you please help me how to do it?
Reply
#4
(2015-06-05, 16:38)OMID-313 Wrote: 1. Of course I have changed the path. I remember I had saved the following path:
Code:
path="/home/xbian/My_Videos"
Now, is this correct?

If that's where your files are, then it looks OK.

You should also change:
Code:
videoList.add(path + "\\" + fname)

to
Code:
videoList.add(path + "/" + fname)

(2015-06-05, 16:38)OMID-313 Wrote: 2. When I say it's frozen, I mean nothing comes at all! The screen is always black.

OK, so Kodi has "hung".

(2015-06-05, 16:38)OMID-313 Wrote: Actually, I haven't tried SSH before, and unfortunately, I don't know the IP of my Xbian/RPi. Would you please help me how to do it?

No need for two threads, continue the discussion in your other thread.
Texture Cache Maintenance Utility: Preload your texture cache for optimal UI performance. Remotely manage media libraries. Purge unused artwork to free up space. Find missing media. Configurable QA check to highlight metadata issues. Aid in diagnosis of library and cache related problems.
Reply
#5
Thanks again @Milhouse for your reply.

One more question:

Is the following line correct?
Code:
xbmc.executebuiltin("xbmc.playercontrol(RepeatAll)")
Or shall I change it to:
Code:
xbmc.executebuiltin('xbmc.playercontrol(RepeatAll)')
?

How about changing
Code:
import os, xbmc
to
Code:
import xbmc
?
Reply
#6
1. Single quote or double quote makes no difference
2. No, that's correct - don't change it.
Texture Cache Maintenance Utility: Preload your texture cache for optimal UI performance. Remotely manage media libraries. Purge unused artwork to free up space. Find missing media. Configurable QA check to highlight metadata issues. Aid in diagnosis of library and cache related problems.
Reply
#7
(2015-06-05, 17:16)Milhouse Wrote: 1. Single quote or double quote makes no difference
2. No, that's correct - don't change it.

Thank you very much @Milhouse for your great help and support.

Well, it seems that the code is generally correct, except the following line:
Code:
videoList.add(path + "\\" + fname)
that must be changed to:
Code:
videoList.add(path + "/" + fname)
.

So, what was the actual cause of Xbian/RPi hanging and freezing !!!?
Huh
Reply
#8
Hard to say, sorry.
Texture Cache Maintenance Utility: Preload your texture cache for optimal UI performance. Remotely manage media libraries. Purge unused artwork to free up space. Find missing media. Configurable QA check to highlight metadata issues. Aid in diagnosis of library and cache related problems.
Reply
#9
(2015-06-05, 17:36)Milhouse Wrote: Hard to say, sorry.

So, if I find a way to access the contents of my SD card, and change the above lines (change "//" to "\"), would this solve the hang/freeze problem!?
Reply
#10
Without knowing what exactly caused the hang, it's hard to say. You'll need a debug log at least to understand why Kodi is no longer responding.
Texture Cache Maintenance Utility: Preload your texture cache for optimal UI performance. Remotely manage media libraries. Purge unused artwork to free up space. Find missing media. Configurable QA check to highlight metadata issues. Aid in diagnosis of library and cache related problems.
Reply
#11
(2015-06-05, 18:53)Milhouse Wrote: Without knowing what exactly caused the hang, it's hard to say. You'll need a debug log at least to understand why Kodi is no longer responding.

Dear @Milhouse,
After reinstalling everything from the beginning, and changing "//" to "\" , finally it worked!!
It seems that the cause of this hang/freeze was this little typo !!

Anyway, I noticed something:
It begins to play the videos in a random order. How can I set it to sort by name!?
I tried to add "Container.SetSortMethod(1)" to the code:

Code:
...
xbmc.executebuiltin("xbmc.playercontrol(RepeatAll)")
xbmc.executebuiltin("Container.SetSortMethod(1)")
xbmc.Player().play(videoList)

But it didn't help. Again the videos started to play at random order.
Is this the correct code? And have I inserted it in the correct line?

(The interesting thing is that every time this random order is the same! But it's not name, date, ...)

So how can I set it to sort videos by name !?
Reply

Logout Mark Read Team Forum Stats Members Help
How to play videos automatically after boot on a loop?0