Browse Source

ATV: add 'Open Network Stream' skeleton

Felix Paul Kühne 9 years ago
parent
commit
e27b3f72ab

+ 4 - 1
VLC for Apple TV/AppDelegate.m

@@ -12,6 +12,7 @@
 #import "AppDelegate.h"
 #import "VLCAppSharesTVViewController.h"
 #import "VLCLocalNetworkTVViewController.h"
+#import "VLCOpenNetworkStreamTVViewController.h"
 
 @interface AppDelegate ()
 {
@@ -19,6 +20,7 @@
 
     VLCAppSharesTVViewController *_sharesVC;
     VLCLocalNetworkTVViewController *_localNetworkVC;
+    VLCOpenNetworkStreamTVViewController *_openNetworkVC;
 }
 
 @end
@@ -32,10 +34,11 @@
 
     _localNetworkVC = [[VLCLocalNetworkTVViewController alloc] initWithNibName:nil bundle:nil];
     _sharesVC = [[VLCAppSharesTVViewController alloc] initWithNibName:nil bundle:nil];
+    _openNetworkVC = [[VLCOpenNetworkStreamTVViewController alloc] initWithNibName:nil bundle:nil];
 
     _mainViewController = [[UITabBarController alloc] init];
     _mainViewController.tabBar.backgroundColor = [UIColor VLCOrangeTintColor];
-    _mainViewController.viewControllers = @[_sharesVC, _localNetworkVC];
+    _mainViewController.viewControllers = @[_sharesVC, _localNetworkVC, _openNetworkVC];
 
     self.window.rootViewController = _mainViewController;
 

+ 1 - 0
VLC for Apple TV/TVPrefixHeader.pch

@@ -21,5 +21,6 @@
 #import <TVVLCKit/TVVLCKit.h>
 
 #import "UIColor+Presets.h"
+#import "VLCTVConstants.h"
 
 #endif /* PrefixHeader_pch */

+ 23 - 0
VLC for Apple TV/VLCOpenNetworkStreamTVViewController.h

@@ -0,0 +1,23 @@
+/*****************************************************************************
+ * VLC for iOS
+ *****************************************************************************
+ * Copyright (c) 2015 VideoLAN. All rights reserved.
+ * $Id$
+ *
+ * Authors: Felix Paul Kühne <fkuehne # videolan.org>
+ *
+ * Refer to the COPYING file of the official project for license.
+ *****************************************************************************/
+
+#import <UIKit/UIKit.h>
+
+@interface VLCOpenNetworkStreamTVViewController : UIViewController <UITableViewDataSource, UITableViewDelegate>
+
+@property (readwrite, nonatomic, weak) IBOutlet UILabel *titleLabel;
+@property (readwrite, nonatomic, weak) IBOutlet UILabel *noURLsToShowLabel;
+@property (readwrite, nonatomic, weak) IBOutlet UITextField *playURLField;
+@property (readwrite, nonatomic, weak) IBOutlet UITableView *previouslyPlayedStreamsTableView;
+
+- (IBAction)URLEnteredInField:(id)sender;
+
+@end

+ 96 - 0
VLC for Apple TV/VLCOpenNetworkStreamTVViewController.m

