Startup in background
#16
dude i tried the file u posted and it did the samething.........whenever i change videos it goes back to full screen. am i doing something wrong?
Image
Reply
#17
i really should fully test things with the same media. it works fine with music (paplayer).

what's happening with video (mplayer) is the onplaybackended is being fired with every change.

try changing that event to this.

Quote: def onplaybackended(self):
pass
For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
Reply
#18
man i have no luck with this thing (u must be annoyed by now)

ok here is what i did
Quote:''' vim: ts=8 sw=4 noexpandtab
by: antibiotek ver: 0.1
original script by rune hammersland ver: 0.3

this script is for those of you who love to turn on your xbox and watch music
vidoes in the morning. it will take a playlist or a music video directory,
randomize all the videos, and play them. be sure to modify your autoexec.py
to start it up!
'''

import time
import os

# ---------------------------------------- #
# "configuration"
# ---------------------------------------- #

# change this to your playlist(s).
# written like this: ['path\\to\\plist1', 'to\\plist2', 'plist\\3']
playlist_files= ['e:\\apps\\xbmc\\userdata\\playlists\\test.m3u', 'f:\\all.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 = ['g:\\video\\musicvidz', 'g:\\video\\musicvids']
# shuffle playlist if this var equals 1.
shuffle_files = 1
player_playing = true


# ---------------------------------------- #
# code
# ---------------------------------------- #

# function for adding files to playlist
class myplayer( xbmc.player ) : # thanks thor918 for this class
def ( self ):
xbmc.player.( self )# initialize xbmc.player as a baseclass of our class

def onplaybackstopped(self):
global player_playing
player_playing = false

def onplaybackended(self):
pass
global player_playing
player_playing = false

def onplaybackstarted(self):
xbmc.executebuiltin('xbmc.activatewindow(home)')

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 (filename[-4:] == ".mp4"): 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()

cplayer = myplayer()
xbmc.player().play(plist)
while player_playing:
time.sleep(.1)

it won't execute. try reviewing this script and see whats wrong.



Image
Reply
#19
get rid of everything below the pass in the onplaybackended definition and make sure your tabs are right.

the tabbing looks off in your post.

Quote: def onplaybackended(self):
pass
For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
Reply
#20
so ur saying i should do this? sorry im at work and can't test it so let me know if this is ok


[code]''' vim: ts=8 sw=4 noexpandtab
by: antibiotek ver: 0.1
original script by rune hammersland ver: 0.3

this script is for those of you who love to turn on your xbox and watch music
vidoes in the morning. it will take a playlist or a music video directory,
randomize all the videos, and play them. be sure to modify your autoexec.py
to start it up!
'''

import time
import os

# ---------------------------------------- #
# "configuration"
# ---------------------------------------- #

# change this to your playlist(s).
# written like this: ['path\\to\\plist1', 'to\\plist2', 'plist\\3']
playlist_files= ['e:\\apps\\xbmc\\userdata\\playlists\\test.m3u', 'f:\\all.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 = ['g:\\video\\musicvidz', 'g:\\video\\musicvids']
# shuffle playlist if this var equals 1.
shuffle_files = 1
player_playing = true


# ---------------------------------------- #
# code
# ---------------------------------------- #

# function for adding files to playlist
class myplayer( xbmc.player ) : # thanks thor918 for this class
def ( self ):
xbmc.player.( self )# initialize xbmc.player as a baseclass of our class

def onplaybackstopped(self):
global player_playing
player_playing = false

def onplaybackended(self):
pass

def onplaybackstarted(self):
xbmc.executebuiltin('xbmc.activatewindow(home)')

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 (filename[-4:] == ".mp4"): 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()

cplayer = myplayer()
xbmc.player().play(plist)
while player_playing:
time.sleep(.1)
Image
Reply
#21
so ur saying i should do this? sorry im at work and can't test it so let me know if this is ok


Quote:''' vim: ts=8 sw=4 noexpandtab
by: antibiotek ver: 0.1
original script by rune hammersland ver: 0.3

this script is for those of you who love to turn on your xbox and watch music
vidoes in the morning. it will take a playlist or a music video directory,
randomize all the videos, and play them. be sure to modify your autoexec.py
to start it up!
'''

import time
import os

# ---------------------------------------- #
# "configuration"
# ---------------------------------------- #

# change this to your playlist(s).
# written like this: ['path\\to\\plist1', 'to\\plist2', 'plist\\3']
playlist_files= ['e:\\apps\\xbmc\\userdata\\playlists\\test.m3u', 'f:\\all.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 = ['g:\\video\\musicvidz', 'g:\\video\\musicvids']
# shuffle playlist if this var equals 1.
shuffle_files = 1
player_playing = true


# ---------------------------------------- #
# code
# ---------------------------------------- #

# function for adding files to playlist
class myplayer( xbmc.player ) : # thanks thor918 for this class
def ( self ):
xbmc.player.( self )# initialize xbmc.player as a baseclass of our class

def onplaybackstopped(self):
global player_playing
player_playing = false

def onplaybackended(self):
pass

def onplaybackstarted(self):
xbmc.executebuiltin('xbmc.activatewindow(home)')

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 (filename[-4:] == ".mp4"): 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()

cplayer = myplayer()
xbmc.player().play(plist)
while player_playing:
time.sleep(.1)
Image
Reply
#22
yes, and remember this forum doesn't display --init--, so make sure you not just copying from here.
For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
Reply
#23
:o :thumbsup: :bowdown:

thanx alot.....that did it. thanx for your work, time and most of all, patience.

:kickass:

now i can finally finish my xbmc360 mod. i cuyrrently got the blades to go fully transparent when ever a video is playing in the background. thanx again. :d
Image
Reply
#24
no problem.

if you have a newer build you can replace the activatewindow with the following. you can use this on older builds, you'll just have to have the webserver running.

nad changed it so you don't need the webserver running to use sendkey in newer builds. Smile

Quote:response = xbmc.executehttpapi("sendkey(258)")

what it does is send the (x) buttons code (switch gui). this would allow you to navigate around without it going back to the home screen. i haven't played with it too much so it may need a sleep command first.
For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
Reply
#25
Man this is also driving me mad. I can't seem to get it to work. I'm using a new 2.0 build. I have a copy of the normal script that works but I want it to start in the background

What does Nuka1195 mean by "--init--"? Ive changed the code so many times and still no luck can anyone help me?

Cheers
Reply
#26
The old forum __init__ wouldn't display. I can't gurantee this works.

Code:
''' vim: ts=8 sw=4 noexpandtab
by: antibiotek ver: 0.1
original script by rune hammersland ver: 0.3
this script is for those of you who love to turn on your xbox and watch music
vidoes in the morning. it will take a playlist or a music video directory,
randomize all the videos, and play them. be sure to modify your autoexec.py
to start it up!
'''
import time
import os
# ---------------------------------------- #
# "configuration"
# ---------------------------------------- #
# change this to your playlist(s).
# written like this: ['path\\to\\plist1', 'to\\plist2', 'plist\\3']
playlist_files= ['e:\\apps\\xbmc\\userdata\\playlists\\test.m3u ', 'f:\\all.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 = ['g:\\video\\musicvidz', 'g:\\video\\musicvids']
# shuffle playlist if this var equals 1.
shuffle_files = 1
player_playing = true

# ---------------------------------------- #
# code
# ---------------------------------------- #
# function for adding files to playlist
class myplayer( xbmc.Player ) : # thanks thor918 for this class
    def __init__( self ):
        xbmc.Player.__init__( self )# initialize xbmc.player as a baseclass of our class
    def onplaybackstopped(self):
        global player_playing
        player_playing = False
    def onplaybackended(self):
        pass
    def onplaybackstarted(self):
        xbmc.executebuiltin('xbmc.activatewindow(home)')

def add_files(pl, dirname, names):
    for filename in names:
        add = 0
        if (os.path.isfile(dirname + "\\" + filename)):
            # 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 (filename[-4:] == ".mp4"): 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()
cplayer = myplayer()
cplayer.play(plist)
while player_playing:
    time.sleep(.1)
Reply
#27
Thanks for that...

Its seems to like it bar the "player_playing = true"

any ideas?
Reply
#28
Heres are far as I can get. It loads ok and starts to play in full screen but when I add "player_playing = true" to the configuration it wont load :confused2:

Code:
''' vim: ts=8 sw=4 noexpandtab
By: aNtiBiOteK ver: 0.1
Original Script by Rune Hammersland ver: 0.3

This script is for those of you who love to turn on your xbox and watch music
vidoes in the morning.  It will take a playlist or a music video directory,
randomize all the videos, and play them.  Be sure to modify your autoexec.py
to start it up!

'''

import xbmc
import os

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

# Change this to your playlist(s).
# Written like this: ['path\\to\\plist1', 'to\\plist2', 'plist\\3']
playlist_files= ['E:\\Media\\Music\\playlist.m3u', 'F:\\all.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 = ['F:\\Music Videos']
# Shuffle playlist if this var equals 1.

shuffle_files = 1

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

# Function for adding files to playlist

class myplayer( xbmc.Player ) : # thanks thor918 for this class
    def __init__( self ):
        xbmc.Player.__init__( self )# initialize xbmc.player as a baseclass of our class
    def onplaybackstopped(self):
        global player_playing
        player_playing = False
    def onplaybackended(self):
        pass
    def onplaybackstarted(self):
        xbmc.executebuiltin('xbmc.activatewindow(home)')

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()

cplayer = myplayer()
cplayer.play(plist)
while player_playing:
    time.sleep(.1)
Reply
#29
True
Reply

Logout Mark Read Team Forum Stats Members Help
Startup in background0