Skip to content

Instantly share code, notes, and snippets.

- (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];
-(void)playVideo {
[_player play];
}
-(void)pauseVideo {
[_player pause];
}
-(void)videoFinishedPlaying:(NSNotification *)notification {
// Moves the playback cursor to the beginning of the video
[_player seekToTime:kCMTimeZero];
// play the video again
[_player play];
}
-(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
#import "VideoView.h"
#import <AVFoundation/AVFoundation.h>
@interface VideoView ()
@property (nonatomic, strong) AVPlayer *player;
@property (nonatomic, strong) AVPlayerLayer *playerLayer;
- (void)videoFinishedPlaying:(NSNotification *)notification;
@end
#import <UIKit/UIKit.h>
@interface VideoView : UIView
-(instancetype)initWithFrame:(CGRect)frame;
-(void)playVideo;
-(void)pauseVideo;
@end
import Foundation
import RealmSwift
class Friend: Object {
// Specify properties to ignore (Realm won't persist these)
// override static func ignoredProperties() -> [String] {
// return []
// }
let store = Twitter.sharedInstance().sessionStore
if let userID = store.session()?.userID {
store.logOutUserID(userID)
}
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
func facebookSignInButtonTapped(with sender: LoginView) {
FBSDKLoginManager().logIn(withReadPermissions: ["email"], from: self, handler: { (result, error) in
guard result != nil, !(result?.isCancelled)!, error == nil else { return FBSDKLoginManager().logOut()}
if let accessToken = result?.token.tokenString {
let credential = FIRFacebookAuthProvider.credential(withAccessToken: accessToken)
FIRAuth.auth()?.signIn(with: credential) { (user, error) in
if let error = error {
print(error.localizedDescription)