VLCLocalNetworkServiceBrowserPlex.m 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /*****************************************************************************
  2. * VLCLocalNetworkServiceBrowserPlex.m
  3. * VLC for iOS
  4. *****************************************************************************
  5. * Copyright (c) 2015 VideoLAN. All rights reserved.
  6. * $Id$
  7. *
  8. * Authors: Tobias Conradi <videolan # tobias-conradi.de>
  9. *
  10. * Refer to the COPYING file of the official project for license.
  11. *****************************************************************************/
  12. #import "VLCLocalNetworkServiceBrowserPlex.h"
  13. #import "VLCNetworkServerBrowserPlex.h"
  14. @implementation VLCLocalNetworkServiceBrowserPlex
  15. - (instancetype)init {
  16. #if TARGET_OS_TV
  17. NSString *name = NSLocalizedString(@"PLEX_SHORT",nil);
  18. #else
  19. NSString *name = NSLocalizedString(@"PLEX_LONG",nil);
  20. #endif
  21. return [super initWithName:name
  22. serviceType:@"_plexmediasvr._tcp."
  23. domain:@""];
  24. }
  25. - (VLCLocalNetworkServiceNetService *)localServiceForNetService:(NSNetService *)netService {
  26. return [[VLCLocalNetworkServicePlex alloc] initWithNetService:netService serviceName:self.name];
  27. }
  28. @end
  29. NSString *const VLCNetworkServerProtocolIdentifierPlex = @"plex";
  30. @implementation VLCLocalNetworkServicePlex
  31. - (UIImage *)icon {
  32. return [UIImage imageNamed:@"PlexServerIcon"];
  33. }
  34. - (id<VLCNetworkServerBrowser>)serverBrowser {
  35. NSNetService *service = self.netService;
  36. if (service.hostName == nil || service.port == 0) {
  37. return nil;
  38. }
  39. NSString *name = service.name;
  40. NSString *hostName = service.hostName;
  41. NSUInteger portNum = service.port;
  42. VLCNetworkServerBrowserPlex *serverBrowser = [[VLCNetworkServerBrowserPlex alloc] initWithName:name host:hostName portNumber:@(portNum) path:@"" authentificication:@""];
  43. return serverBrowser;
  44. }
  45. @end