xboxscene.org forums

Author Topic: [script, Howto] Xbmc Starts With Video's Playing In Bg  (Read 127 times)

RSkillz

  • Archived User
  • Newbie
  • *
  • Posts: 8
[script, Howto] Xbmc Starts With Video's Playing In Bg
« on: February 13, 2006, 01:47:00 AM »

Ok, I better explain what I would like and what I got so far...

What I would like is to have my MusicVideo Playlist automaticly starting everytime
I start XBMC. It needs to play the musicvideo's in the background of the "Home"screen.

What I got so far is the following script "StartMyVid.py" added to my "Autoexec.py":

CODE
import xbmc
import os

# ---------------------------------------- #
# "Configuration"
# ---------------------------------------- #

# Change this to your playlist(s).
# Written like this: ['path\\to\\plist1', 'to\\plist2', 'plist\\3']
playlist_files= ['F:\\Files\\Albums\\Cache\\Playlists\\Video\\mv.m3u']

# Dirs(s) to traverse if playlist does not exist. NB: No trailing slash.
# Written like this: ['path\\to\\dir1', 'to\\dir2', 'dir\\3']
musicvideos_dirs = ['']

# Shuffle playlist if this var equals 1.
shuffle_files = 1


# ---------------------------------------- #
# Code
# ---------------------------------------- #

# Function for adding files to playlist
def add_files(pl, dirname, names):
    for filename in names:
        if (os.path.isfile(dirname + "\\" + filename)):
            add = 0
            
            # Check extension of file.
            if (filename[-4:] == ".avi"): add = 1
            if (filename[-4:] == ".mpg"): add = 1
            if (filename[-4:] == ".wmv"): add = 1
            if (filename[-4:] == ".asf"): add = 1
        if (filename[-4:] == ".m2v"): add = 1            

            # If file is to be added, do it.
            if (add == 1): pl.add(dirname + "\\" + filename)
        elif (os.path.isdir(dirname + "\\" + filename)):
            os.path.walk(dirname + "\\" + filename, add_files, pl)

# Get music playlist from XBMC
plist = xbmc.PlayList(0)
plist.clear()

# Load playlist if it exists
for playlist_file in playlist_files:
    if (os.path.isfile(playlist_file)):
    plist.load(playlist_file)
# Else, find all available music videos
else:
    for musicvideos_dir in musicvideos_dirs:
        os.path.walk(musicvideos_dir, add_files, plist)

# Do the shuffle!
if (shuffle_files == 1): plist.shuffle()

xbmc.Player().play(plist)
xbmc.executebuiltin('XBMC.ActivateWindow(0)')


It's an existing script which I edited just a bit to point to my musicvideo playlist (mv.m3u).
the last line
CODE
xbmc.executebuiltin('XBMC.ActivateWindow(0)')
makes the first video play in the background of the Home-screen (main window),
which is perfect BUT the next video's are all played in fullscreen.

What I did notice, is when I start the musicvideo playlist manually (from within XBMC) and then switch manually from fullscreen to the background of the Home-screen, it does play ALL the video's in the background, which is exactly what I want.

So the question is: What command is given when you start a video playlist manually AND
what command is given when you switch manually from full screen to background mode?

If I know this the "StartMyVid.py" script could be edited with these commands and the script would probably work perfectly.

This post has been edited by RSkillz: Feb 13 2006, 09:49 AM
Logged

JayDee

  • Archived User
  • Hero Member
  • *
  • Posts: 2311
[script, Howto] Xbmc Starts With Video's Playing In Bg
« Reply #1 on: February 13, 2006, 01:58:00 AM »

Moving to right forum...
Logged

RSkillz

  • Archived User
  • Newbie
  • *
  • Posts: 8
[script, Howto] Xbmc Starts With Video's Playing In Bg
« Reply #2 on: February 13, 2006, 02:04:00 AM »

QUOTE(JayDee @ Feb 13 2006, 09:29 AM) *

Moving to right forum...


Sorry about that, need to wake up (IMG:style_emoticons/default/sleeping.gif)
Logged

therockguy

  • Archived User
  • Newbie
  • *
  • Posts: 3
[script, Howto] Xbmc Starts With Video's Playing In Bg
« Reply #3 on: February 17, 2006, 10:07:00 PM »

This is the script i been lookin 4. All we need is that extra line of code to get it working good.

Good Luck.
Logged

mayto

  • Archived User
  • Newbie
  • *
  • Posts: 24
[script, Howto] Xbmc Starts With Video's Playing In Bg
« Reply #4 on: February 19, 2006, 05:01:00 PM »

im not sure what you mean by background of home screen but is it possible to have video in a small window (like in the HDEE script when you press X while watching a video). So for example for that skin, the music video would play in the bottom left of the screen when XBMC starts up. Anyways you should post your post in the xbmc forums if you havent already.
Logged