mirror of
https://github.com/SoPat712/YTLitePlus.git
synced 2025-08-21 18:48:45 -04:00
Video player prototype
This commit is contained in:
@@ -47,6 +47,8 @@ static int appVersionSpoofer() {
|
|||||||
|
|
||||||
@interface YTSettingsSectionItemManager (YTLitePlus)
|
@interface YTSettingsSectionItemManager (YTLitePlus)
|
||||||
- (void)updateYTLitePlusSectionWithEntry:(id)entry;
|
- (void)updateYTLitePlusSectionWithEntry:(id)entry;
|
||||||
|
- (void)documentPicker:(UIDocumentPickerViewController *)controller didPickDocumentsAtURLs:(NSArray<NSURL *> *)urls;
|
||||||
|
- (void)documentPickerWasCancelled:(UIDocumentPickerViewController *)controller;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
extern NSBundle *YTLitePlusBundle();
|
extern NSBundle *YTLitePlusBundle();
|
||||||
@@ -197,6 +199,29 @@ static const NSInteger YTLiteSection = 789;
|
|||||||
];
|
];
|
||||||
[sectionItems addObject:pasteSettings];
|
[sectionItems addObject:pasteSettings];
|
||||||
|
|
||||||
|
YTSettingsSectionItem *videoPlayer = [%c(YTSettingsSectionItem)
|
||||||
|
itemWithTitle:LOC(@"VIDEO_PICKER")
|
||||||
|
titleDescription:LOC(@"VIDEO_PICKER_DESC")
|
||||||
|
accessibilityIdentifier:nil
|
||||||
|
detailTextBlock:nil
|
||||||
|
selectBlock:^BOOL (YTSettingsCell *cell, NSUInteger arg1) {
|
||||||
|
// Access the current view controller
|
||||||
|
UIViewController *settingsViewController = [self valueForKey:@"_settingsViewControllerDelegate"];
|
||||||
|
if (settingsViewController) {
|
||||||
|
// Present the video picker
|
||||||
|
UIDocumentPickerViewController *documentPicker = [[UIDocumentPickerViewController alloc] initWithDocumentTypes:@[(NSString *)kUTTypeMovie, (NSString *)kUTTypeVideo] inMode:UIDocumentPickerModeImport];
|
||||||
|
documentPicker.delegate = (id<UIDocumentPickerDelegate>)self;
|
||||||
|
documentPicker.allowsMultipleSelection = NO;
|
||||||
|
[settingsViewController presentViewController:documentPicker animated:YES completion:nil];
|
||||||
|
} else {
|
||||||
|
NSLog(@"settingsViewController is nil");
|
||||||
|
}
|
||||||
|
|
||||||
|
return YES; // Return YES to indicate that the action was handled
|
||||||
|
}
|
||||||
|
];
|
||||||
|
[sectionItems addObject:videoPlayer];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
YTSettingsSectionItem *appIcon = [%c(YTSettingsSectionItem)
|
YTSettingsSectionItem *appIcon = [%c(YTSettingsSectionItem)
|
||||||
itemWithTitle:LOC(@"CHANGE_APP_ICON")
|
itemWithTitle:LOC(@"CHANGE_APP_ICON")
|
||||||
@@ -479,4 +504,31 @@ static const NSInteger YTLiteSection = 789;
|
|||||||
}
|
}
|
||||||
%orig;
|
%orig;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Implement the delegate method for document picker
|
||||||
|
%new
|
||||||
|
- (void)documentPicker:(UIDocumentPickerViewController *)controller didPickDocumentsAtURLs:(NSArray<NSURL *> *)urls {
|
||||||
|
NSURL *pickedURL = [urls firstObject];
|
||||||
|
|
||||||
|
if (pickedURL) {
|
||||||
|
// Use AVPlayerViewController to play the video
|
||||||
|
AVPlayer *player = [AVPlayer playerWithURL:pickedURL];
|
||||||
|
AVPlayerViewController *playerViewController = [[AVPlayerViewController alloc] init];
|
||||||
|
playerViewController.player = player;
|
||||||
|
|
||||||
|
UIViewController *settingsViewController = [self valueForKey:@"_settingsViewControllerDelegate"];
|
||||||
|
if (settingsViewController) {
|
||||||
|
[settingsViewController presentViewController:playerViewController animated:YES completion:^{
|
||||||
|
[player play];
|
||||||
|
}];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
%new
|
||||||
|
- (void)documentPickerWasCancelled:(UIDocumentPickerViewController *)controller {
|
||||||
|
// Handle cancellation if needed
|
||||||
|
NSLog(@"Document picker was cancelled");
|
||||||
|
}
|
||||||
|
|
||||||
%end
|
%end
|
||||||
|
@@ -6,6 +6,9 @@
|
|||||||
#import <sys/utsname.h>
|
#import <sys/utsname.h>
|
||||||
#import <substrate.h>
|
#import <substrate.h>
|
||||||
#import <rootless.h>
|
#import <rootless.h>
|
||||||
|
#import <AVKit/AVKit.h> // For AVPlayer and AVPlayerViewController
|
||||||
|
#import <MobileCoreServices/MobileCoreServices.h> // For kUTTypeMovie and kUTTypeVideo
|
||||||
|
|
||||||
|
|
||||||
#import "Tweaks/FLEX/FLEX.h"
|
#import "Tweaks/FLEX/FLEX.h"
|
||||||
#import "Tweaks/YouTubeHeader/YTAppDelegate.h"
|
#import "Tweaks/YouTubeHeader/YTAppDelegate.h"
|
||||||
|
Reference in New Issue
Block a user