Пример #1
0
 public static void PlaybackStopped(VideoInfo info, long position)
 {
     if (TraktEnabled())
     {
         // Wait 1s in case of old commands
         Thread.Sleep(1000);
         traktHelper.TraktScrobble(TraktHelper.ScrobblePlayingStatus.Stop, info, (int)position,
                                   (int)info.Duration);
     }
 }
Пример #2
0
        private void FindChangedFiles(Dictionary <string, long> filePositions)
        {
            // find all the files which have changed
            Dictionary <string, long> changedFilePositions = new Dictionary <string, long>();

            foreach (KeyValuePair <string, long> kvp in filePositions)
            {
                changedFilePositions[kvp.Key] = kvp.Value;
            }

            // update the changed positions
            foreach (KeyValuePair <string, long> kvp in changedFilePositions)
            {
                previousFilePositions[kvp.Key] = kvp.Value.ToString();
            }

            foreach (KeyValuePair <string, long> kvp in changedFilePositions)
            {
                VideoInfo v = recentlyPlayedFiles.Values.FirstOrDefault(a => a.Uri == kvp.Key);
                if (v != null)
                {
                    logger.Info($"Video position for {v.Uri} has changed to {kvp.Value}");
                    v.ChangePosition(kvp.Value); //Set New Resume Position

                    try
                    {
                        if (VM_ShokoServer.Instance.Trakt_IsEnabled &&
                            !string.IsNullOrEmpty(VM_ShokoServer.Instance.Trakt_AuthToken) &&
                            !scrobbleLock)
                        {
                            scrobblePosition = kvp.Value;
                            scrobbleLock     = true;
                            traktHelper.TraktScrobble(TraktHelper.ScrobblePlayingStatus.Start, v, (int)kvp.Value,
                                                      (int)v.Duration);
                            scrobbleLock = false;
                        }
                    }
                    catch (Exception)
                    {
                        scrobbleLock = false;
                    }

                    if (!MayUpdateWatchStatus(v, kvp.Value))
                    {
                        return;
                    }
                }
            }
        }