From e30e20104dece0fa7d40d7363518175c83c99a96 Mon Sep 17 00:00:00 2001
From: angelblue05 <tamara.angel05@gmail.com>
Date: Thu, 25 Feb 2016 17:46:12 -0600
Subject: [PATCH] Fix resume point

Move stop transcode and stop playback out of the currentposition,
runtime verification.
---
 resources/lib/player.py | 23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/resources/lib/player.py b/resources/lib/player.py
index 5eece2cc..2e648180 100644
--- a/resources/lib/player.py
+++ b/resources/lib/player.py
@@ -455,6 +455,9 @@ class Player(xbmc.Player):
                 type = data['Type']
                 playMethod = data['playmethod']
 
+                # Prevent manually mark as watched in Kodi monitor
+                utils.window('emby_skipWatched%s' % itemid, value="true")
+
                 if currentPosition and runtime:
                     try:
                         percentComplete = (currentPosition * 10000000) / int(runtime)
@@ -466,17 +469,6 @@ class Player(xbmc.Player):
                     log("Percent complete: %s Mark played at: %s"
                         % (percentComplete, markPlayedAt), 1)
 
-                    # Prevent manually mark as watched in Kodi monitor
-                    utils.window('emby_skipWatched%s' % itemid, value="true")
-
-                    self.stopPlayback(data)
-                    # Stop transcoding
-                    if playMethod == "Transcode":
-                        log("Transcoding for %s terminated." % itemid, 1)
-                        deviceId = self.clientInfo.getDeviceId()
-                        url = "{server}/emby/Videos/ActiveEncodings?DeviceId=%s" % deviceId
-                        doUtils(url, type="DELETE")
-
                     # Send the delete action to the server.
                     offerDelete = False
 
@@ -498,6 +490,15 @@ class Player(xbmc.Player):
                         url = "{server}/emby/Items/%s?format=json" % itemid
                         log("Deleting request: %s" % itemid, 1)
                         doUtils(url, type="DELETE")
+
+                self.stopPlayback(data)
+
+                # Stop transcoding
+                if playMethod == "Transcode":
+                    log("Transcoding for %s terminated." % itemid, 1)
+                    deviceId = self.clientInfo.getDeviceId()
+                    url = "{server}/emby/Videos/ActiveEncodings?DeviceId=%s" % deviceId
+                    doUtils(url, type="DELETE")
     
         self.played_info.clear()