Jelajahi Sumber

Add support to let 3rd parties open network streams in our app (refs #8575)

This includes protocol support for ftp, sftp, rtp, udp, rtmp, mms / mmsh and smb
Felix Paul Kühne 12 tahun lalu
induk
melakukan
d828f3c7e1

+ 84 - 0
AspenProject/AspenProject-Info.plist

@@ -35,6 +35,90 @@
 	<string>1.0</string>
 	<key>CFBundleSignature</key>
 	<string>????</string>
+	<key>CFBundleURLTypes</key>
+	<array>
+		<dict>
+			<key>CFBundleTypeRole</key>
+			<string>Viewer</string>
+			<key>CFBundleURLName</key>
+			<string>RTSP</string>
+			<key>CFBundleURLSchemes</key>
+			<array>
+				<string>rtsp</string>
+			</array>
+		</dict>
+		<dict>
+			<key>CFBundleTypeRole</key>
+			<string>Viewer</string>
+			<key>CFBundleURLName</key>
+			<string>Multimedia Stream URL</string>
+			<key>CFBundleURLSchemes</key>
+			<array>
+				<string>mms</string>
+				<string>mmsh</string>
+			</array>
+		</dict>
+		<dict>
+			<key>CFBundleTypeRole</key>
+			<string>Viewer</string>
+			<key>CFBundleURLName</key>
+			<string>UDP URL</string>
+			<key>CFBundleURLSchemes</key>
+			<array>
+				<string>udp</string>
+			</array>
+		</dict>
+		<dict>
+			<key>CFBundleTypeRole</key>
+			<string>Viewer</string>
+			<key>CFBundleURLName</key>
+			<string>RTP URL</string>
+			<key>CFBundleURLSchemes</key>
+			<array>
+				<string>rtp</string>
+			</array>
+		</dict>
+		<dict>
+			<key>CFBundleTypeRole</key>
+			<string>Viewer</string>
+			<key>CFBundleURLName</key>
+			<string>RTMP</string>
+			<key>CFBundleURLSchemes</key>
+			<array>
+				<string>rtmp</string>
+			</array>
+		</dict>
+		<dict>
+			<key>CFBundleTypeRole</key>
+			<string>Viewer</string>
+			<key>CFBundleURLName</key>
+			<string>SFTP</string>
+			<key>CFBundleURLSchemes</key>
+			<array>
+				<string>sftp</string>
+			</array>
+		</dict>
+		<dict>
+			<key>CFBundleTypeRole</key>
+			<string>Viewer</string>
+			<key>CFBundleURLName</key>
+			<string>FTP</string>
+			<key>CFBundleURLSchemes</key>
+			<array>
+				<string>ftp</string>
+			</array>
+		</dict>
+		<dict>
+			<key>CFBundleTypeRole</key>
+			<string>Viewer</string>
+			<key>CFBundleURLName</key>
+			<string>SMB</string>
+			<key>CFBundleURLSchemes</key>
+			<array>
+				<string>smb</string>
+			</array>
+		</dict>
+	</array>
 	<key>CFBundleVersion</key>
 	<string>1.0</string>
 	<key>LSRequiresIPhoneOS</key>

+ 11 - 1
AspenProject/VLCAppDelegate.m

@@ -14,7 +14,6 @@
 
 @implementation VLCAppDelegate
 
-
 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
 {
     self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
@@ -26,9 +25,20 @@
 
     self.navigationController.navigationBar.barStyle = UIBarStyleBlack;
     [self.window makeKeyAndVisible];
+
     return YES;
 }
 
+- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
+{
+    if (_playlistViewController && url != nil) {
+        APLog(@"%@ requested %@ to be opened", sourceApplication, url);
+        [_playlistViewController openMovieFromURL:url];
+        return YES;
+    }
+    return NO;
+}
+
 - (void)applicationWillResignActive:(UIApplication *)application
 {
     [[MLMediaLibrary sharedMediaLibrary] applicationWillExit];

+ 1 - 0
AspenProject/VLCPlaylistViewController.h

@@ -28,5 +28,6 @@
 @property (nonatomic, strong) IBOutlet UITabBarItem *networkStreamsBarItem;
 
 - (void)updateViewContents;
+- (void)openMovieFromURL:(NSURL *)url;
 
 @end

+ 10 - 6
AspenProject/VLCPlaylistViewController.m

@@ -200,13 +200,17 @@
 
 - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
 {
-    if (buttonIndex == 1) {
-        if (!self.movieViewController)
-            self.movieViewController = [[VLCMovieViewController alloc] initWithNibName:@"VLCMovieViewController" bundle:nil];
+    if (buttonIndex == 1)
+        [self openMovieFromURL:_pasteURL];
+}
 
-        self.movieViewController.url = _pasteURL;
-        [self.navigationController pushViewController:self.movieViewController animated:YES];
-    }
+- (void)openMovieFromURL:(NSURL *)url
+{
+    if (!self.movieViewController)
+        self.movieViewController = [[VLCMovieViewController alloc] initWithNibName:@"VLCMovieViewController" bundle:nil];
+
+    self.movieViewController.url = url;
+    [self.navigationController pushViewController:self.movieViewController animated:YES];
 }
 
 @end