Automatically loop all videos in the iOS photos app.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

77 lines
1.5KB

  1. typedef struct {
  2. long long value;
  3. int timescale;
  4. unsigned int flags;
  5. long long epoch;
  6. } TIME;
  7. @interface PUBrowsingVideoPlayer
  8. -(void)videoSessionDidPlayToEnd:(id)arg1; //IOS12
  9. -(void)avPlayer:(id)arg1 itemDidPlayToEnd:(id)arg2; //IOS13
  10. -(void)seekToTime:(TIME)arg1 toleranceBefore:(TIME)arg2 toleranceAfter:(TIME)arg3 completionHandler:(id)arg4;
  11. -(void)seekToTime:(TIME)arg1 completionHandler:(id)arg2;
  12. -(TIME)currentTime;
  13. -(void)_updateVideoSessionDesiredPlayState;
  14. -(void)rewindExistingPlayer;
  15. @property(nonatomic) long long desiredPlayState;
  16. @end
  17. %group IOS12
  18. %hook PUBrowsingVideoPlayer
  19. - (void)avPlayer:(id)arg1 itemDidPlayToEnd:(id)arg2 {
  20. // %orig (arg1, arg2);
  21. NSLog(@"AutoReplay - Ended 12");
  22. TIME t = [self currentTime];
  23. t.value = (long long) 0;
  24. t.timescale = 100;
  25. t.flags = (unsigned int) 1;
  26. [self seekToTime:t toleranceBefore:t toleranceAfter:t completionHandler:NULL];
  27. }
  28. %end
  29. %end //end group IOS12
  30. %group IOS13
  31. %hook PUBrowsingVideoPlayer
  32. static bool isFirstTryAfterEnding = false;
  33. - (void)videoSessionDidPlayToEnd:(id)arg1 {
  34. isFirstTryAfterEnding = true;
  35. [self rewindExistingPlayer];
  36. }
  37. - (void)_updateVideoSessionDesiredPlayState {
  38. if (self.desiredPlayState == 0 && isFirstTryAfterEnding) {
  39. isFirstTryAfterEnding = false;
  40. MSHookIvar<long long>(self, "_desiredPlayState") = 1;
  41. }
  42. %orig;
  43. }
  44. %end
  45. %end //end group IOS13
  46. %ctor {
  47. float version = [[[UIDevice currentDevice] systemVersion] floatValue];
  48. if (version < 13) {
  49. %init(IOS12);
  50. } else {
  51. %init(IOS13);
  52. }
  53. }