@@ -0,0 +1,96 @@
+/*****************************************************************************
+ * VLC for iOS
+ *****************************************************************************
+ * Copyright (c) 2015 VideoLAN. All rights reserved.
+ * $Id$
+ *
+ * Authors: Felix Paul Kühne <fkuehne # videolan.org>
+ *
+ * Refer to the COPYING file of the official project for license.
+ *****************************************************************************/
+
+#import "VLCOpenNetworkStreamTVViewController.h"
+
+@interface VLCOpenNetworkStreamTVViewController ()
+{
+    NSMutableArray *_recentURLs;
+}
+@end
+
+@implementation VLCOpenNetworkStreamTVViewController
+
+- (NSString *)title
+{
+    return @"Open Network Stream";
+}
+
+- (void)viewDidLoad {
+    [super viewDidLoad];
+
+    NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
+    [notificationCenter addObserver:self
+                           selector:@selector(ubiquitousKeyValueStoreDidChange:)
+                               name:NSUbiquitousKeyValueStoreDidChangeExternallyNotification
+                             object:[NSUbiquitousKeyValueStore defaultStore]];
+
+    /* force store update */
+    NSUbiquitousKeyValueStore *ubiquitousKeyValueStore = [NSUbiquitousKeyValueStore defaultStore];
+    [ubiquitousKeyValueStore synchronize];
+
+    /* fetch data from cloud */
+    _recentURLs = [NSMutableArray arrayWithArray:[[NSUbiquitousKeyValueStore defaultStore] arrayForKey:kVLCRecentURLs]];
+    [self.previouslyPlayedStreamsTableView reloadData];
+    self.noURLsToShowLabel.hidden = _recentURLs.count != 0;
+}
+
+- (void)ubiquitousKeyValueStoreDidChange:(NSNotification *)notification
+{
+    /* TODO: don't blindly trust that the Cloud knows best */
+    _recentURLs = [NSMutableArray arrayWithArray:[[NSUbiquitousKeyValueStore defaultStore] arrayForKey:kVLCRecentURLs]];
+    [self.previouslyPlayedStreamsTableView reloadData];
+    self.noURLsToShowLabel.hidden = _recentURLs.count != 0;
+}
+
+- (void)viewWillDisappear:(BOOL)animated
+{
+    [super viewWillDisappear:animated];
+
+    /* force update before we leave */
+    [[NSUbiquitousKeyValueStore defaultStore] synchronize];
+}
+
+- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
+{
+    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"RecentlyPlayedURLsTableViewCell"];
+    if (!cell) {
+        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"RecentlyPlayedURLsTableViewCell"];
+    }
+
+    NSString *content = _recentURLs[indexPath.row];
+    cell.textLabel.text = [content lastPathComponent];
+    cell.detailTextLabel.text = content;
+
+    return cell;
+}
+
+- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
+{
+    NSLog(@"user tried to play something");
+}
+
+- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
+{
+    return _recentURLs.count;
+}
+
+- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
+{
+    return 1;
+}
+
+- (void)URLEnteredInField:(id)sender
+{
+    NSLog(@"user entered URL '%@'", self.playURLField.text);
+}
+
+@end

+ 73 - 0
VLC for Apple TV/VLCOpenNetworkStreamTVViewController.xib

