What is the easiest way to launch XBMC and play a movie from a certain timepoint?

Apparently there aren't many command line options (ref), and the XBMC python scripts seem to be designed to run from within XBMC, once it is launched (ref). Also, I want to be able to play files that are not necessarily in the XBMC media library.

  • Are you looking to launch into the movie at a known time? Or do you want to resume playing the movie from where you last left off? I'm positive XBMC can resume playing a file from the last known time marker, which may be a good clue to persue.
    – root
    Nov 21 '13 at 20:30
  • This looks like a potential solution if you have a known time: "To seek video to a particular point , add the line - xbmc.Player.seekTime(int sec) " Source: assembla.com/wiki/show/oniontv-plugin/…
    – root
    Nov 21 '13 at 20:33
  • @root Don't post answers in the comments. Nov 26 '13 at 18:42
  • @DanteTheEgregore root said "it looks like..." so he is not sure and he didn't expand on his comment to a working solution so i don't think it should be an answer. (at least it wouldn't be a worthy answer without it working in my opinion, and i think, would it be an answer, he would have gotten comments as to it not being complete/working... please expand... etc...)
    – Rik
    Nov 27 '13 at 0:34
  • Since the answer drew more questions that I don't know the answer to, I retract the answer. Though, I think that @root had something there that should have been an answer.
    – killermist
    Nov 29 '13 at 23:29

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 )

      file = os.getenv('XBMC_PLAY','')
      jump = os.getenv('XBMC_JUMP','0')
    if os.path.isfile(file):

      xbmc.executebuiltin('Notification(Playing '+file+',Jump to '+jump+',5000)')

        xbmc.Player().play( playlist)


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:

"C:\Program Files(x86)\XBMC\XBMC.exe"

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%

:: 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
set XBMC_PLAY=%1
set XBMC_JUMP=%jump%
echo Starting %XBMC_PLAY% and jump to %XBMC_JUMP% seconds
goto :eof

echo Usage: %0 movie [jump]
exit/b 1

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

  • I don't use windoze, so I can't verify the functionality of your answer, but it is more comprehensive than the bit I got from root's comment, so I'm +1'ing as it all looks like it makes sense.
    – killermist
    Dec 1 '13 at 0:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.