2006-06-11, 14:34
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?
(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 backgroundit does!
(nuka1195 @ june 13 2006,16:38 Wrote:just add a xbmc.executebuiltin('xbmc.activatewindow(home)') after the call to start the video.im not good enough at python to know what your talking about, sorry
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)')
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)
(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.thanx, i dont understand some of what your saying but i kinda get it. any help appreciated. :o :kickass:
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.
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)
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.