@@ -0,0 +1,73 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<document type="com.apple.InterfaceBuilder.AppleTV.XIB" version="3.0" toolsVersion="9058" systemVersion="14F1017" targetRuntime="AppleTV" propertyAccessControl="none" useAutolayout="YES">
+    <dependencies>
+        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9048"/>
+    </dependencies>
+    <objects>
+        <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="VLCOpenNetworkStreamTVViewController">
+            <connections>
+                <outlet property="noURLsToShowLabel" destination="9hs-BK-cVI" id="jpj-cD-PRW"/>
+                <outlet property="playURLField" destination="dWa-3n-YCa" id="Eoe-vT-AuM"/>
+                <outlet property="preferredFocusedView" destination="dWa-3n-YCa" id="0Ez-4Z-KFF"/>
+                <outlet property="previouslyPlayedStreamsTableView" destination="v0o-s0-Xaz" id="I1r-ie-lFf"/>
+                <outlet property="titleLabel" destination="SBQ-fX-9BB" id="ZOr-mb-B3l"/>
+                <outlet property="view" destination="iN0-l3-epB" id="Eym-vH-oyN"/>
+            </connections>
+        </placeholder>
+        <placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
+        <view contentMode="scaleToFill" id="iN0-l3-epB">
+            <rect key="frame" x="0.0" y="0.0" width="1920" height="1080"/>
+            <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+            <subviews>
+                <textField opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" placeholder="Enter URL to play" textAlignment="center" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="dWa-3n-YCa">
+                    <rect key="frame" x="710" y="156" width="500" height="66"/>
+                    <constraints>
+                        <constraint firstAttribute="width" constant="500" id="3fz-h4-cGU"/>
+                        <constraint firstAttribute="height" constant="66" id="hDw-hW-ont"/>
+                    </constraints>
+                    <fontDescription key="fontDescription" style="UICTFontTextStyleHeadline"/>
+                    <textInputTraits key="textInputTraits" enablesReturnKeyAutomatically="YES"/>
+                    <connections>
+                        <action selector="URLEnteredInField:" destination="-1" eventType="editingDidEnd" id="ZIV-DP-cGr"/>
+                    </connections>
+                </textField>
+                <tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" style="plain" separatorStyle="default" rowHeight="66" sectionHeaderHeight="40" sectionFooterHeight="40" translatesAutoresizingMaskIntoConstraints="NO" id="v0o-s0-Xaz">
+                    <rect key="frame" x="183" y="301" width="1555" height="700"/>
+                    <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
+                    <constraints>
+                        <constraint firstAttribute="width" constant="1555" id="ELC-Ea-jpC"/>
+                        <constraint firstAttribute="height" constant="700" id="gQs-hK-0At"/>
+                    </constraints>
+                    <connections>
+                        <outlet property="dataSource" destination="-1" id="5xO-BE-h5Q"/>
+                        <outlet property="delegate" destination="-1" id="osW-Kv-1VK"/>
+                    </connections>
+                </tableView>
+                <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Open Network Stream" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="SBQ-fX-9BB">
+                    <rect key="frame" x="718" y="57" width="485" height="60"/>
+                    <fontDescription key="fontDescription" type="system" pointSize="50"/>
+                    <color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
+                    <nil key="highlightedColor"/>
+                </label>
+                <label hidden="YES" opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="No recently played streams" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="9hs-BK-cVI">
+                    <rect key="frame" x="662" y="510" width="596" height="60"/>
+                    <fontDescription key="fontDescription" type="system" pointSize="50"/>
+                    <color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
+                    <nil key="highlightedColor"/>
+                </label>
+            </subviews>
+            <animations/>
+            <color key="backgroundColor" white="0.66666666666666663" alpha="1" colorSpace="calibratedWhite"/>
+            <constraints>
+                <constraint firstItem="dWa-3n-YCa" firstAttribute="top" secondItem="SBQ-fX-9BB" secondAttribute="bottom" constant="39" id="QP5-C5-l6C"/>
+                <constraint firstItem="SBQ-fX-9BB" firstAttribute="centerX" secondItem="iN0-l3-epB" secondAttribute="centerX" id="VXg-dj-wUU"/>
+                <constraint firstItem="9hs-BK-cVI" firstAttribute="centerX" secondItem="iN0-l3-epB" secondAttribute="centerX" id="WOA-cL-SLX"/>
+                <constraint firstItem="v0o-s0-Xaz" firstAttribute="centerX" secondItem="iN0-l3-epB" secondAttribute="centerX" id="elq-bO-Tb3"/>
+                <constraint firstItem="v0o-s0-Xaz" firstAttribute="top" secondItem="dWa-3n-YCa" secondAttribute="bottom" constant="79" id="jCe-Gz-82c"/>
+                <constraint firstItem="9hs-BK-cVI" firstAttribute="centerY" secondItem="iN0-l3-epB" secondAttribute="centerY" id="n8b-cY-wQE"/>
+                <constraint firstItem="dWa-3n-YCa" firstAttribute="centerX" secondItem="iN0-l3-epB" secondAttribute="centerX" id="oFS-xp-QJo"/>
+                <constraint firstAttribute="bottom" secondItem="v0o-s0-Xaz" secondAttribute="bottom" constant="79" id="ydf-eT-5UK"/>
+            </constraints>
+        </view>
+    </objects>
+</document>

+ 22 - 0
VLC for Apple TV/VLCTVConstants.h

