Is it possible to do something when a video "stops" or "ends"?

  Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Post Reply
Jezz_X Offline
Team-XBMC Skinner
Posts: 5,264
Joined: Jun 2006
Reputation: 55
Location: Earth
Post: #41
(2012-06-02 06:35)vikjon0 Wrote:  I have done some tests and the playCount and percentagePlayed are not updated on return to MyVideoNav.
and isResumable always returns an empty string.

Indeed there is currently a issue with it even in the latest git source where they only get updated on a list contents refresh which doesn't happen because the dir gets cached 99.8% of the time so its a far from reliable method to use nd its even worse in the files node where it randomly changes other files watched status

Skins I have done....
[Image: skinsq.png]
And others in the past...

Want to know what I'm working on currently? Check me out on Google+
find quote
vikjon0 Offline
---
Posts: 2,429
Joined: Apr 2009
Reputation: 7
Location: Sweden
Post: #42
Thanks Jezz_X, I was this very minute pulling my hair out because for the moment it is working perfectly.
Would Container.Refresh help at all? If so, any idea how I can get it to cache again so I can test? (I have tested 25 times)

It is also worth noting that percentagePlayed perhaps goes from 0-100 as stated, but it also return to 0 when done.
find quote
snavaro Offline
Member
Posts: 81
Joined: Mar 2012
Reputation: 0
Post: #43
That is good information to know. It would be helpful if those functions worked properly, but that is way over my head.
find quote
phil65 Offline
Skilled Skinner
Posts: 4,456
Joined: Mar 2009
Reputation: 56
Location: Cologne, Germany
Post: #44
EDIT: was wrong, sorry.
(This post was last modified: 2012-06-06 13:21 by phil65.)
find quote
datalore44 Offline
Junior Member
Posts: 9
Joined: Jun 2012
Reputation: 0
Post: #45
Hi. Has anyone managed to get this working yet?
I tried Snavaro`s code and all it did was to lock up!
Could not a separate script be made that could give you the delete option after you press stop?
find quote
snavaro Offline
Member
Posts: 81
Joined: Mar 2012
Reputation: 0
Post: #46
(2012-06-19 02:15)datalore44 Wrote:  Hi. Has anyone managed to get this working yet?
I tried Snavaro`s code and all it did was to lock up!
Could not a separate script be made that could give you the delete option after you press stop?

Hi datalore,

I have been working on the lockup issues. Several things apparently come into play. First, there is no way currently to determine when the CleanLibrary function is finished, and apparently if the Container is Refreshed while cleaning is in progress.. it just locks up. To solve that issue, I have moved the PreviousMenu and Container.Refresh commands ahead of the Cleaning function. That way,I did not have to worry about setting sleep delays that varied by computer speed, library size etc.
From what I have learned, monitoring the Clean function will be possible in Frodo, as it has been implemented in the recent builds via Library.IsScanningVideo.
Here is my updated code. Try it and let me know what other bugs there are.
Code:
import xbmc, xbmcgui, os,  sys
import xbmcvfs
import ntpath

file = xbmc.getInfoLabel( "ListItem.FilenameAndPath" )
title1 = xbmc.getInfoLabel( "ListItem.TVShowTitle" )
title2 = xbmc.getInfoLabel( "ListItem.Title" )
#either title1 or title2 will be a null string
title = title1 + title2
print "file = " + file
filename = ntpath.basename(file)
filename1, ext = os.path.splitext(filename)
# for future development to delete ancillary files
file1 = filename1 + ".nfo" #...same filename different extension
file2 = filename1 + ".tbn"

if title == title1:
    category = "TvShowTitles"
else:
    category = "MovieTitles"
#------------above category code not needed for now----------

if (not xbmc.abortRequested):
    if xbmcvfs.exists(file):
        xbmcvfs.delete(file)
        #comment out above line for testing...remove comment hash to implement
        print "Deleting " + file  #for debugging only ..can be deleted
        xbmc.executebuiltin("XBMC.Notification(%s, %s, %i)" % ('Deleting File',filename + ' is being deleted.',4000)) # Screen notification of file deletion process
        xbmc.sleep(4000)
    else:
        print "File does not exist!"
        xbmc.executebuiltin("XBMC.Notification(%s, %s, %i)" % ('File Not Found',filename + ' not found in database!',4000))

# Check for deletion process to finish before cleaning.
while (xbmcvfs.exists(file) and not xbmc.abortRequested):
    xbmc.sleep(3000)
    print "File deletion not yet complete..."


# Check if the library is being updated before cleaning up
while (xbmc.getCondVisibility("Library.IsScanningVideo")):
    xbmc.sleep(5000)
    xbmc.executebuiltin("Notification(Library Scan in Progress,Waiting Until Library Scan Completes...,5000)")
    
