SageTV Community  

Go Back   SageTV Community > SageTV Development and Customizations > SageTV Github Development
Forum Rules FAQs Community Downloads Today's Posts Search

Notices

SageTV Github Development Discussion related to SageTV Open Source Development. Use this forum for development topics about the Open Source versions of SageTV, hosted on Github.

Reply
 
Thread Tools Search this Thread Display Modes
  #21  
Old 08-28-2018, 08:47 AM
wnjj wnjj is offline
Sage Icon
 
Join Date: Jan 2009
Posts: 1,514
Quote:
Originally Posted by davidb View Post
The api doesn't need to be extended for this to work. The titlenum is only for when you are watching on Sage.

The SetWatchedTimes was added in SageTV V7.0.13 Beta 8/4/2010 with the comment:
"Added Airing API call SetWatchedTimes(Airing, WatchedEndTime, RealStartTime) which can be used to set explicitly what the last watched time is for an Airing. Useful if viewing is done outside of the regular SageTV media players (i.e. web clients)."

If anyone is lurking and didn't read the whole thread. I have added issue: 384 on github.

David
Then I am completely misunderstanding your needs. From the very beginning I thought the issue was that you wanted your client to save the latest watched position so that you could resume watching it. To do that you need to write the current title number into the wiz.bin DB. There is no API that does that today even though there is an underlying BigBrother function that does. The API you are referring to maybe was ideally supposed to do that but doesn’t. So either that one needs a new parameter or a new API is needed. Without that you cannot update the title field. What else am I missing here? I doubt you’ll get much of a response on GitHub.

If you’d like a JAR with that functionality added to try, I could build you one, though I’m heading on a 5 day vacation tomorrow.
Reply With Quote
  #22  
Old 08-28-2018, 08:56 AM
davidb's Avatar
davidb davidb is offline
Sage Advanced User
 
Join Date: Feb 2009
Posts: 134
Yes I am wanting to save the watched position to be able to resume in Sage. The watching will be not through the stv but on an iPhone or Apple TV. Ultimately I would like to be able to start watching at home on the hd-300 then later pick back up at the same spot on my iPhone and possible continue when I get back home on the hd-300. My understanding was the api function SetWatchedTimes would do set the watched position for this. It half works in that it works for recordings. The titlenum doesn't make sense when you are not watching on the stv or an extender. That is why the existing api code is using 0 for the title number.

Sure I could use a JAR with that functionality but ultimately the code should go in the api function for it.

David

Quote:
Originally Posted by wnjj View Post
Then I am completely misunderstanding your needs. From the very beginning I thought the issue was that you wanted your client to save the latest watched position so that you could resume watching it. To do that you need to write the current title number into the wiz.bin DB. There is no API that does that today even though there is an underlying BigBrother function that does. The API you are referring to maybe was ideally supposed to do that but doesn’t. So either that one needs a new parameter or a new API is needed. Without that you cannot update the title field. What else am I missing here? I doubt you’ll get much of a response on GitHub.

If you’d like a JAR with that functionality added to try, I could build you one, though I’m heading on a 5 day vacation tomorrow.

Last edited by davidb; 08-28-2018 at 08:59 AM.
Reply With Quote
  #23  
Old 08-28-2018, 09:04 AM
wnjj wnjj is offline
Sage Icon
 
Join Date: Jan 2009
Posts: 1,514
Quote:
Originally Posted by davidb View Post
Yes I am wanting to save the watched position to be able to resume in Sage. The watching will be not through the stv but on an iPhone or Apple TV. Ultimately I would like to be able to start watching at home on the hd-300 then later pick back up at the same spot on my iPhone and possible continue when I get back home on the hd-300. My understanding was the api function SetWatchedTimes would do set the watched position for this. It half works in that it works for recordings. The titlenum doesn't make sense when you are not watching on the stv or an extender. That is why the existing api code is using 0 for the title number.

David
But you just said, “when I get back home on the had-300.” That IS watching on the extender. The code that resumes there (in Sage) needs title to be correct to do that.

Does watching on IOS after leaving Sage work ok or are both directions currently broken? I assume you can resume where you want to on IOS since the problem you’re dealing with is setting the watched time afterwards.

Best of luck to you. I cannot suggest anything further.
Reply With Quote
  #24  
Old 08-28-2018, 09:13 AM
davidb's Avatar
davidb davidb is offline
Sage Advanced User
 
Join Date: Feb 2009
Posts: 134
From IOS I can resume watching where I left off on the hd-300. I can also use the SetWatchedTimes call to set the position last watched for a recording. I can then continue watching on the hd-300 at the last spot on watched on my iPhone. This works great for a recording but not for a dvd rip.

I do have the mediaID if you have a way to use it to the titleNum from it.

