I am trying to play videos automatically when the Raspberry Pi boots. I decided to use crontab for that:

@reboot /storage/.config/autostart.sh

The autostart.sh file contains the following code:

xbmc-send -a "PlayMedia(/storage/videos/)"

The Raspberry Pi successfully automatically starts to play videos from /storage/videos/ directory when it reboots.

The problem is that it plays the videos in descending order. My video files are called 1.mp4, 2.mp4, 3.mp4 and it plays 3.mp4 video first then 2.mp4 and finally 1.mp4. I need to play them in ascending order.

When I try to play them manually by going to video directory and clicking to play 1.mp4 video then it play sequentially. If you know how to resolve this problem, please let me know. It is very useful to me.

  • 1
    Why not simply rename them? Commented May 2, 2013 at 13:20
  • 2
    I am not suppose to do that way. I am waiting for getting your new idea.
    – Viswa
    Commented May 3, 2013 at 3:59
  • It might be sorting the files by date created? Since the last file is the newest it will be the first. Try and adjust the first file date by moving it or something so it gets a new modified date/created dates.
    – Piotr Kula
    Commented Nov 10, 2013 at 18:18

1 Answer 1


I suppose you could create a smart playlist file and have xmbc play that when it starts.

Note this hasn't been tested


<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<smartplaylist type="movies">
    <rule field="none" operator="contains"></rule>
    <order direction="ascending">filename</order>

xbmc-send -a "PlayMedia(/storage/videos/videos.xsp)"

you can find more information on smartplaylists here : http://wiki.xbmc.org/index.php?title=Smart_playlists#Format_of_a_smart_playlist_file

  • Could you please tell me the way to create a playlist. I just create a file called videos.xsp in "/storage/videos/" paste the line which you given above. but the player was not play contents.
    – Viswa
    Commented May 2, 2013 at 11:08
  • as I mentioned in my answer, I haven't tried this yet, but will try this weekend and report the results. It is something that would appear within the xbmc documentation to fix your issue.
    – kolin
    Commented May 3, 2013 at 13:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.