@@ -0,0 +1,22 @@
+/*****************************************************************************
+ * VLCConstants.h
+ * VLC for iOS
+ *****************************************************************************
+ * Copyright (c) 2013-2015 VideoLAN. All rights reserved.
+ * $Id$
+ *
+ * Authors: Felix Paul Kühne <fkuehne # videolan.org>
+ *          Jean-Romain Prévost <jr # 3on.fr>
+ *
+ * Refer to the COPYING file of the official project for license.
+ *****************************************************************************/
+
+#define kVLCVersionCodename @"All Along the Watchtower"
+
+#define kVLCApplicationGroupIdentifier @"group.org.videolan.vlc-ios"
+
+#define kVLCRecentURLs @"recent-urls"
+
+#define kSupportedFileExtensions @"\\.(3gp|3gp|3gp2|3gpp|amv|asf|avi|axv|divx|dv|flv|f4v|gvi|gxf|m1v|m2p|m2t|m2ts|m2v|m4v|mks|mkv|moov|mov|mp2v|mp4|mpeg|mpeg1|mpeg2|mpeg4|mpg|mpv|mt2s|mts|mxf|mxg|nsv|nuv|oga|ogg|ogm|ogv|ogx|spx|ps|qt|rec|rm|rmvb|tod|ts|tts|vlc|vob|vro|webm|wm|wmv|wtv|xesc)$"
+#define kSupportedSubtitleFileExtensions @"\\.(srt|sub|cdg|idx|utf|ass|ssa|aqt|jss|psb|rt|smi|txt|smil)$"
+#define kSupportedAudioFileExtensions @"\\.(aac|aiff|aif|amr|aob|ape|axa|caf|flac|it|m2a|m4a|m4b|mka|mlp|mod|mp1|mp2|mp3|mpa|mpc|mpga|oga|ogg|oma|opus|rmi|s3m|spx|tta|voc|vqf|wav|w64|wma|wv|xa|xm)$"

+ 12 - 0
VLC for iOS.xcodeproj/project.pbxproj

@@ -140,6 +140,8 @@
 		7D6B08FC174D773C00A05173 /* Settings.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 7D6B08FB174D773C00A05173 /* Settings.bundle */; };
 		7D711ADA18227A490094E4F0 /* GTMOAuth2ViewTouch.xib in Resources */ = {isa = PBXBuildFile; fileRef = 7D711AD918227A490094E4F0 /* GTMOAuth2ViewTouch.xib */; };
 		7D74177A1AE2D3CE001F1997 /* VLCNavigationController.m in Sources */ = {isa = PBXBuildFile; fileRef = 7D7417791AE2D3CE001F1997 /* VLCNavigationController.m */; };
+		7D7EF3DA1BD56B5900CD4CEE /* VLCOpenNetworkStreamTVViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 7D7EF3D81BD56B5900CD4CEE /* VLCOpenNetworkStreamTVViewController.m */; };
+		7D7EF3DB1BD56B5900CD4CEE /* VLCOpenNetworkStreamTVViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 7D7EF3D91BD56B5900CD4CEE /* VLCOpenNetworkStreamTVViewController.xib */; };
 		7D84E4C61B41AB2800EA7D1F /* VideoToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7D84E4C51B41AB2800EA7D1F /* VideoToolbox.framework */; settings = {ATTRIBUTES = (Weak, ); }; };
 		7D84E4C91B41ABCE00EA7D1F /* CoreMedia.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7D84E4C81B41ABCE00EA7D1F /* CoreMedia.framework */; };
 		7D8968711BD3058800F4EAAD /* LocalAuthentication.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7D8968701BD3058800F4EAAD /* LocalAuthentication.framework */; settings = {ATTRIBUTES = (Weak, ); }; };
@@ -608,6 +610,10 @@
 		7D7417781AE2D3CE001F1997 /* VLCNavigationController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = VLCNavigationController.h; path = Sources/VLCNavigationController.h; sourceTree = SOURCE_ROOT; };
 		7D7417791AE2D3CE001F1997 /* VLCNavigationController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = VLCNavigationController.m; path = Sources/VLCNavigationController.m; sourceTree = SOURCE_ROOT; };
 		7D7DA52F1768A53200C7E95D /* id */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = id; path = id.lproj/Localizable.strings; sourceTree = "<group>"; };