David

Quote:
Originally Posted by wnjj View Post
But you just said, “when I get back home on the had-300.” That IS watching on the extender. The code that resumes there (in Sage) needs title to be correct to do that.

Does watching on IOS after leaving Sage work ok or are both directions currently broken? I assume you can resume where you want to on IOS since the problem you’re dealing with is setting the watched time afterwards.

Best of luck to you. I cannot suggest anything further.
Reply With Quote
  #25  
Old 08-28-2018, 09:38 AM
wnjj wnjj is offline
Sage Icon
 
Join Date: Jan 2009
Posts: 1,514
Your IOS player needs to determine which title number it was last playing. Do you have a way to do that? Then the API needs fixed/amended/augmented with one that accepts titlenum and saves it into wiz.bin.

Here’s the DVD playback code in VideoFrame.java that uses that wiz.bin information to resume payback. Notice the filter for “bad watched info” that checks the titlenum? That’s what is getting you when you use the current API for DVDs.

Code:
      if (watchMe.isDVD() || watchMe.isBluRay())
          {
            dvdResumeTarget = Wizard.getInstance().getWatch(watchMe.getContentAiring());
            if (dvdResumeTarget != null && dvdResumeTarget.getTitleNum() == 0)
            {
              // bad watched info from 7.0.13/14
              dvdResumeTarget = null;
            }
Reply With Quote
  #26  
Old 08-28-2018, 09:50 AM
davidb's Avatar
davidb davidb is offline
Sage Advanced User
 
Join Date: Feb 2009
Posts: 134
In the VideoFrame.java is the call to dvdResumeTarget.getTitleNum() really needed? In the sample code earlier in this thread there is a print statement that is showing the WatchedTime is actually being set as it prints correctly. So I would assume the
Code:
            dvdResumeTarget = Wizard.getInstance().getWatch(watchMe.getContentAiring());
is getting the position to resume playback
Or is there another way to get the titlenum into the wiz.bin?

Thanks!
David


Quote:
Originally Posted by wnjj View Post
Your IOS player needs to determine which title number it was last playing. Do you have a way to do that? Then the API needs fixed/amended/augmented with one that accepts titlenum and saves it into wiz.bin.

Here’s the DVD playback code in VideoFrame.java that uses that wiz.bin information to resume payback. Notice the filter for “bad watched info” that checks the titlenum? That’s what is getting you when you use the current API for DVDs.

Code:
      if (watchMe.isDVD() || watchMe.isBluRay())
          {
            dvdResumeTarget = Wizard.getInstance().getWatch(watchMe.getContentAiring());
            if (dvdResumeTarget != null && dvdResumeTarget.getTitleNum() == 0)
            {
              // bad watched info from 7.0.13/14
              dvdResumeTarget = null;
            }
Reply With Quote
  #27  
Old 08-28-2018, 10:39 AM
wnjj wnjj is offline
Sage Icon
 
Join Date: Jan 2009
Posts: 1,514
Quote:
Originally Posted by davidb View Post
In the VideoFrame.java is the call to dvdResumeTarget.getTitleNum() really needed? In the sample code earlier in this thread there is a print statement that is showing the WatchedTime is actually being set as it prints correctly. So I would assume the
Code:
            dvdResumeTarget = Wizard.getInstance().getWatch(watchMe.getContentAiring());
is getting the position to resume playback
Or is there another way to get the titlenum into the wiz.bin?

Thanks!
David

Yes, Wizard.getWatch() returns a 'Watched' object. The Watched object contains the watched times, duration and the titlenum (for DVD's) where something was last watched. These watched objects are stored in wiz.bin. When your IOS player is done playing its section of the DVD, your IOS app needs to figure out what the title is currently at and then save it back to Sage along with the watched time. In other words, watched time alone isn't enough information for DVD's.

The DVD playback code in VideoFrame.java sets the title using this information:
Code:
              dplayer.playControlEx(DVD_CONTROL_TITLE_SET, dvdResumeTarget.getTitleNum(), dvdResumeTarget.getTitleNum());
So again, you need to know what title you last finished watching on IOS, push that titlenum back to wiz.bin using an API that isn't supported yet. Then extenders, server and Windows clients can use that information to seek to the correct title and time.

When I looked through the code, the only things I found that can set the titlenum are VideoFrame.logFileWatch():
Code:
            if (Sage.DBG) System.out.println("Setting DVD watched info for " + currFile + " title=" + getDVDTitle() + " Time=" + theTime);
            BigBrother.setWatched(doneAir, 0, theTime, realWatchStart, Sage.time(), getDVDTitle(), false);
and the client/server code in SageTVConnection.recvSetWatch():
Code:
        BigBrother.setWatched(theAir, airStart, airEnd, realStart, realEnd, titleNum, false);

The API is missing that ability and that is a bug/missing feature.

Last edited by wnjj; 08-28-2018 at 10:44 AM.
Reply With Quote
  #28  
Old 08-28-2018, 11:06 AM
wnjj wnjj is offline
Sage Icon
 
Join Date: Jan 2009
Posts: 1,514
Here's 9.1.9 jar file with an added API if you want to try it out:

https://www.dropbox.com/s/f2d3rnwszg...dTimesDVD?dl=0

I created "SetWatchedTimesDVD" that works like the original "SetWatchedTimes" but also takes an integer for the title number after "RealStartTime".

Code:
    rft.put(new PredefinedJEPFunction("Airing", "SetWatchedTimesDVD", 4, new String[] { "Airing", "WatchedEndTime", "RealStartTime", "TitleNum" }, true)
    {
      /**
       * Updates the Watched information for this airing, including the DVD titlenum. The AiringEndTime should be an airing-relative time which indicates the time the
       * user has watched the show up until. The new watched end time will be the maximum of this value and the current watched end time. The
       * RealStartTime is the time (in real time) the user started watching this program at. Internally SageTV will set the start time of the watched
       * data to be the minimum of the recording start time and the airing start time; and the 'real' end time to be the current time.
       * @param Airing the Airing object
       * @param WatchedEndTime an airing-relative time which indicates the time the user has watched the show up until
       * @param RealStartTime the time (in real time) the user started watching this program at
       * @param Titlenum the title number the user was last watching
       * @since 9.1
       *
       * @declaration public void SetWatchedTimes(Airing Airing, long WatchedEndTime, long RealStartTime, int TitleNum);
       */
      public Object runSafely(Catbert.FastStack stack) throws Exception{
        int titlenum = getInt(stack);
        long realStart = getLong(stack);
        long airEnd = getLong(stack);
			 Airing air = getAir(stack);
			 if (air != null && Permissions.hasPermission(Permissions.PERMISSION_RECORDINGSCHEDULE, stack.getUIMgr()))
        {
         MediaFile mf = Wizard.getInstance().getFileForAiring(air);
          BigBrother.setWatched(air, (mf != null) ? mf.getRecordTime() : air.getStartTime(), airEnd, realStart, Sage.time(), titlenum, false);
        }
        return null;
      }});
I think I did everything right. The only thing else I had to do was make the BigBrother.setWatched() function that takes 7 arguments 'public' so AiringAPI could access it.

Last edited by wnjj; 08-28-2018 at 04:55 PM.
Reply With Quote
  #29  
Old 08-28-2018, 11:34 AM
wnjj wnjj is offline
Sage Icon
 
Join Date: Jan 2009
Posts: 1,514
So here's some further details about DVD playback in DirectShow (Windows clients):

When the DVD position is changed, VideoFrame.timeselected() calls player.seek() which for Windows playback of DVD's calls DShowDVDPlayer.seek() which calls seekDVD0 in the native DLL driver (DVDPlaybackExtensions.cpp) which calls PlayAtTime() in DirectShow. Here's the description of PlayAtTime() from MS:

https://docs.microsoft.com/en-us/win...ol2-playattime

Notice it can only seek within a title. So absolute DVD playback time is not valid. That's why you need both a title and playback time within that title.

Based upon what I can tell, the 'watched' times for a DVD are all relative to a title.

I'm assuming the extenders are similar.
Reply With Quote
  #30  
Old 08-28-2018, 01:02 PM
davidb's Avatar
davidb davidb is offline
Sage Advanced User
 
Join Date: Feb 2009
Posts: 134
How do I get a title number? I have the airring and mediaID.

David

Quote:
Originally Posted by wnjj View Post
Here's 9.1.9 jar file with an added API if you want to try it out:

https://www.dropbox.com/s/jm9wmcoci7...dTimesDVD?dl=0

I created "SetWatchedTimesDVD" that works like the original "SetWatchedTimes" but also takes an integer for the title number after "RealStartTime".

Code:
    rft.put(new PredefinedJEPFunction("Airing", "SetWatchedTimesDVD", 4, new String[] { "Airing", "WatchedEndTime", "RealStartTime", "TitleNum" }, true)
    {
      /**
       * Updates the Watched information for this airing, including the DVD titlenum. The AiringEndTime should be an airing-relative time which indicates the time the
       * user has watched the show up until. The new watched end time will be the maximum of this value and the current watched end time. The
       * RealStartTime is the time (in real time) the user started watching this program at. Internally SageTV will set the start time of the watched
       * data to be the minimum of the recording start time and the airing start time; and the 'real' end time to be the current time.
       * @param Airing the Airing object
       * @param WatchedEndTime an airing-relative time which indicates the time the user has watched the show up until
       * @param RealStartTime the time (in real time) the user started watching this program at
       * @param Titlenum the title number the user was last watching
       * @since 9.1
       *
       * @declaration public void SetWatchedTimes(Airing Airing, long WatchedEndTime, long RealStartTime, int TitleNum);
       */
      public Object runSafely(Catbert.FastStack stack) throws Exception{
        int titlenum = getInt(stack);
        long realStart = getLong(stack);
        long airEnd = getLong(stack);
			 Airing air = getAir(stack);
			 if (air != null && Permissions.hasPermission(Permissions.PERMISSION_RECORDINGSCHEDULE, stack.getUIMgr()))
        {
         MediaFile mf = Wizard.getInstance().getFileForAiring(air);
          BigBrother.setWatched(air, (mf != null) ? mf.getRecordTime() : air.getStartTime(), airEnd, realStart, Sage.time(), titlenum, false);
        }
        return null;
      }});
I think I did everything right. The only thing else I had to do was make the BigBrother.setWatched() function that takes 7 arguments 'public' so AiringAPI could access it.
Reply With Quote
  #31  
Old 08-28-2018, 02:49 PM
wnjj wnjj is offline
Sage Icon
 
Join Date: Jan 2009
Posts: 1,514
Quote:
Originally Posted by davidb View Post
How do I get a title number? I have the airring and mediaID.

David
That probably needs an API too since the other parameters all have “get” functions. Does playback on IOS not have to deal with titles? I’ll make a getDVDTitle API and rebuild in a bit.

Alternatively I could make the original API get and the re-set the title rather than setting 0 so you don’t need to. I don’t know if external players will want to keep the title or change it though.
Reply With Quote
  #32  
Old 08-28-2018, 02:52 PM
davidb's Avatar
davidb davidb is offline
Sage Advanced User
 
Join Date: Feb 2009
Posts: 134
No the app keeps track of the mediaID and can do everything with it.

David
Quote:
Originally Posted by wnjj View Post
That probably needs an API too since the other parameters all have “get” functions. Does playback on IOS not have to deal with titles? I’ll make a getDVDTitle API and rebuild in a bit.

Alternatively I could make the original API get and the re-set the title rather than setting 0 so you don’t need to. I don’t know if external players will want to keep the title or change it though.
Reply With Quote
  #33  
Old 08-28-2018, 03:25 PM
wnjj wnjj is offline
Sage Icon
 
Join Date: Jan 2009
Posts: 1,514
I updated my Dropbox link with 2 new things:

1. Modified the original SetWatchedTimes API to get the previous titlenum and pass it back into BigBrother. This should fix your problem as-is.
2. Since #1 is not backward compatible and I'm not sure who else uses SetWatchedTimes and assumes title will be set to 0, I also added a GetDVDTitleNum API:

Code:
    rft.put(new PredefinedJEPFunction("Airing", "GetDVDTitleNum", 1, new String[] { "Airing" })
    {
      /**
       * Gets the DVD title.
       * @param Airing the Airing object
       * @return the DVD titlenum for this Airing
       * @since 6.4
       *
       * @declaration public int GetDVDTitle(Airing Airing);
       */
      public Object runSafely(Catbert.FastStack stack) throws Exception{
        Airing a = getAir(stack);
        if (a == null) return new Integer(0);
        Watched w = Wizard.getInstance().getWatch(a);
        return (w == null) ? new Integer(0) : new Integer(w.getTitleNum());
      }});
You could also use that one and then the SetWatchedTimesDVD API to pass it back in along with the other parameters.

In summary: Use both of my 2 new API functions as a Get/Set pair or just use the original one that I've modded.

Download the jar from https://www.dropbox.com/s/f2d3rnwszg...dTimesDVD?dl=0 and give it a try if you want. Please back up your old jar and wiz.bin or do this on a test system you don't care about.

Last edited by wnjj; 08-28-2018 at 04:55 PM.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Marking one episode Watched marks all future as Watched svemuri SageTV Beta Test Software 3 03-16-2011 01:24 PM
Last time you watched Live TV? IVB General Discussion 34 01-01-2010 03:28 AM
Daylight Savings Time and NTFS time stamps - 1 hour off? Opus4 The SageTV Community 2 11-01-2006 11:34 PM
Reset watched shows after a certain time? Speedy64i SageTV Software 3 04-20-2006 02:08 PM
Feature Request: Time limited "watched" list Deadbolt SageTV Beta Test Software 2 02-10-2004 05:34 PM


All times are GMT -6. The time now is 12:47 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2023, vBulletin Solutions Inc.
Copyright 2003-2005 SageTV, LLC. All rights reserved.