Skip to content

Commit

Permalink
Mac os x support and sample app
Browse files Browse the repository at this point in the history
  • Loading branch information
lilfaf committed Dec 14, 2014
1 parent f0aaad9 commit 77cf780
Show file tree
Hide file tree
Showing 12 changed files with 1,163 additions and 0 deletions.
13 changes: 13 additions & 0 deletions Sample/MacSample/AppDelegate.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//
// AppDelegate.h
// MacSample
//
// Created by Louis Larpin on 14/12/2014.
// Copyright (c) 2014 Louis Larpin. All rights reserved.
//

#import <Cocoa/Cocoa.h>

@interface AppDelegate : NSObject <NSApplicationDelegate>
@end

31 changes: 31 additions & 0 deletions Sample/MacSample/AppDelegate.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
//
// AppDelegate.m
// MacSample
//
// Created by Louis Larpin on 14/12/2014.
// Copyright (c) 2014 Louis Larpin. All rights reserved.
//

#import "MainWindowController.h"
#import "AppDelegate.h"

@interface AppDelegate ()

@property(strong, nonatomic) MainWindowController *mainWindowController;

@end

@implementation AppDelegate

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
// Insert code here to initialize your application

self.mainWindowController = [[MainWindowController alloc] initWithWindowNibName:@"MainWindow"];
[self.mainWindowController showWindow:self];
}

- (void)applicationWillTerminate:(NSNotification *)aNotification {
// Insert code here to tear down your application
}

@end
667 changes: 667 additions & 0 deletions Sample/MacSample/Base.lproj/MainMenu.xib

Large diffs are not rendered by default.