+		7D7EF3D71BD56B5900CD4CEE /* VLCOpenNetworkStreamTVViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VLCOpenNetworkStreamTVViewController.h; sourceTree = "<group>"; };
+		7D7EF3D81BD56B5900CD4CEE /* VLCOpenNetworkStreamTVViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VLCOpenNetworkStreamTVViewController.m; sourceTree = "<group>"; };
+		7D7EF3D91BD56B5900CD4CEE /* VLCOpenNetworkStreamTVViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = VLCOpenNetworkStreamTVViewController.xib; sourceTree = "<group>"; };
+		7D7EF3DC1BD572CE00CD4CEE /* VLCTVConstants.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = VLCTVConstants.h; sourceTree = "<group>"; };
 		7D8139BE18651FEE00D65504 /* cs */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = cs; path = cs.lproj/Localizable.strings; sourceTree = "<group>"; };
 		7D8139C31865206200D65504 /* fa */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = fa; path = fa.lproj/Localizable.strings; sourceTree = "<group>"; };
 		7D8139C8186520A800D65504 /* es-MX */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "es-MX"; path = "es-MX.lproj/Localizable.strings"; sourceTree = "<group>"; };
@@ -1088,11 +1094,14 @@
 			children = (
 				7D2D7FD21BD2F109002D6B6D /* VLC for Apple TV.entitlements */,
 				7D1329421BA1F10100BE647E /* AppDelegate.h */,
+				7D7EF3DC1BD572CE00CD4CEE /* VLCTVConstants.h */,
 				7D1329431BA1F10100BE647E /* AppDelegate.m */,
 				7DC71D1E1BC83058001FACAA /* VLCAppSharesTVViewController.h */,
 				7DC71D1F1BC83058001FACAA /* VLCAppSharesTVViewController.m */,
 				7DC71D231BC830A5001FACAA /* VLCLocalNetworkTVViewController.h */,
 				7DC71D241BC830A5001FACAA /* VLCLocalNetworkTVViewController.m */,
+				7D7EF3D71BD56B5900CD4CEE /* VLCOpenNetworkStreamTVViewController.h */,
+				7D7EF3D81BD56B5900CD4CEE /* VLCOpenNetworkStreamTVViewController.m */,
 				7DC71D281BC83138001FACAA /* xibs */,
 				7D13294E1BA1F10100BE647E /* Assets.xcassets */,
 				7D1329501BA1F10100BE647E /* Info.plist */,
@@ -1567,6 +1576,7 @@
 			children = (
 				7DC71D201BC83058001FACAA /* VLCAppSharesTVViewController.xib */,
 				7DC71D251BC830A5001FACAA /* VLCLocalNetworkTVViewController.xib */,
+				7D7EF3D91BD56B5900CD4CEE /* VLCOpenNetworkStreamTVViewController.xib */,
 			);
 			name = xibs;
 			sourceTree = "<group>";
@@ -2025,6 +2035,7 @@
 				7DC71D271BC830A5001FACAA /* VLCLocalNetworkTVViewController.xib in Resources */,
 				7DC71D221BC83058001FACAA /* VLCAppSharesTVViewController.xib in Resources */,
 				7D13294F1BA1F10100BE647E /* Assets.xcassets in Resources */,
+				7D7EF3DB1BD56B5900CD4CEE /* VLCOpenNetworkStreamTVViewController.xib in Resources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -2169,6 +2180,7 @@
 			buildActionMask = 2147483647;
 			files = (
 				7DC71D211BC83058001FACAA /* VLCAppSharesTVViewController.m in Sources */,
+				7D7EF3DA1BD56B5900CD4CEE /* VLCOpenNetworkStreamTVViewController.m in Sources */,
 				7DC71D261BC830A5001FACAA /* VLCLocalNetworkTVViewController.m in Sources */,
 				7D1329441BA1F10100BE647E /* AppDelegate.m in Sources */,
 				7D1329411BA1F10100BE647E /* main.m in Sources */,