Resume last played movie

  Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Post Reply
ezd Offline
Junior Member
Posts: 40
Joined: Oct 2003
Reputation: 0
Smile  Resume last played movie Post: #1
Hi folks,

As I often watch bits of a movie over several days, I was getting tired of sifting to my directory structure to find that last movie- what was its title again?

I've now made two scripts to solve that- one is mapped to the stop button and saves filename and position, the other one (started from the menu) resumes that file. Simple but effective.

Hope this will help out others as lazy as I am! Wink

ezd


savelast.py
Code:
# SaveLast script 1.0 by ezd

# Saves last played movie name and pos to instantly resume without browsing for the file.
# Add the <stop> tag to the full-screen video part of keymap.xml:

# In <FullscreenVideo>, part <remote>:

#      <stop>XBMC.RunScript(Q:\Scripts\savelast.py)</stop>

import xbmc

fn = xbmc.Player().getPlayingFile()
t=xbmc.Player().getTime()

f = open('Q:\\scripts\\last.txt', 'w')
f.write(fn+'|'+str(t))
f.close()

xbmc.Player().stop()

playlast.py
Code:
# PlayLast script 1.0 by ezd

# Resumes last played movie instantly from reading savelast's last.txt.

# Many possible ways to start this script, for example by using the
# Submenu Editor within the scripts folder, or mapping a key. RTFM :)

# To resume gently, the -5 below sets the time 5 secs before the stopping time.

import xbmc

f = open('Q:\\scripts\\last.txt', 'r')
fn,p = f.readline().split('|')
f.close()

pl=xbmc.Player()
pl.play(fn)
pl.seekTime(float(p)-5)
find quote
Rockstarr Offline
Skilled Python Coder
Posts: 78
Joined: Mar 2006
Reputation: 0
Location: Leipzig, Germany
Post: #2
Hi.

Nice idea.
But isnt there already a xbmc function what is doing this?
find quote
kwkard Offline
Junior Member
Posts: 8
Joined: Dec 2006
Reputation: 0
Post: #3
Wow, this is great! I'm trying to adapt your code to suit my needs. I want to be able to do this type of thing with audio and playlists. One song, will work, but not the whole playlist.

Is there a function to return the playlist? And when you play a playlist, can you start from a specific location, eg song #6?
find quote
Nuka1195 Offline
Skilled Python Coder
Posts: 3,917
Joined: Dec 2004
Reputation: 17
Post: #4
http://home.no.net/thor918/xbmc/xbmc.html
find quote
kwkard Offline
Junior Member
Posts: 8
Joined: Dec 2006
Reputation: 0
Post: #5
Thanks for the link, I used xbmc.Playlist(0).getPosition() to retrieve the position of the song, but when I load that playlist later, how do I start playback at that position? I'm new to python, but I use vbscript a lot. Just trying to learn another language.
find quote
kraqh3d Offline
Retired Developer
Posts: 7,183
Joined: Dec 2003
Reputation: 4
Location: New York City, USA
Post: #6
player.playselected(position)

Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.
find quote
Livin Offline
Posting Freak
Posts: 3,432
Joined: May 2004
Reputation: 17
Location: above ground
Post: #7
Ideally this should not be a script but a native XBMC function... i.e. button on the Videos screen ("Resume Last")!

I'd think this would be easy for a dev like Kraqh3d to do... since he is one of the masters Big Grin

I'm not an expert but I play one at work.
find quote
ezd Offline
Junior Member
Posts: 40
Joined: Oct 2003
Reputation: 0
Post: #8
Sorry for the late reply, threat notifications went to the wrong address so...

Rockstarr, a movie you select will resume, but XBMC won't select the movie for you Smile

At first I was also thinking it'd be best to make this a native XBMC function, but this being in a script has its advantages- perhaps a default link within the skin to the script to hack away at?

For example, my GF and I sometimes watch movies the other isn't interested in, so now I've copied the script 3 times (mapping to 3 different stop buttons) to let us easily resume our own movies as well as the 'together' movie Big Grin.

Also, she doesn't want the Xbox to resume any movies from any movies in the 'Fitness' folder she may play in between watching the movie, so I've created an exception rule which doesn't save said movie positions.

XBMC and scripting/open(ed) platforms are cool. I pity the fool who bought a closed system! Wink
find quote