Startup in background
#1
so i once had a script that made me start any playlist minimized but accidentally deleted it and the autoexec. can someone please help me get it back cause i can't find it anywere?
Image
Reply
#2
anyone please? :help:
Image
Reply
#3
hi.

check autostartmanager on xbmcscripts.com!
new version (1.6) will come the next days.
Reply
#4
correct me if im wrong but from my experience autostartmanager doesn't give me the option to start a video in the background (as in, minimized or like when you press "x" when a video is playing)
Image
Reply
#5
just add a xbmc.executebuiltin('xbmc.activatewindow(home)') after the call to start the video.

you may need the actual window id for home? and you may need a small sleep between the two.

from time import sleep
"the call to play the video"
sleep(.2)
xbmc.executebuiltin('xbmc.activatewindow(home)')
For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
Reply
#6
(incognegro @ june 13 2006,17:16 Wrote:correct me if im wrong but from my experience autostartmanager doesn't give me the option to start a video in the background
it does!
since 1.5 you have a settingsmenu for that.
Reply
#7
(nuka1195 @ june 13 2006,16:38 Wrote:just add a xbmc.executebuiltin('xbmc.activatewindow(home)') after the call to start the video.

you may need the actual window id for home? and you may need a small sleep between the two.

from time import sleep
"the call to play the video"
sleep(.2)
xbmc.executebuiltin('xbmc.activatewindow(home)')
im not good enough at python to know what your talking about, sorry Shocked

and i tried auto start and checked the "play in the background" option but it doesnt work. still plays in normally.
Image
Reply
#8
ok i figured i would attempt to edit ascript to my liking. i found this script:

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 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 = ['e:\\media\\musicvideos', 'f:\\media\\musicvideos']
# 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)

so can someone help me get it to starup in the background? what do i add to the code?
Image
Reply
#9
ok i added xbmc.executebuiltin('xbmc.activatewindow(home)') at the end and it did what i wanted but one problem.........when it changes videos iut swtches back to full screen.......now i really need help cause i dunno what to do rom here at all :help:
Image
Reply
#10
:help:
Image
Reply
#11
i'll test how the onplayback events work. i'm not sure if they execute on a change of media or not.

if they don't then maybe an onplaybackchange event could be added?

you could thread a while loop that compares the currently playing media and see if it's changed. kinda sloppy.
For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
Reply
#12
(nuka1195 @ june 16 2006,05:32 Wrote:i'll test how the onplayback events work. i'm not sure if they execute on a change of media or not.

if they don't then maybe an onplaybackchange event could be added?

you could thread a while loop that compares the currently playing media and see if it's changed. kinda sloppy.
thanx, i dont understand some of what your saying but i kinda get it. any help appreciated. :o :kickass:
Image
Reply
#13
ok, the good news is onplaybackstarted() fires everytime a new song is played.

try this, if it does not minimize the video the first time you may have to add the activatewindow line just after the play line.

let me know. keep in mind if you change windows when the media changes it will take you back to the home window.

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:\\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 = ['e:\\media\\musicvideos', 'f:\\media\\musicvideos']
# 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):
       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 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)



For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
Reply
#14
did u get it working on ur xbmc? cause i just get "running" for a quick second and it disappears and thats it :tear:



Image
Reply
#15
ah the missing --init--.

http://www.filefactory.com/get....9441892

i changed the file location at the top to work with mine and fixed an indentation error, but yes it works.

if the timing is right and you have your webserver running. you might be able to use:
Quote:response = xbmc.executehttpapi("sendkey(275)")
instead of the activatewindow() call. just replace 275 with the right code for minimizing videos (look in key.h). this way you won't jump to home if your somewhere else.
For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
Reply

Logout Mark Read Team Forum Stats Members Help
Startup in background0