[solved] - GUI Toggle Watched Event

Discussion in 'Moving Pictures' started by popy, February 1, 2015.

  1. popy
    • Super User

    popy Super User

    Joined:
    July 3, 2011
    Messages:
    616
    Likes Received:
    83
    Ratings:
    +141 / 2
    Show System Specs
    Hey guys.

    i want to extend the WatchedSynronizer Plugin and looking for a toggle watched event for moving pictures.
    In mptvseries it like that:



    Code (Text):
    1. using WindowPlugins.GUITVSeries;
    2.  
    3. ...
    4.  
    5. TVSeriesPlugin.ToggleWatched += new TVSeriesPlugin.ToggleWatchedEventDelegate(OnTVSeriesToggledWatched);
    6.  
    7. ....
    8.  
    9. private void OnTVSeriesToggledWatched(DBSeries objSeries, List<DBEpisode> lstDBEpisodes, bool bolWatched)
    10. {
    11.  
    12. }
    is there anything similar in MovingPictures?

    thx
    pOpY
     
  2. Google AdSense Guest Advertisement



    to hide all adverts.
  3. popy
    • Super User

    popy Super User

    Joined:
    July 3, 2011
    Messages:
    616
    Likes Received:
    83
    Ratings:
    +141 / 2
    Show System Specs
    Hey.

    have searched throught the source code and didnt found any event like there is one in mptvseries.
    Tried to implement it and built v1.8 from svn tag. I can compile it but when ir loads in Mediaportal there is an error:

    Code (Text):
    1. [2015-02-01 21:49:37,833] [Log    ] [MPMain   ] [INFO ] - PluginManager: 'C:\Program Files (x86)\Team MediaPortal\MediaPortal\Plugins\windows\MovingPictures.dll' file version: 1.8.0.1613
    2. [2015-02-01 21:49:37,843] [Log    ] [MPMain   ] [INFO ] - PluginManager: Plugin file MovingPictures.dll is broken or incompatible with the current MediaPortal version and won't be loaded!
    3. [2015-02-01 21:49:37,844] [Log    ] [MPMain   ] [INFO ] - PluginManager: Exception: System.IO.FileNotFoundException: Die Datei oder Assembly "CookComputing.XmlRpcV2, Version=2.4.0.0, Culture=neutral, PublicKeyToken=a7d6e17aa302004d" oder eine Abhängigkeit davon wurde nicht gefunden. Das System kann die angegebene Datei nicht finden.
    4. Dateiname: "CookComputing.XmlRpcV2, Version=2.4.0.0, Culture=neutral, PublicKeyToken=a7d6e17aa302004d"
    5.    bei System.Reflection.RuntimeAssembly.GetExportedTypes(RuntimeAssembly assembly, ObjectHandleOnStack retTypes)
    6.    bei System.Reflection.RuntimeAssembly.GetExportedTypes()
    7.    bei MediaPortal.GUI.Library.PluginManager.LoadWindowPlugin(String strFile)
    8.  
    9. WRN: Protokollierung der Assemblybindung ist AUS.
    10. Sie können die Protokollierung der Assemblybindungsfehler aktivieren, indem Sie den Registrierungswert [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) auf 1 festlegen.
    11. Hinweis: Die Protokollierung der Assemblybindungsfehler führt zu einer gewissen Leistungseinbuße.
    12. Sie können dieses Feature deaktivieren, indem Sie den Registrierungswert [HKLM\Software\Microsoft\Fusion!EnableLog] entfernen.
    13.  
    14. [2015-02-01 21:49:37,844] [Log    ] [MPMain   ] [DEBUG] - PluginManager: End loading '\windows\MovingPictures.dll' (16,0149 ms running time)
    i have attached my patch for the needed event.
    Can anybody please provide me an test build with the patch merged?

    thx
    pOpY
     

    Attached Files:

  4. popy
    • Super User

    popy Super User

    Joined:
    July 3, 2011
    Messages:
    616
    Likes Received:
    83
    Ratings:
    +141 / 2
    Show System Specs
    Update:
    It works now. I had to run "merge.bat" in the output directory.
    Now my MovingPictures.dll is running and the event is working ;)
    My development version of WatchedSyncronizer receives the toggle watchedstate event from the MovingPictures GUI.

    Code (Text):
    1. [2015-02-01 22:24:26,021] [Log    ] [MPMain   ] [DEBUG] - WatchedSynchronizer: OnMovingPicturesToggledWatched: The Watched Status for file '\\MEDIASERVER\Videos\Movies\xxxxxxxxxxxxxxxxxxx.mkv' was toggled to 'True',
    2.  
    @ltfearme: Is it possible that my patch from the previous post wil be merged into the next MovingPictures Version?

    thx
    pOpY

    PS: Attached a patched MovingPictures.dll version 1.8.0.1613.
     

    Attached Files:

    Last edited: February 1, 2015
  5. ltfearme
    • Premium Supporter

    ltfearme Community Plugin Dev

    Joined:
    June 10, 2007
    Messages:
    6,458
    Likes Received:
    4,245
    Gender:
    Male
    Occupation:
    Software Test Engineer
    Location:
    Sydney
    Ratings:
    +5,389 / 0
    Home Country:
    Australia Australia
    It already has support for this:
    Code (Text):
    1.  
    2. MovingPicturesCore.DatabaseManager.ObjectUpdatedEx += new DatabaseManager.ObjectUpdatedDelegate(DatabaseManager_ObjectUpdatedEx);
    3.  
     
    • Thank You! Thank You! x 1
  6. popy
    • Super User

    popy Super User

    Joined:
    July 3, 2011
    Messages:
    616
    Likes Received:
    83
    Ratings:
    +141 / 2
    Show System Specs
    thx, this is what i have searched for ;)
     
  7. popy
    • Super User

    popy Super User

    Joined:
    July 3, 2011
    Messages:
    616
    Likes Received:
    83
    Ratings:
    +141 / 2
    Show System Specs
    Hey, another question regarding the resumedata in the event.
    My code currently is:

    Code (Text):
    1.    
    2.     //ByteArrayToString, helper function for converting byte array to string
    3.     private string ByteArrayToString(byte[] ba)
    4.     {
    5.         if (ba == null) return "null";
    6.         StringBuilder hex = new StringBuilder(ba.Length * 2);
    7.         foreach (byte b in ba)
    8.             hex.AppendFormat("{0:x2}", b);
    9.         return hex.ToString();
    10.     }
    11.  
    12.     /// <summary>
    13.     /// Fired when an object is updated in the Moving Pictures Database
    14.     /// </summary>
    15.     /// <param name="obj"></param>
    16.     private void DatabaseManager_ObjectUpdatedEx(DatabaseTable dbObject, TableUpdateInfo ui)
    17.     {
    18.         WatchedStateEvent curEvent = new WatchedStateEvent();
    19.         string strDebug;
    20.  
    21.         // If it is user settings for a movie
    22.         if (dbObject.GetType() != typeof(DBUserMovieSettings))
    23.         {
    24.             Log.Debug("WatchedSynchronizer: DatabaseManager_ObjectUpdatedEx: dbObject.GetType != DBUserMovieSettings");
    25.             return;
    26.         }
    27.  
    28.         DBUserMovieSettings userMovieSettings = (DBUserMovieSettings)dbObject;
    29.         DBMovieInfo movie = userMovieSettings.AttachedMovies[0];
    30.  
    31.         //Debug
    32.         strDebug = "WatchedSynchronizer: DatabaseManager_ObjectUpdatedEx: userMovieSettings:" +
    33.                                                             "ID: " + userMovieSettings.ID.ToString() + ", " +
    34.                                                             "User: " + userMovieSettings.User.ToString() + ", " +
    35.                                                             "UserRating: " + userMovieSettings.UserRating.ToString() + ", " +
    36.                                                             "WatchedCount: " + userMovieSettings.WatchedCount.ToString() + ", " +
    37.                                                             "ResumePart: " + userMovieSettings.ResumePart.ToString() + ", " +
    38.                                                             "ResumeTime: " + userMovieSettings.ResumeTime.ToString() + ", " +
    39.                                                             "ResumeTitleBD: " + userMovieSettings.ResumeTitleBD.ToString();
    40.         if (userMovieSettings.ResumeData.Data == null)
    41.         {
    42.             strDebug = strDebug + ", " + "ResumeData: null";
    43.         }
    44.         else
    45.         {
    46.             strDebug = strDebug + ", " + "ResumeData: " + ByteArrayToString(userMovieSettings.ResumeData.Data);
    47.         }
    48.         Log.Debug(strDebug);
    I am always getting exception:

    Code (Text):
    1. [2015-02-03 13:04:08,132] [Log    ] [MPMain   ] [DEBUG] - GUIVideoFiles: OnPlayBackStopped store resume time
    2. [2015-02-03 13:04:08,157] [Log    ] [MPMain   ] [ERROR] - Exception: System.NullReferenceException: Der Objektverweis wurde nicht auf eine Objektinstanz festgelegt.
    3.    bei Cornerstone.Database.CustomTypes.ByteArray.get_Data()
    4.    bei WatchedSynchronizer.WatchedSynchronizer.DatabaseManager_ObjectUpdatedEx(DatabaseTable dbObject, TableUpdateInfo ui)
    5.    bei Cornerstone.Database.DatabaseManager.update(DatabaseTable dbObject)
    6.    bei Cornerstone.Database.DatabaseManager.Commit(DatabaseTable dbObject)
    7.    bei Cornerstone.Database.Tables.DatabaseTable.Commit()
    8.    bei MediaPortal.Plugins.MovingPictures.Database.MovingPicturesDBTable.Commit()
    9.    bei MediaPortal.Plugins.MovingPictures.MainUI.MoviePlayer.updateMovieResumeState(DBMovieInfo movie, Int32 part, Int32 timePlayed, Byte[] resumeData, Int32 titleBD)
    10.    bei MediaPortal.Plugins.MovingPictures.MainUI.MoviePlayer.onPlayBackStoppedOrChanged(MediaType type, Int32 timeMovieStopped, String filename)
    11.    bei MediaPortal.Player.g_Player.StoppedHandler.Invoke(MediaType type, Int32 stoptime, String filename)
    12.    bei MediaPortal.Player.g_Player.OnStopped()
    13.    bei MediaPortal.Player.g_Player.doStop(Boolean keepTimeShifting, Boolean keepExclusiveModeOn)
    14.    bei MediaPortal.Player.g_Player.Stop()
    15.    bei MediaPortalApp.OnAction(Action action)  Message: Der Objektverweis wurde nicht auf eine Objektinstanz festgelegt.  Site   : Byte[] get_Data()  Source : Cornerstone  Stack Trace:     bei Cornerstone.Database.CustomTypes.ByteArray.get_Data()
    16.    bei WatchedSynchronizer.WatchedSynchronizer.DatabaseManager_ObjectUpdatedEx(DatabaseTable dbObject, TableUpdateInfo ui)
    17.    bei Cornerstone.Database.DatabaseManager.update(DatabaseTable dbObject)
    18.    bei Cornerstone.Database.DatabaseManager.Commit(DatabaseTable dbObject)
    19.    bei Cornerstone.Database.Tables.DatabaseTable.Commit()
    20.    bei MediaPortal.Plugins.MovingPictures.Database.MovingPicturesDBTable.Commit()
    21.    bei MediaPortal.Plugins.MovingPictures.MainUI.MoviePlayer.updateMovieResumeState(DBMovieInfo movie, Int32 part, Int32 timePlayed, Byte[] resumeData, Int32 titleBD)
    22.    bei MediaPortal.Plugins.MovingPictures.MainUI.MoviePlayer.onPlayBackStoppedOrChanged(MediaType type, Int32 timeMovieStopped, String filename)
    23.    bei MediaPortal.Player.g_Player.StoppedHandler.Invoke(MediaType type, Int32 stoptime, String filename)
    24.    bei MediaPortal.Player.g_Player.OnStopped()
    25.    bei MediaPortal.Player.g_Player.doStop(Boolean keepTimeShifting, Boolean keepExclusiveModeOn)
    26.    bei MediaPortal.Player.g_Player.Stop()
    27.    bei MediaPortalApp.OnAction(Action action)
    28. [2015-02-03 13:04:08,170] [Error  ] [MPMain   ] [ERROR] - Exception: Der Objektverweis wurde nicht auf eine Objektinstanz festgelegt. Cornerstone    bei Cornerstone.Database.CustomTypes.ByteArray.get_Data()
    29.    bei WatchedSynchronizer.WatchedSynchronizer.DatabaseManager_ObjectUpdatedEx(DatabaseTable dbObject, TableUpdateInfo ui)
    30.    bei Cornerstone.Database.DatabaseManager.update(DatabaseTable dbObject)
    31.    bei Cornerstone.Database.DatabaseManager.Commit(DatabaseTable dbObject)
    32.    bei Cornerstone.Database.Tables.DatabaseTable.Commit()
    33.    bei MediaPortal.Plugins.MovingPictures.Database.MovingPicturesDBTable.Commit()
    34.    bei MediaPortal.Plugins.MovingPictures.MainUI.MoviePlayer.updateMovieResumeState(DBMovieInfo movie, Int32 part, Int32 timePlayed, Byte[] resumeData, Int32 titleBD)
    35.    bei MediaPortal.Plugins.MovingPictures.MainUI.MoviePlayer.onPlayBackStoppedOrChanged(MediaType type, Int32 timeMovieStopped, String filename)
    36.    bei MediaPortal.Player.g_Player.StoppedHandler.Invoke(MediaType type, Int32 stoptime, String filename)
    37.    bei MediaPortal.Player.g_Player.OnStopped()
    38.    bei MediaPortal.Player.g_Player.doStop(Boolean keepTimeShifting, Boolean keepExclusiveModeOn)
    39.    bei MediaPortal.Player.g_Player.Stop()
    40.    bei MediaPortalApp.OnAction(Action action)
    41. [2015-02-03 13:04:08,175] [Log    ] [MPMain   ] [ERROR] - Exception: System.Exception: exception occurred ---> System.NullReferenceException: Der Objektverweis wurde nicht auf eine Objektinstanz festgelegt.
    42.    bei Cornerstone.Database.CustomTypes.ByteArray.get_Data()
    43.    bei WatchedSynchronizer.WatchedSynchronizer.DatabaseManager_ObjectUpdatedEx(DatabaseTable dbObject, TableUpdateInfo ui)
    44.    bei Cornerstone.Database.DatabaseManager.update(DatabaseTable dbObject)
    45.    bei Cornerstone.Database.DatabaseManager.Commit(DatabaseTable dbObject)
    46.    bei Cornerstone.Database.Tables.DatabaseTable.Commit()
    47.    bei MediaPortal.Plugins.MovingPictures.Database.MovingPicturesDBTable.Commit()
    48.    bei MediaPortal.Plugins.MovingPictures.MainUI.MoviePlayer.updateMovieResumeState(DBMovieInfo movie, Int32 part, Int32 timePlayed, Byte[] resumeData, Int32 titleBD)
    49.    bei MediaPortal.Plugins.MovingPictures.MainUI.MoviePlayer.onPlayBackStoppedOrChanged(MediaType type, Int32 timeMovieStopped, String filename)
    50.    bei MediaPortal.Player.g_Player.StoppedHandler.Invoke(MediaType type, Int32 stoptime, String filename)
    51.    bei MediaPortal.Player.g_Player.OnStopped()
    52.    bei MediaPortal.Player.g_Player.doStop(Boolean keepTimeShifting, Boolean keepExclusiveModeOn)
    53.    bei MediaPortal.Player.g_Player.Stop()
    54.    bei MediaPortalApp.OnAction(Action action)
    55.    --- Ende der internen Ausnahmestapelüberwachung ---
    56.    bei MediaPortalApp.OnAction(Action action)
    57.    bei MediaPortal.GUI.Library.OnActionHandler.Invoke(Action action)
    58.    bei MediaPortal.GUI.Library.GUIWindowManager.DispatchThreadMessages()
    59.    bei MediaPortalApp.FrameMove()  Message: exception occurred  Site   : Void OnAction(MediaPortal.GUI.Library.Action)  Source : MediaPortal  Inner Exception(s):  -> exception occurred  -> Der Objektverweis wurde nicht auf eine Objektinstanz festgelegt.  Stack Trace:     bei MediaPortalApp.OnAction(Action action)
    60.    bei MediaPortal.GUI.Library.OnActionHandler.Invoke(Action action)
    61.    bei MediaPortal.GUI.Library.GUIWindowManager.DispatchThreadMessages()
    62.    bei MediaPortalApp.FrameMove()
    63. [2015-02-03 13:04:08,282] [Log    ] [MPMain   ] [DEBUG] - D3D: Showing mouse cursor
    When ill remove the Debug print of the Resumpart variable the code runs fine.
    What i have understanded is that the resumepart is needed for gplayer to resume settings for BD/DVD playback.

    how can ill print it correctly to the debug log (best is hex string formated)??

    how can ill update Resumepart with Update sql statement within c#.
    Currently my code is:

    Code (Text):
    1.             string strSQL = String.Format("UPDATE user_movie_settings SET watched = {0}, resume_part = {1}, resume_time = {2}, resume_data = NULL, resume_titlebd = {3} WHERE id = '{4}'", strWatchedStatus, intResumePart.ToString(), intResumeTime.ToString(), intResumeTitleBD.ToString(), strUserMovieSettingsId);
    2.             Log.Debug("WatchedSynchronizer: (SetEpisodeWatchedStatus) SQL statement '" + strSQL + "' is going to be executed in database '" + mDatabase.DatabaseName + "'.");
    3.             mDatabase.Execute(strSQL);
    4.  
    thx
    pOpY
     
  8. popy
    • Super User

    popy Super User

    Joined:
    July 3, 2011
    Messages:
    616
    Likes Received:
    83
    Ratings:
    +141 / 2
    Show System Specs
    Update: I have solved it.

    The issue is in the ByteArray.cs of CornerStone.
    Old Code:

    Code (Text):
    1.         public byte[] Data {
    2.             get {
    3.                 if (_data.Length == 0)
    4.                     return null;
    5.                 else
    6.                     return _data;
    7.             }
    8.             set { _data = value; }
    9.         }
    10.         private byte[] _data = null;
    11.  
    12.         public ByteArray() {
    13.         }
    14.  
    15.         public ByteArray(byte[] data) {
    16.             _data = data;
    17.         }
    Ill think it happens that when an new ByteArray is instanced with no given "data" and "Data" is accessed, the code access "_data.Length" (bold above) and there the exception is thrown!

    Fixed Code:

    Code (Text):
    1.         public byte[] Data {
    2.             get {
    3.                 if ((_data == null) || (_data.Length == 0))
    4.                     return null;
    5.                 else
    6.                     return _data;
    7.             }
    8.             set { _data = value; }
    9.         }
    10.         private byte[] _data = null;
    11.  
    12.         public ByteArray() {
    13.         }
    14.  
    15.         public ByteArray(byte[] data) {
    16.             _data = data;
    17.         }
    My workaround in my current code of WatchedSyncronizer:

    Code (Text):
    1.     private void OnMovingPicturesDatabaseUpdated(DatabaseTable dbObject, TableUpdateInfo ui)
    2.     {
    3.         WatchedStateEvent curEvent = new WatchedStateEvent();
    4.         byte[] bteTmpResumeData = new byte[] { };
    5.  
    6.         // If it is user settings for a movie
    7.         if (dbObject.GetType() != typeof(DBUserMovieSettings))
    8.         {
    9.             Log.Debug("WatchedSynchronizer: OnMovingPicturesDatabaseUpdated: unknown object type: '" + dbObject.GetType().ToString() + "', event dropped!");
    10.             return;
    11.         }
    12.  
    13.         //Cast to DBUserMovieSettings object and get movie details
    14.         DBUserMovieSettings userMovieSettings = (DBUserMovieSettings)dbObject;
    15.         DBMovieInfo movie = userMovieSettings.AttachedMovies[0];
    16.  
    17.         //check if userMovieSettings.ResumeData is null or empty string
    18.         //if that is the case reinitialize userMovieSettings.ResumeData with an empty byte array to prevent null exception when accessing userMovieSettings.ResumeData.Data
    19.         //this should be fixed in ByteArray.cs of Cornerstone. There is access to _data.length and NO null check before!
    20.         if ((userMovieSettings.ResumeData == null) || (userMovieSettings.ResumeData.ToString() == ""))
    21.         {
    22.             userMovieSettings.ResumeData = new ByteArray(bteTmpResumeData);
    23.         }
    pOpY
     
Loading...

Users Viewing Thread (Users: 0, Guests: 0)

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice
  • About The Project

    The vision of the MediaPortal project is to create a free open source media centre application, which supports all advanced media centre functions, and is accessible to all Windows users.

    In reaching this goal we are working every day to make sure our software is one of the best.

             

  • Support MediaPortal!

    The team works very hard to make sure the community is running the best HTPC-software. We give away MediaPortal for free but hosting and software is not for us.

    Care to support our work with a few bucks? We'd really appreciate it!