This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)viewDidLoad { | |
[super viewDidLoad]; | |
[self.view setBackgroundColor:[UIColor whiteColor]]; | |
_videoBackgroundView = [[VideoView alloc] initWithFrame:self.view.frame]; | |
[self.view addSubview:_videoBackgroundView]; | |
[self setupViews]; | |
} | |
-(void)viewWillAppear:(BOOL)animated { | |
[super viewWillAppear:animated]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-(void)playVideo { | |
[_player play]; | |
} | |
-(void)pauseVideo { | |
[_player pause]; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-(void)videoFinishedPlaying:(NSNotification *)notification { | |
// Moves the playback cursor to the beginning of the video | |
[_player seekToTime:kCMTimeZero]; | |
// play the video again | |
[_player play]; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-(instancetype)initWithFrame:(CGRect)frame { | |
self = [super initWithFrame:frame]; | |
if(self) { | |
[self setBackgroundColor:[UIColor whiteColor]]; | |
// Find the video file | |
NSString *videoPath = [[NSBundle mainBundle] pathForResource:@"drop" ofType:@"mp4"]; | |
// Create a new URL based on the video location |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import "VideoView.h" | |
#import <AVFoundation/AVFoundation.h> | |
@interface VideoView () | |
@property (nonatomic, strong) AVPlayer *player; | |
@property (nonatomic, strong) AVPlayerLayer *playerLayer; | |
- (void)videoFinishedPlaying:(NSNotification *)notification; | |
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <UIKit/UIKit.h> | |
@interface VideoView : UIView | |
-(instancetype)initWithFrame:(CGRect)frame; | |
-(void)playVideo; | |
-(void)pauseVideo; | |
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
import RealmSwift | |
class Friend: Object { | |
// Specify properties to ignore (Realm won't persist these) | |
// override static func ignoredProperties() -> [String] { | |
// return [] | |
// } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let store = Twitter.sharedInstance().sessionStore | |
if let userID = store.session()?.userID { | |
store.logOutUserID(userID) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class func signInWithTwitter() { | |
Twitter.sharedInstance().logIn(withMethods: .webBased) { (session, error) in | |
if error != nil { | |
print(error?.localizedDescription) | |
}else{ | |
if session != nil { | |
if let unwrappedSession = session { | |
let token = unwrappedSession.authToken | |
let secret = unwrappedSession.authTokenSecret |
NewerOlder