I think i'm going to tackle this one... You asked for the easiest way to launch XBMC... Well... Here is the easiest way. I'm not saying it is an easy way but it is the only way to run a movie (which is not in your library) and works with the jump to minutes (or seconds).
First you need to setup XBMC to autoexecute a script on startup. For this we need to create a file named autoexec.py
in %appdata%\XBMC\userdata
.
Normally this is C:\Users\<username>\AppData\Roaming\XBMC\userdata
.
Don't worry. You don't need to "learn" python for this. Just copy the code to that file.
Create autoexec.py
there:
import xbmc
import xbmcgui
import os
class Main:
def __init__(self):
playlist = xbmc.PlayList( xbmc.PLAYLIST_VIDEO )
playlist.clear()
try:
file = os.getenv('XBMC_PLAY','')
jump = os.getenv('XBMC_JUMP','0')
except:pass
if os.path.isfile(file):
xbmc.executebuiltin('Notification(Playing '+file+',Jump to '+jump+',5000)')
playlist.add(file)
try:
xbmc.Player().play( playlist)
except:pass
try:
xbmc.Player().seekTime(int(jump))
except:pass
m = Main()
I adjusted the script from here (thnx @root) and made it so it would check your environment variables for XBMC_PLAY
and XBMC_JUMP
. That way we can call XBMC from a batchfile and it is going to play the file.
Again don't worry. If these environment variables don't exists XBMC will work as normal.
Next we need to create the batchfile to set the correct values and run XBMC.
XBMC_PLAY
is your movie-file and XBMC_JUMP
are the seconds to jump in (it can be 0
).
The easiest would be:
set XBMC_PLAY=<YOUR_MOVIE>
set XBMC_JUMP=<SECONDS_TO_JUMP>
"C:\Program Files(x86)\XBMC\XBMC.exe"
set XBMC_PLAY=
set XBMC_JUMP=
But since i'm a perfectionist ;) i created a more elaborate batch which you can use to drop a file on and it will ask for the "jump minutes". It is also possible to call this batchfile like
xbmc_run moviefile.avi 15
directly.
You could even create a file association for .avi
etc... to run this batchfile instead of another player :)
Create xbmc_run.bat
@echo off
if "%1"=="" goto usage
if not exist %1 goto filenotfound
::-----------------------------------------------
:: set-up temp-variable for Program Files
::-----------------------------------------------
set ProgFiles86=%ProgramFiles(x86)%
if not "%ProgFiles86%"=="" goto win64
set ProgFiles86=%ProgramFiles%
:win64
::-----------------------------------------------
:: get %2 parameter. if not given ask for seconds
::-----------------------------------------------
set jump=%2
if "%jump%"=="" set /p jump="Jump to minute: "
set /a jump*=60
::-----------------------------------------------
:: set user-environment variables and start xbmc
::-----------------------------------------------
:play
set XBMC_PLAY=%1
set XBMC_JUMP=%jump%
echo Starting %XBMC_PLAY% and jump to %XBMC_JUMP% seconds
"%progFiles86%\XBMC\XBMC.exe"
set XBMC_PLAY=
set XBMC_JUMP=
goto :eof
:usage
echo Usage: %0 movie [jump]
exit/b 1
:filenotfound
echo File %1 not found
exit/b 1
It works perfectly here. I used XBMC v12.2 "FRODO". If you want help running it, let me know.
Edit: It just occurred to me that asking to jump in minutes might be more intuitive than seconds (as i did originally). So i changed the code above to ask the jump-minute and re-calculate to seconds for XBMC.
If you want the jump in seconds back you can change these 2 lines:
if "%jump%"=="" set /p jump="Jump to second: "
set /a jump*=1
Just drop a movie-file on this batch-file, enter the jump-minute (or just enter if none) and you're good to go :)