浏览代码

plex : Network Service Browser use information login on tvOS

Pierre SAGASPE 6 年之前
父节点
当前提交
409a00f02b

+ 2 - 1
Apple-TV/VLCServerBrowsingTVViewController.m

@@ -125,7 +125,8 @@
 
     [self vlc_showAlertWithTitle:NSLocalizedString(@"LOCAL_SERVER_CONNECTION_FAILED_TITLE", nil)
                          message:NSLocalizedString(@"LOCAL_SERVER_CONNECTION_FAILED_MESSAGE", nil)
-                     buttonTitle:NSLocalizedString(@"BUTTON_CANCEL", nil)];
+                     buttonTitle:NSLocalizedString(@"BUTTON_OK", nil)];
+
 }
 
 #pragma mark -

+ 24 - 6
SharedSources/ServerBrowsing/Plex/VLCLocalNetworkServiceBrowserPlex.m

@@ -2,7 +2,7 @@
  * VLCLocalNetworkServiceBrowserPlex.m
  * VLC for iOS
  *****************************************************************************
- * Copyright (c) 2015 VideoLAN. All rights reserved.
+ * Copyright (c) 2015-2019 VideoLAN. All rights reserved.
  * $Id$
  *
  * Authors: Tobias Conradi <videolan # tobias-conradi.de>
@@ -14,7 +14,9 @@
 #import "VLCNetworkServerBrowserPlex.h"
 
 @implementation VLCLocalNetworkServiceBrowserPlex
-- (instancetype)init {
+
+- (instancetype)init
+{
 #if TARGET_OS_TV
     NSString *name = NSLocalizedString(@"PLEX_SHORT",nil);
 #else
@@ -24,7 +26,9 @@
                    serviceType:@"_plexmediasvr._tcp."
                         domain:@""];
 }
-- (VLCLocalNetworkServiceNetService *)localServiceForNetService:(NSNetService *)netService {
+
+- (VLCLocalNetworkServiceNetService *)localServiceForNetService:(NSNetService *)netService
+{
     return [[VLCLocalNetworkServicePlex alloc] initWithNetService:netService serviceName:self.name];
 }
 @end
@@ -32,11 +36,23 @@
 NSString *const VLCNetworkServerProtocolIdentifierPlex = @"plex";
 
 @implementation VLCLocalNetworkServicePlex
-- (UIImage *)icon {
+- (UIImage *)icon
+{
     return [UIImage imageNamed:@"PlexServerIcon"];
 }
-- (id<VLCNetworkServerBrowser>)serverBrowser {
+#if TARGET_OS_TV
+- (nullable id<VLCNetworkServerLoginInformation>)loginInformation
+{
+    VLCNetworkServerLoginInformation *login = [[VLCNetworkServerLoginInformation alloc] init];
+    login.address = self.netService.hostName;
+    login.port = [NSNumber numberWithInteger:self.netService.port];
+    login.protocolIdentifier = VLCNetworkServerProtocolIdentifierPlex;
 
+    return login;
+}
+#else
+- (id<VLCNetworkServerBrowser>)serverBrowser
+{
     NSNetService *service = self.netService;
     if (service.hostName == nil || service.port == 0) {
         return nil;
@@ -45,9 +61,11 @@ NSString *const VLCNetworkServerProtocolIdentifierPlex = @"plex";
     NSString *name = service.name;
     NSString *hostName = service.hostName;
     NSUInteger portNum = service.port;
+
     VLCNetworkServerBrowserPlex *serverBrowser = [[VLCNetworkServerBrowserPlex alloc] initWithName:name host:hostName portNumber:@(portNum) path:@"" authentificication:@""];
 
     return serverBrowser;
 }
-@end
+#endif
 
+@end