58 changes: 58 additions & 0 deletions Sample/MacSample/Images.xcassets/AppIcon.appiconset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{
"images" : [
{
"idiom" : "mac",
"size" : "16x16",
"scale" : "1x"
},
{
"idiom" : "mac",
"size" : "16x16",
"scale" : "2x"
},
{
"idiom" : "mac",
"size" : "32x32",
"scale" : "1x"
},
{
"idiom" : "mac",
"size" : "32x32",
"scale" : "2x"
},
{
"idiom" : "mac",
"size" : "128x128",
"scale" : "1x"
},
{
"idiom" : "mac",
"size" : "128x128",
"scale" : "2x"
},
{
"idiom" : "mac",
"size" : "256x256",
"scale" : "1x"
},
{
"idiom" : "mac",
"size" : "256x256",
"scale" : "2x"
},
{
"idiom" : "mac",
"size" : "512x512",
"scale" : "1x"
},
{
"idiom" : "mac",
"size" : "512x512",
"scale" : "2x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
34 changes: 34 additions & 0 deletions Sample/MacSample/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIconFile</key>
<string></string>
<key>CFBundleIdentifier</key>
<string>louis.larpin.$(PRODUCT_NAME:rfc1034identifier)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSMinimumSystemVersion</key>
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2014 Louis Larpin. All rights reserved.</string>
<key>NSMainNibFile</key>
<string>MainMenu</string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
</dict>
</plist>
71 changes: 71 additions & 0 deletions Sample/MacSample/MainWindow.xib
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="6254" systemVersion="13F34" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.AVKitIBPlugin" version="6254"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="6254"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="MainWindowController">
<connections>
<outlet property="playerView" destination="rfM-L3-aFx" id="QYn-OW-4fr"/>
<outlet property="qualitySeg" destination="yHQ-iH-HYR" id="02q-6G-31u"/>
<outlet property="textURL" destination="qj8-EU-bhe" id="2Tn-FS-ZMr"/>
<outlet property="window" destination="F0z-JX-Cv5" id="gIp-Ho-8D9"/>
</connections>
</customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
<window title="Window" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" oneShot="NO" releasedWhenClosed="NO" animationBehavior="default" id="F0z-JX-Cv5">
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
<rect key="contentRect" x="196" y="240" width="578" height="363"/>
<rect key="screenRect" x="0.0" y="0.0" width="1440" height="900"/>
<view key="contentView" id="se5-gp-TjO">
<rect key="frame" x="0.0" y="0.0" width="578" height="363"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="nlo-2n-FoI">
<rect key="frame" x="492" y="7" width="66" height="25"/>
<buttonCell key="cell" type="roundTextured" title="Play" bezelStyle="texturedRounded" alignment="center" state="on" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="kIP-Ot-fn0">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="playVideo:" target="-2" id="VUR-dv-dkq"/>
</connections>
</button>
<textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="qj8-EU-bhe">
<rect key="frame" x="20" y="8" width="291" height="23"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" title="http://vimeo.com/58600663" placeholderString="" drawsBackground="YES" id="o7L-xz-cIa">
<font key="font" metaFont="system"/>
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<avPlayerView fixedFrame="YES" controlsStyle="none" translatesAutoresizingMaskIntoConstraints="NO" id="rfM-L3-aFx">
<rect key="frame" x="0.0" y="39" width="578" height="324"/>
</avPlayerView>
<segmentedControl verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="yHQ-iH-HYR">
<rect key="frame" x="317" y="7" width="169" height="24"/>
<segmentedCell key="cell" borderStyle="border" alignment="left" style="rounded" trackingMode="selectOne" id="BKa-8I-9SX">
<font key="font" metaFont="system"/>
<segments>
<segment label="Low"/>
<segment label="Standard" selected="YES" tag="1"/>
<segment label="HD"/>
</segments>
</segmentedCell>
<connections>
<action selector="changeQuality:" target="-2" id="QDN-ex-9zF"/>
</connections>
</segmentedControl>
</subviews>
</view>
<connections>
<outlet property="delegate" destination="-2" id="VVk-9V-9Ie"/>
</connections>
<point key="canvasLocation" x="189" y="193.5"/>
</window>
</objects>
</document>
23 changes: 23 additions & 0 deletions Sample/MacSample/MainWindowController.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//
// MainWindowController.h
// Sample
//
// Created by Louis Larpin on 14/12/2014.
// Copyright (c) 2014 Louis Larpin. All rights reserved.
//

#import <Cocoa/Cocoa.h>
#import <Foundation/Foundation.h>
#import <CoreMedia/CoreMedia.h>
#import <AVKit/AVKit.h>
#import <AVFoundation/AVFoundation.h>

#import "YTVimeoExtractor.h"

@interface MainWindowController : NSWindowController
@property (weak) IBOutlet NSTextField *textURL;
@property (weak) IBOutlet NSSegmentedControl *qualitySeg;

- (IBAction)playVideo:(id)sender;
- (IBAction)changeQuality:(id)sender;
@end
67 changes: 67 additions & 0 deletions Sample/MacSample/MainWindowController.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
//
// MainWindowController.m
// Sample
//
// Created by Louis Larpin on 14/12/2014.
// Copyright (c) 2014 Louis Larpin. All rights reserved.
//

#import "MainWindowController.h"

@interface MainWindowController ()

@property (nonatomic) AVPlayer *videoPlayer;
@property (weak) IBOutlet AVPlayerView *playerView;


@property (strong, nonatomic) YTVimeoExtractor *extractor;
@property (nonatomic) YTVimeoVideoQuality quality;

@end

@implementation MainWindowController

- (void)windowDidLoad {
[super windowDidLoad];

self.quality = YTVimeoVideoQualityMedium;
}

- (void)windowWillClose:(NSNotification *)notification {
[self.videoPlayer pause];
[self.playerView removeFromSuperviewWithoutNeedingDisplay];
//self.videoPlayer.delegate = nil;
self.videoPlayer = nil;
self.playerView = nil;
}

- (IBAction)playVideo:(id)sender {
[YTVimeoExtractor fetchVideoURLFromURL:self.textURL.stringValue quality:self.quality completionHandler:^(NSURL *videoURL, NSError *error, YTVimeoVideoQuality quality) {
if (error) {
NSLog(@"Error : %@", [error localizedDescription]);
} else if (videoURL) {
NSLog(@"Extracted url : %@", [videoURL absoluteString]);

self.videoPlayer = [[AVPlayer alloc] initWithURL:videoURL];
self.playerView.player = self.videoPlayer;
[self.videoPlayer play];
}
}];
}

- (IBAction)changeQuality:(id)sender {
switch (self.qualitySeg.selectedSegment) {
case 0:
self.quality = YTVimeoVideoQualityLow;
break;
case 1:
self.quality = YTVimeoVideoQualityMedium;
break;
case 2:
self.quality = YTVimeoVideoQualityHigh;

default:
break;
}
}
@end
13 changes: 13 additions & 0 deletions Sample/MacSample/main.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//
// main.m
// MacSample
//
// Created by Louis Larpin on 14/12/2014.
// Copyright (c) 2014 Louis Larpin. All rights reserved.
//

#import <Cocoa/Cocoa.h>

int main(int argc, const char * argv[]) {
return NSApplicationMain(argc, argv);
}
Loading

0 comments on commit 77cf780

Please sign in to comment.