if (not xbmcvfs.exists(file)):
    print "File has been deleted."
    # refresh display
    xbmc.executebuiltin("xbmc.action(PreviousMenu)")
    xbmc.sleep(1000)
    xbmc.executebuiltin("Container.Refresh")
    
    xbmc.executebuiltin("XBMC.CleanLibrary(video)")
    print "Cleaning library"
    
    # The following will only work in Eden 12.0
    #while (xbmc.getCondVisibility('Library.IsScanningVideo')) : #wait while CleanLibrary finishes
    #    xbmc.sleep(5000)
Hope this helps.
find quote
datalore44 Offline
Junior Member
Posts: 9
Joined: Jun 2012
Reputation: 0
Post: #47
Great stuff I will try it and let you know.
Will this code work on any skin?
find quote
snavaro Offline
Member
Posts: 81
Joined: Mar 2012
Reputation: 0
Post: #48
(2012-06-19 20:58)datalore44 Wrote:  Great stuff I will try it and let you know.
Will this code work on any skin?

I am not sure. I have only tried it on the default Confluence skin. I presume that you were able to create a Delete button in DialogVideoInfo.xml and run the script from there. If you need help let me know.
find quote
datalore44 Offline
Junior Member
Posts: 9
Joined: Jun 2012
Reputation: 0
Post: #49
(2012-06-19 21:55)snavaro Wrote:  
(2012-06-19 20:58)datalore44 Wrote:  Great stuff I will try it and let you know.
Will this code work on any skin?

I am not sure. I have only tried it on the default Confluence skin. I presume that you were able to create a Delete button in DialogVideoInfo.xml and run the script from there. If you need help let me know.


Hmmm. I will be needing your help with the delete button. I know nothing about coding for xbmc, I am just a computer engineer.
When I ran the first code you posted, the delete button appeared in the settings menu once. When I restarted xbmc it was no longer there!
That is why i think it would have been nice to have a standalone script, that could be applied to any skin. But I realise that it cannot be done because each skin has its own individual folders and .xml files.
Where does the new code you wrote go, and do I still use any of the old code you wrote?

Looking at your old code, am I right in thinking that this:
In MyVideoNav add the following after line 5:
<onload condition="Window.Previous(FullScreenVideo) + Skin.HasSetting(DeleteEps)">Delete</onload>
Was the delete function.
And the coding that went into Custom Settings_1111 was the creation of the button to enable it?
I am sorry for my ignorance, but I am fascinated by the inner workings of the skin coding.
(This post was last modified: 2012-06-20 00:05 by datalore44.)
find quote
snavaro Offline
Member
Posts: 81
Joined: Mar 2012
Reputation: 0
Post: #50
No problem. Here is what I did, step by step.
To add the option to delete shows after watching, add this code to CustomSettings_111.xml at about line 296:
Code:
<!--deleteafterwatching-->
                    <control type="radiobutton" id="2003">
                    <width>750</width>
                    <height>40</height>
                    <font>font13</font>
                    <textcolor>grey2</textcolor>
                    <focusedcolor>white</focusedcolor>
                    <texturefocus>MenuItemFO.png</texturefocus>
                    <texturenofocus>MenuItemNF.png</texturenofocus>
                    <label>Enable DELETE After Watching TV Episodes</label>
                    <onclick>Skin.ToggleSetting(DeleteEps)</onclick>
                    <selected>Skin.HasSetting(DeleteEps)</selected>
                    <include>button_Settings</include>
                    </control>
In DialogVideoInfo.xml search for this line: <control type="togglebutton" id="8"> or the words "Play/Browse" These will be the buttons that show up as "Play" Refresh Cast Trailer etc. Add a new button control for the Delete button as follows:
Code:
<control type="button" id="7"><!--new button control to Delete program-->
                        <description>Delete</description>
                        <include>ButtonInfoDialogsCommonValues</include>
                        <label>184</label><!--label changed to read "Delete" in strings.xml file--->
                        <onclick>xbmc.RunScript(special://skin/scripts/deletefile.py)</onclick>
                        <visible>Skin.HasSetting(DeleteEps)</visible> <!--button is visible only through Settings-->
                    </control>
You can either comment out the Refresh button control so it does not appear or leave it on, your choice. Put the Delete button control code directly after the Refresh button control or in place of it.

You will notice in the above code that label 184 will show on the Delete control. Find string.xml in the confluence/language/English folder for XBMC. Search for label 184 and replace the text (which I think is the word "Refresh" with the word Delete.
make a new folder called scripts under the confluence skin folder (but not in the 720p folder). Place the script (which I named deletefile.py) in that folder.
Restart XBMC and you should be good to go.Don't forget to go into Settings/Video and enable the Delete After Watching option. That is the only way that the Delete button will appear for you.
find quote
Post Reply