Repository: vizllx/DraggableYoutubeFloatingVideo Branch: master Commit: d2197c01e5e7 Files: 31 Total size: 110.7 KB Directory structure: gitextract_fxps1y3q/ ├── .gitignore ├── DraggableFloatingViewController.podspec ├── LICENSE.md ├── README.md ├── YouTubeDraggableVideo/ │ ├── AppDelegate.h │ ├── AppDelegate.m │ ├── Base.lproj/ │ │ └── LaunchScreen.xib │ ├── Demo/ │ │ ├── AppDelegate.h │ │ ├── AppDelegate.m │ │ ├── AppDelegate.swift │ │ ├── FirstViewController.swift │ │ ├── NSTimerHelper.swift │ │ ├── SecondViewController.swift │ │ ├── VideoDetailViewController.swift │ │ └── YouTubeDraggableVideo-Bridging-Header.h │ ├── Images.xcassets/ │ │ ├── AppIcon.appiconset/ │ │ │ └── Contents.json │ │ ├── DownArrow.imageset/ │ │ │ └── Contents.json │ │ └── test.imageset/ │ │ └── Contents.json │ ├── Info.plist │ ├── Source/ │ │ ├── DraggableFloatingViewController.h │ │ └── DraggableFloatingViewController.m │ └── main.m ├── YouTubeDraggableVideo.xcodeproj/ │ ├── project.pbxproj │ ├── project.xcworkspace/ │ │ ├── contents.xcworkspacedata │ │ ├── xcshareddata/ │ │ │ └── YouTubeDraggableVideo.xccheckout │ │ └── xcuserdata/ │ │ └── sandeepmukherjee.xcuserdatad/ │ │ └── UserInterfaceState.xcuserstate │ └── xcuserdata/ │ ├── Takuya.xcuserdatad/ │ │ └── xcschemes/ │ │ └── YouTubeDraggableVideo.xcscheme │ └── sandeepmukherjee.xcuserdatad/ │ └── xcschemes/ │ ├── YouTubeDraggableVideo.xcscheme │ └── xcschememanagement.plist └── YouTubeDraggableVideoTests/ ├── Info.plist └── YouTubeDraggableVideoTests.m ================================================ FILE CONTENTS ================================================ ================================================ FILE: .gitignore ================================================ *.xcbkptlist ================================================ FILE: DraggableFloatingViewController.podspec ================================================ # # Be sure to run `pod spec lint DraggableFloatingViewController.podspec' to ensure this is a # valid spec and to remove all comments including this before submitting the spec. # # To learn more about Podspec attributes see http://docs.cocoapods.org/specification.html # To see working Podspecs in the CocoaPods repo see https://github.com/CocoaPods/Specs/ # Pod::Spec.new do |s| # ――― Spec Metadata ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # # # These will help people to find your library, and whilst it # can feel like a chore to fill in it's definitely to your advantage. The # summary should be tweet-length, and the description more in depth. # s.name = "DraggableFloatingViewController" # s.version = "v1.0" s.summary = "A short description of DraggableFloatingViewController." s.description = <<-DESC A longer description of DraggableFloatingViewController in Markdown format. * Think: Why did you write this? What is the focus? What does it do? * CocoaPods will be using this to generate tags, and improve search results. * Try to keep it short, snappy and to the point. * Finally, don't worry about the indent, CocoaPods strips it! DESC s.homepage = "http://github.com/entotsu/DraggableFloatingViewController" # s.screenshots = "www.example.com/screenshots_1.gif", "www.example.com/screenshots_2.gif" # ――― Spec License ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # # # Licensing your code is important. See http://choosealicense.com for more info. # CocoaPods will detect a license file if there is a named LICENSE* # Popular ones are 'MIT', 'BSD' and 'Apache License, Version 2.0'. # s.license = "MIT (example)" # s.license = { :type => "MIT", :file => "FILE_LICENSE" } # ――― Author Metadata ――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # # # Specify the authors of the library, with email addresses. Email addresses # of the authors are extracted from the SCM log. E.g. $ git log. CocoaPods also # accepts just a name if you'd rather not provide an email address. # # Specify a social_media_url where others can refer to, for example a twitter # profile URL. # s.author = { "Sandeep Mukherjee" => "vizllx@gmail.com" } # Or just: s.author = "Sandeep Mukherjee" # s.authors = { "Sandeep Mukherjee" => "vizllx@gmail.com" } # s.social_media_url = "http://github.com/vizllx" # ――― Platform Specifics ――――――――――――――――――――――――――――――――――――――――――――――――――――――― # # # If this Pod runs only on iOS or OS X, then specify the platform and # the deployment target. You can optionally include the target after the platform. # # s.platform = :ios s.platform = :ios, "6.0" # When using multiple platforms # s.ios.deployment_target = "5.0" # s.osx.deployment_target = "10.7" s.source = { :git => "http://github.com/entotsu/DraggableFloatingViewController.git", :tag => "v1.0" } s.source_files = "Classes", "YouTubeDraggableVideo/Source/*.{h,m}" # s.exclude_files = "Classes/Exclude" # s.public_header_files = "Classes/**/*.h" # ――― Resources ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # # # A list of resources included with the Pod. These are copied into the # target bundle with a build phase script. Anything else will be cleaned. # You can preserve files from being cleaned, please don't preserve # non-essential files like tests, examples and documentation. # # s.resource = "icon.png" # s.resources = "Resources/*.png" # s.preserve_paths = "FilesToSave", "MoreFilesToSave" # ――― Project Linking ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # # # Link your library with frameworks, or libraries. Libraries do not include # the lib prefix of their name. # # s.framework = "SomeFramework" # s.frameworks = "SomeFramework", "AnotherFramework" # s.library = "iconv" # s.libraries = "iconv", "xml2" # ――― Project Settings ――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # # # If your library depends on compiler flags you can set them in the xcconfig hash # where they will only apply to your library. If you depend on other Podspecs # you can include multiple dependencies to ensure it works. # s.requires_arc = true # s.xcconfig = { "HEADER_SEARCH_PATHS" => "$(SDKROOT)/usr/include/libxml2" } # s.dependency "JSONKit", "~> 1.4" end ================================================ FILE: LICENSE.md ================================================ The MIT License (MIT) Copyright (c) 2015 Sandeep Mukherjee Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ================================================ FILE: README.md ================================================ # DraggableFloatingViewController ### Like YouTube app DraggableFloatingViewController allows you to play videos on a floating mini window at the bottom of your screen from sites like YouTube, Vimeo & Facebook or custom video , yes you have to prepare your video view for that. How it works ------------ The view will animate the view just like Youtube mobile app, while tapping on video a UIView pops up from right corner of the screen and the view can be dragged to right corner through Pan Gesture and more features are there as Youtube iOS app Screenshot ------------ ![Output sample](https://github.com/entotsu/DraggableFloatingViewController/raw/master/Screenshot2.gif) # Usage ## extend this class #### set your video view in "viewDidLoad" of subclass ```swift override func viewDidLoad() { self.setupViewsWithVideoView(yourMoivePlayer.view, //UIView videoViewHeight: yourPlayerHeight, //CGFloat minimizeButton: yourButton //UIButton ) // add your view to bodyView self.bodyView.addSubview(yourView) } ``` ## in parent view controller ### show ```swift func showSecondController() { removeDraggableFloatingViewController() self.videoViewController = VideoDetailViewController() self.videoViewController.delegate = self self.videoViewController.showVideoViewControllerOnParentVC(self) } ``` ### dismiss ```swift func removeDraggableFloatingViewController() { if self.videoViewController != nil { self.videoViewController.removeAllViews() self.videoViewController = nil } } ``` -------------------------------------------------- # Please edit "info.plist" To disable swipe down gesture of Notification Center, you need to edit "info.plist" to hide status bar. http://stackoverflow.com/questions/18059703/cannot-hide-status-bar-in-ios7 ![editInfoPlist](http://i.stack.imgur.com/dM32P.png "editInfoPlist") -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- # please override if you want ```swift override func didExpand() { showVideoControl() } override func didMinimize() { hideVideoControl() } ``` ------------------------------------------------------- ## Please see demo app If you want to use this, you have to check this demo app. ================================================ FILE: YouTubeDraggableVideo/AppDelegate.h ================================================ // // AppDelegate.h // test // // Created by Takuya Okamoto on 2015/06/19. // Copyright (c) 2015年 Uniface. All rights reserved. // #import @interface AppDelegate : UIResponder @property (strong, nonatomic) UIWindow *window; @end ================================================ FILE: YouTubeDraggableVideo/AppDelegate.m ================================================ // // AppDelegate.m // test // // Created by Takuya Okamoto on 2015/06/19. // Copyright (c) 2015年 Uniface. All rights reserved. // #import "AppDelegate.h" @interface AppDelegate () @end @implementation AppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Override point for customization after application launch. return YES; } - (void)applicationWillResignActive:(UIApplication *)application { // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. } - (void)applicationDidEnterBackground:(UIApplication *)application { // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. } - (void)applicationWillEnterForeground:(UIApplication *)application { // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. } - (void)applicationDidBecomeActive:(UIApplication *)application { // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. } - (void)applicationWillTerminate:(UIApplication *)application { // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. } @end ================================================ FILE: YouTubeDraggableVideo/Base.lproj/LaunchScreen.xib ================================================ ================================================ FILE: YouTubeDraggableVideo/Demo/AppDelegate.h ================================================ // // AppDelegate.h // test // // Created by Sandeep Mukherjee on 02/02/15. // Copyright (c) 2015 Sandeep Mukherjee. All rights reserved. // #import @class VideoDetailViewController; @interface AppDelegate : UIResponder @property (strong, nonatomic) UIWindow *window; @property (strong, nonatomic) VideoDetailViewController *videoViewController; @end ================================================ FILE: YouTubeDraggableVideo/Demo/AppDelegate.m ================================================ // // AppDelegate.m // test // // Created by Sandeep Mukherjee on 02/02/15. // Copyright (c) 2015 Sandeep Mukherjee. All rights reserved. // #import "AppDelegate.h" #import "YouTubeDraggableVideo-Swift.h" @interface AppDelegate () @end @implementation AppDelegate //+ (VideoDetailViewController) video // static func appDelegate() -> AppDelegate? { // return UIApplication.sharedApplication().delegate as? AppDelegate // } + (AppDelegate *) appDelegate { return [[UIApplication sharedApplication] delegate]; } //+ (VideoDetailViewController *) videoController { // return [[[UIApplication sharedApplication] delegate] videoViewController]; //} - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { self.videoViewController = [[VideoDetailViewController alloc] init]; self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; self.window.rootViewController = [[FirstViewController alloc] init]; [self.window makeKeyAndVisible]; return YES; } - (void)applicationWillResignActive:(UIApplication *)application { // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. } - (void)applicationDidEnterBackground:(UIApplication *)application { // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. } - (void)applicationWillEnterForeground:(UIApplication *)application { // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. } - (void)applicationDidBecomeActive:(UIApplication *)application { // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. } - (void)applicationWillTerminate:(UIApplication *)application { // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. } @end ================================================ FILE: YouTubeDraggableVideo/Demo/AppDelegate.swift ================================================ //// //// AppDelegate.swift //// APlayerViewController //// // Created by Sandeep Mukherjee on 02/02/15. // Copyright (c) 2015 Sandeep Mukherjee. All rights reserved. // // //import UIKit // //@UIApplicationMain //class AppDelegate: UIResponder, UIApplicationDelegate { // // var window: UIWindow? // var videoViewController = VideoDetailViewController() // // // static func appDelegate() -> AppDelegate? { // return UIApplication.sharedApplication().delegate as? AppDelegate // } // // static func videoController() -> VideoDetailViewController { // return appDelegate()!.videoViewController // } // // static func getWindow() -> UIWindow { // return appDelegate()!.window! // } // // // func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { // // Override point for customization after application launch. // self.window = UIWindow(frame: UIScreen.mainScreen().bounds) // self.window!.rootViewController = FirstViewController() // self.window!.makeKeyAndVisible() // return true // } // // func applicationWillResignActive(application: UIApplication) { // // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. // // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. // } // // func applicationDidEnterBackground(application: UIApplication) { // // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. // // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. // } // // func applicationWillEnterForeground(application: UIApplication) { // // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. // } // // func applicationDidBecomeActive(application: UIApplication) { // // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. // } // // func applicationWillTerminate(application: UIApplication) { // // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. // } // // //} // ================================================ FILE: YouTubeDraggableVideo/Demo/FirstViewController.swift ================================================ // // FirstViewController.swift // YouTubeDraggableVideo // // Created by Sandeep Mukherjee on 02/02/15. // Copyright (c) 2015 Sandeep Mukherjee. All rights reserved. // import UIKit class FirstViewController: UIViewController { override func viewDidLoad() { self.view.backgroundColor = .white let btn = UIButton() btn.frame = CGRect(x: self.view.center.x-100, y: self.view.center.y, width: 200, height: 100) btn.backgroundColor = .blue btn.setTitle("Show Video Screen", for: .normal) btn.addTarget(self, action: #selector(onTapShowButton), for: .touchUpInside) self.view.addSubview(btn) } @objc func onTapShowButton() { (UIApplication.shared.delegate as! AppDelegate).videoViewController.show() //👈 } override var prefersStatusBarHidden: Bool { return false } } ================================================ FILE: YouTubeDraggableVideo/Demo/NSTimerHelper.swift ================================================ // // NSTimerHelper.swift // YouTubeDraggableVideo // // Created by Sandeep Mukherjee on 02/02/15. // Copyright (c) 2015 Sandeep Mukherjee. All rights reserved. // import Foundation extension Timer { static func schedule(delay: TimeInterval, handler: @escaping(Timer?) -> Void) -> Timer? { let fireDate = delay + CFAbsoluteTimeGetCurrent() let timer = CFRunLoopTimerCreateWithHandler(kCFAllocatorDefault, fireDate, 0, 0, 0, handler) CFRunLoopAddTimer(CFRunLoopGetCurrent(), timer, CFRunLoopMode.commonModes) return timer } static func schedule(repeatInterval interval: TimeInterval, handler: @escaping(Timer?) -> Void) -> Timer? { let fireDate = interval + CFAbsoluteTimeGetCurrent() let timer = CFRunLoopTimerCreateWithHandler(kCFAllocatorDefault, fireDate, interval, 0, 0, handler) CFRunLoopAddTimer(CFRunLoopGetCurrent(), timer, CFRunLoopMode.commonModes) return timer } } // Usage: //var count = 0 //NSTimer.schedule(repeatInterval: 1) { timer in // println(++count) // if count >= 10 { // timer.invalidate() // } //} // //NSTimer.schedule(delay: 5) { timer in // println("5 seconds") //} ================================================ FILE: YouTubeDraggableVideo/Demo/SecondViewController.swift ================================================ // // SecondViewController.swift // YouTubeDraggableVideo // // Created by Sandeep Mukherjee on 02/02/15. // Copyright (c) 2015 Sandeep Mukherjee. All rights reserved. // import Foundation class SecondViewController: UIViewController { @objc func onTapButton() { (UIApplication.shared.delegate as! AppDelegate).videoViewController.show()//👈 } @objc func onTapDismissButton() { _ = self.presentingViewController self.dismiss(animated: true, completion: nil) // NSTimer.schedule(delay: 0.2) { timer in // AppDelegate.videoController().changeParentVC(parentVC)//👈 // } } override func viewDidLoad() { self.view.backgroundColor = .white let btn = UIButton() btn.frame = CGRect(x: 10, y: 10, width: 100, height: 100) btn.backgroundColor = .blue btn.addTarget(self, action: #selector(onTapButton), for: .touchUpInside) self.view.addSubview(btn) let dismissBtn = UIButton() dismissBtn.frame = CGRect(x: 150, y: 150, width: 100, height: 100) dismissBtn.backgroundColor = .orange dismissBtn.addTarget(self, action: #selector(onTapDismissButton), for: .touchUpInside) self.view.addSubview(dismissBtn) } } ================================================ FILE: YouTubeDraggableVideo/Demo/VideoDetailViewController.swift ================================================ // // VideoViewController.swift // YouTubeDraggableVideo // // Created by Sandeep Mukherjee on 02/02/15. // Copyright (c) 2015 Sandeep Mukherjee. All rights reserved. // import Foundation import UIKit @objc class VideoDetailViewController: DraggableFloatingViewController { var moviePlayer: MPMoviePlayerController! private let loadingSpinner = UIActivityIndicatorView() override func viewDidLoad() { super.viewDidLoad() moviePlayer = MPMoviePlayerController() self.setupViews(withVideoView: moviePlayer.view, videoViewHeight: 160)//, minimizeButton: minimizeButton) setupMoviePlayer() NotificationCenter.default.addObserver(self, selector: #selector(onOrientationChanged), name: UIDevice.orientationDidChangeNotification, object: nil) // design controller view let minimizeButton = UIButton() minimizeButton.frame = CGRect(x: 0, y: 0, width: 44, height: 44) minimizeButton.setImage(UIImage(named: "DownArrow"), for: .normal) minimizeButton.addTarget(self, action: #selector(onTapMinimizeButton), for: .touchUpInside) self.controllerView.addSubview(minimizeButton) let testControl = UILabel() testControl.frame = CGRect(x: 100, y: 5, width: 150, height: 40) testControl.text = "controller view" testControl.textColor = .white self.controllerView.addSubview(testControl) // design body view self.bodyView.backgroundColor = .gray self.bodyView.layer.borderColor = UIColor.blue.cgColor self.bodyView.layer.borderWidth = 2.0 let testView = UILabel() testView.frame = CGRect(x: 20, y: 10, width: 100, height: 40) testView.text = "body view" testView.textColor = .blue self.bodyView.addSubview(testView) // design message view self.messageView.backgroundColor = UIColor.black.withAlphaComponent(0.8) loadingSpinner.frame = CGRect(x: 0, y: 0, width: 50, height: 50) loadingSpinner.center = self.messageView.center loadingSpinner.hidesWhenStopped = false loadingSpinner.style = .white self.messageView.addSubview(loadingSpinner) } override func didDisappear() { moviePlayer.pause() } override func didReAppear() { setupMoviePlayer() } override var prefersStatusBarHidden: Bool { return true } func onTapButton() { print("onTapButton") } override func showMessageView() { loadingSpinner.startAnimating() super.showMessageView() } override func hideMessageView() { super.hideMessageView() loadingSpinner.stopAnimating() } override func didFullExpandByGesture() { showVideoControl() } override func didExpand() { print("didExpand") showVideoControl() } override func didMinimize() { print("didMinimized") hideVideoControl() } override func didStartMinimizeGesture() { print("didStartMinimizeGesture") } @objc func onTapMinimizeButton() { self.minimizeView() } // -------------------------------------------------------------------------------------------------- func setupMoviePlayer() { // setupMovie let url = NSURL.fileURL(withPath: Bundle.main.path(forResource: "test", ofType: "mp4")!) moviePlayer.contentURL = url moviePlayer.isFullscreen = false moviePlayer.controlStyle = .none moviePlayer.repeatMode = .none moviePlayer.prepareToPlay() // play let seconds = 1.0 let delay = seconds * Double(NSEC_PER_SEC)// nanoseconds per seconds DispatchQueue.main.asyncAfter(deadline: .now() + delay) { self.moviePlayer.play() } // for movie loop NotificationCenter.default.addObserver(self, selector: #selector(moviePlayBackDidFinish), name: NSNotification.Name.MPMoviePlayerPlaybackDidFinish, object: moviePlayer) } // movie loop @objc func moviePlayBackDidFinish(notification: NSNotification) { print("moviePlayBackDidFinish:") moviePlayer.play() removeObserver(aName: NSNotification.Name.MPMoviePlayerPlaybackDidFinish.rawValue) } // ----------------------------- events ----------------------------------------------- // MARK: Orientation @objc func onOrientationChanged() { let orientation: UIInterfaceOrientation = getOrientation() switch orientation { case .portrait, .portraitUpsideDown: print("portrait") exitFullScreen() case .landscapeLeft, .landscapeRight: print("landscape") goFullScreen() default: print("no action for this orientation:" + orientation.rawValue.description) } } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() } // --------------------------------- util ------------------------------------------ // MARK: FullScreen Method func isFullScreen() -> Bool { // println("isFullScreen: " + String(stringInterpolationSegment: moviePlayer.fullscreen)) return moviePlayer.isFullscreen } func goFullScreen() { if !isFullScreen() { // println("goFullScreen") moviePlayer.controlStyle = MPMovieControlStyle.fullscreen moviePlayer.isFullscreen = true addObserver(selector: #selector(willExitFullScreen), name: NSNotification.Name.MPMoviePlayerWillExitFullscreen.rawValue) } } func exitFullScreen() { if isFullScreen() { // println("exit fullscreen"); moviePlayer.isFullscreen = false } } @objc func willExitFullScreen() { // println("willExitFullScreen") if isLandscape() { setOrientation(orientation: .portrait) } removeObserver(aName: NSNotification.Name.MPMoviePlayerWillExitFullscreen.rawValue) } // FIXIT: Don't work func showVideoControl() { // println("showVideoControl"); moviePlayer.controlStyle = .none } // FIXIT: Don't work func hideVideoControl() { // println("hideVideoControl") moviePlayer.controlStyle = .none } //----------------------------------------------------------------------------------- func getOrientation() -> UIInterfaceOrientation { return UIApplication.shared.statusBarOrientation } func setOrientation(orientation: UIInterfaceOrientation) { let orientationNum: NSNumber = NSNumber(value: orientation.rawValue) UIDevice.current.setValue(orientationNum, forKey: "orientation") } func addObserver(selector aSelector: Selector, name aName: String) { NotificationCenter.default.addObserver(self, selector: aSelector, name:NSNotification.Name(aName), object: nil) } func removeObserver(aName: String) { NotificationCenter.default.removeObserver(self, name: NSNotification.Name(aName), object: nil) } func isLandscape() -> Bool { if (UIApplication.shared.statusBarOrientation.isLandscape) { return true } else { return false } } } ================================================ FILE: YouTubeDraggableVideo/Demo/YouTubeDraggableVideo-Bridging-Header.h ================================================ // // Use this file to import your target's public headers that you would like to expose to Swift. // #import "DraggableFloatingViewController.h" #import "AppDelegate.h" ================================================ FILE: YouTubeDraggableVideo/Images.xcassets/AppIcon.appiconset/Contents.json ================================================ { "images" : [ { "idiom" : "iphone", "scale" : "2x", "size" : "20x20" }, { "idiom" : "iphone", "scale" : "3x", "size" : "20x20" }, { "idiom" : "iphone", "scale" : "2x", "size" : "29x29" }, { "idiom" : "iphone", "scale" : "3x", "size" : "29x29" }, { "idiom" : "iphone", "scale" : "2x", "size" : "40x40" }, { "idiom" : "iphone", "scale" : "3x", "size" : "40x40" }, { "idiom" : "iphone", "scale" : "2x", "size" : "60x60" }, { "idiom" : "iphone", "scale" : "3x", "size" : "60x60" }, { "idiom" : "ios-marketing", "scale" : "1x", "size" : "1024x1024" } ], "info" : { "author" : "xcode", "version" : 1 } } ================================================ FILE: YouTubeDraggableVideo/Images.xcassets/DownArrow.imageset/Contents.json ================================================ { "images" : [ { "idiom" : "universal", "scale" : "1x", "filename" : "DownArrow~iPhone.png" }, { "idiom" : "universal", "scale" : "2x", "filename" : "DownArrow~iPhone-667h@2x.png" }, { "idiom" : "universal", "scale" : "3x", "filename" : "DownArrow~iPhone-736h@3x.png" } ], "info" : { "version" : 1, "author" : "xcode" } } ================================================ FILE: YouTubeDraggableVideo/Images.xcassets/test.imageset/Contents.json ================================================ { "images" : [ { "idiom" : "universal", "scale" : "1x", "filename" : "test.jpg" }, { "idiom" : "universal", "scale" : "2x" }, { "idiom" : "universal", "scale" : "3x" } ], "info" : { "version" : 1, "author" : "xcode" } } ================================================ FILE: YouTubeDraggableVideo/Info.plist ================================================ CFBundleDevelopmentRegion en CFBundleExecutable $(EXECUTABLE_NAME) CFBundleIdentifier $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion 6.0 CFBundleName $(PRODUCT_NAME) CFBundlePackageType APPL CFBundleShortVersionString 1.0 CFBundleSignature ???? CFBundleVersion 1 LSRequiresIPhoneOS UILaunchStoryboardName LaunchScreen UIRequiredDeviceCapabilities armv7 UISupportedInterfaceOrientations UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight UIViewControllerBasedStatusBarAppearance ================================================ FILE: YouTubeDraggableVideo/Source/DraggableFloatingViewController.h ================================================ // // BSVideoDetailController.h // YouTubeDraggableVideo // // Created by Sandeep Mukherjee on 02/02/15. // Copyright (c) 2015 Sandeep Mukherjee. All rights reserved. // #import #import @protocol DraggableFloatingViewControllerDelegate @required - (void)removeDraggableFloatingViewController; @end // please extend @interface DraggableFloatingViewController : UIViewController // ---------- use from SubClass ------------------------ // please add subview on this @property(nonatomic, strong) UIView *bodyView; //please add controller on this @property(nonatomic, strong) UIView *controllerView; //please add loading spiner on this @property(nonatomic, strong) UIView *messageView; // please call from "viewDidLoad" from sub class - (void) setupViewsWithVideoView: (UIView *)vView videoViewHeight: (CGFloat) videoHeight; // please override if you want - (void) didExpand; - (void) didMinimize; - (void) didStartMinimizeGesture; - (void) didFullExpandByGesture;//stil dev - (void) didDisappear; - (void) didReAppear; // please call if you want - (void) minimizeView; - (void) expandView; - (void) hideControllerView; - (void) showControllerView; - (void) showMessageView; - (void) hideMessageView; // ---------- use from other class ------------------------ // please call from parent view controller - (void) show; - (void) bringToFront; @end ================================================ FILE: YouTubeDraggableVideo/Source/DraggableFloatingViewController.m ================================================ // // BSVideoDetailController.m // YouTubeDraggableVideo // // Created by Sandeep Mukherjee on 02/02/15. // Copyright (c) 2015 Sandeep Mukherjee. All rights reserved. // #import "DraggableFloatingViewController.h" #import "QuartzCore/CALayer.h" typedef NS_ENUM(NSUInteger, UIPanGestureRecognizerDirection) { UIPanGestureRecognizerDirectionUndefined, UIPanGestureRecognizerDirectionUp, UIPanGestureRecognizerDirectionDown, UIPanGestureRecognizerDirectionLeft, UIPanGestureRecognizerDirectionRight }; @interface DraggableFloatingViewController () @end @implementation DraggableFloatingViewController { //local Frame storee CGRect videoWrapperFrame; CGRect minimizedVideoFrame; CGRect pageWrapperFrame; // animation Frame CGRect wFrame; CGRect vFrame; //local touch location CGFloat _touchPositionInHeaderY; CGFloat _touchPositionInHeaderX; //detecting Pan gesture Direction UIPanGestureRecognizerDirection direction; UITapGestureRecognizer *tapRecognizer; //Creating a transparent Black layer view UIView *transparentBlackSheet; //Just to Check wether view is expanded or not BOOL isExpandedMode; UIView *pageWrapper; UIView *videoWrapper; // UIButton *foldButton; UIView *videoView; // border of mini vieo view UIView *borderView; CGFloat maxH; CGFloat maxW; CGFloat videoHeightRatio; CGFloat finalViewOffsetY; CGFloat minimamVideoHeight; UIView *parentView; BOOL isDisplayController; NSTimer *hideControllerTimer; BOOL isMinimizingByGesture; BOOL isAppear; BOOL isSetuped; CGRect windowFrame; } const CGFloat finalMargin = 3.0; const CGFloat minimamVideoWidth = 140; const CGFloat flickVelocity = 1000; // please override if you want - (void) didExpand {} - (void) didMinimize {} - (void) didStartMinimizeGesture { [[UIApplication sharedApplication] setStatusBarHidden:NO]; } - (void) didFullExpandByGesture {}// TODO: meke this stable - (void) didDisappear{} - (void) didReAppear{} - (id)init { self = [super init]; if (self) { self.bodyView = [[UIView alloc] init]; self.controllerView = [[UIView alloc] init]; self.messageView = [[UIView alloc] init]; } return self; } - (id) initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; if (self) { self.bodyView = [[UIView alloc] init]; self.controllerView = [[UIView alloc] init]; self.messageView = [[UIView alloc] init]; } return self; } # pragma mark - init - (void) show { if (!isSetuped) { [self setup]; } else { if (!isAppear) { [self reAppearWithAnimation]; } } } - (void) setup { isSetuped = true; NSLog(@"showVideoViewControllerOnParentVC"); // if( ![parentVC conformsToProtocol:@protocol(DraggableFloatingViewControllerDelegate)] ) { // NSAssert(NO, @"❌❌Parent view controller must confirm to protocol .❌❌"); // } // self.delegate = parentVC; // set portrait if (UIInterfaceOrientationIsLandscape([[UIApplication sharedApplication] statusBarOrientation])) { [[UIDevice currentDevice] setValue:[NSNumber numberWithInteger: UIInterfaceOrientationPortrait] forKey:@"orientation"]; } [[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationSlide]; // parentView = parentVC.view; // [parentView addSubview:self.view];// then, "viewDidLoad" called [[self getWindow] addSubview:self.view]; // wait to run "viewDidLoad" before "showThisView" [self performSelector:@selector(showThisView) withObject:nil afterDelay:0.0]; isAppear = true; } // ↓ // VIEW DID LOAD - (void) setupViewsWithVideoView: (UIView *)vView videoViewHeight: (CGFloat) videoHeight // minimizeButton: (UIButton *)foldBtn { NSLog(@"setupViewsWithVideoView"); videoView = vView; // foldButton = foldBtn;//control show and hide windowFrame = [[UIScreen mainScreen] bounds]; maxH = windowFrame.size.height; maxW = windowFrame.size.width; CGFloat videoWidth = maxW; videoHeightRatio = videoHeight / videoWidth; minimamVideoHeight = minimamVideoWidth * videoHeightRatio; finalViewOffsetY = maxH - minimamVideoHeight - finalMargin; videoWrapper = [[UIView alloc] init]; videoWrapper.frame = CGRectMake(0, 0, videoWidth, videoHeight); videoView.frame = videoWrapper.frame; self.controllerView.frame = videoWrapper.frame; self.messageView.frame = videoWrapper.frame; pageWrapper = [[UIView alloc] init]; pageWrapper.frame = CGRectMake(0, 0, maxW, maxH); videoWrapperFrame = videoWrapper.frame; pageWrapperFrame = pageWrapper.frame; borderView = [[UIView alloc] init]; borderView.clipsToBounds = YES; borderView.layer.masksToBounds = NO; borderView.layer.borderColor = [[UIColor whiteColor] CGColor]; borderView.layer.borderWidth = 0.5f; // borderView.layer.shadowOffset = CGSizeMake(0.0f, 0.0f); // borderView.layer.shadowColor = [UIColor blackColor].CGColor; // borderView.layer.shadowRadius = 1.0; // borderView.layer.shadowOpacity = 1.0; borderView.alpha = 0; borderView.frame = CGRectMake(videoView.frame.origin.y - 1, videoView.frame.origin.x - 1, videoView.frame.size.width + 1, videoView.frame.size.height + 1); self.bodyView.frame = CGRectMake(0, videoHeight, maxW, maxH - videoHeight); } // ↓ - (void) showThisView { // only first time, SubViews add to "self.view". // After animation, they move to "parentView" videoView.backgroundColor = [UIColor blackColor]; videoWrapper.backgroundColor = [UIColor blackColor]; [pageWrapper addSubview:self.bodyView]; [videoWrapper addSubview:videoView]; // move subviews from "self.view" to "parentView" after animation [self.view addSubview:pageWrapper]; [self.view addSubview:videoWrapper]; transparentBlackSheet = [[UIView alloc] initWithFrame:windowFrame]; transparentBlackSheet.backgroundColor = [UIColor blackColor]; transparentBlackSheet.alpha = 1; [self appearAnimation]; } // ↓ - (void) appearAnimation { self.view.frame = CGRectMake(windowFrame.size.width - 50, windowFrame.size.height - 50, windowFrame.size.width, windowFrame.size.height); self.view.transform = CGAffineTransformMakeScale(0.2, 0.2); self.view.alpha = 0; [UIView animateWithDuration:0.2 delay:0.0 options:UIViewAnimationOptionCurveEaseInOut animations:^ { self.view.transform = CGAffineTransformMakeScale(1.0, 1.0); self.view.alpha = 1; self.view.frame = CGRectMake(windowFrame.origin.x, windowFrame.origin.y, windowFrame.size.width, windowFrame.size.height); } completion:^(BOOL finished) { [self afterAppearAnimation]; }]; } // ↓ -(void) afterAppearAnimation { videoView.backgroundColor = videoWrapper.backgroundColor = [UIColor clearColor]; // [parentView addSubview:transparentBlackSheet]; // move from self.view // [parentView addSubview:pageWrapper]; // [parentView addSubview:videoWrapper]; [[self getWindow] addSubview:transparentBlackSheet]; [[self getWindow] addSubview:pageWrapper]; [[self getWindow] addSubview:videoWrapper]; self.view.hidden = TRUE; [videoView addSubview:borderView]; [videoWrapper addSubview:self.controllerView]; self.messageView.hidden = TRUE; [videoWrapper addSubview:self.messageView]; [self showControllerView]; UITapGestureRecognizer* expandedTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onTapExpandedVideoView)]; expandedTap.numberOfTapsRequired = 1; expandedTap.delegate = self; [videoWrapper addGestureRecognizer:expandedTap]; vFrame = videoWrapperFrame; wFrame = pageWrapperFrame; // adding Pan Gesture UIPanGestureRecognizer *pan = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(panAction:)]; pan.delegate = self; [videoWrapper addGestureRecognizer:pan]; isExpandedMode = TRUE; } - (void) disappear { isAppear = false; // [self.delegate removeDraggableFloatingViewController]; } - (void) reAppearWithAnimation { borderView.alpha = 0; transparentBlackSheet.alpha = 0; videoWrapper.alpha = 0; pageWrapper.alpha = 0; pageWrapper.frame = pageWrapperFrame; videoWrapper.frame = videoWrapperFrame; videoView.frame = videoWrapperFrame; self.controllerView.frame = videoView.frame; self.bodyView.frame = CGRectMake(0, videoView.frame.size.height,// keep stay on bottom of videoView self.bodyView.frame.size.width, self.bodyView.frame.size.height); borderView.frame = CGRectMake(videoView.frame.origin.y - 1, videoView.frame.origin.x - 1, videoView.frame.size.width + 1, videoView.frame.size.height + 1); // parentViewにのってるViewは pageWrapper と videoWrapper と transparentView // pageWrapper と videoWrapper をself.viewと同様のアニメーションをさせた後に、parentViewに戻す // transparentView は あとで1にすればいい pageWrapper.frame = CGRectMake(windowFrame.size.width - 50, windowFrame.size.height - 150, pageWrapper.frame.size.width, pageWrapper.frame.size.height); // pageWrapper.transform = CGAffineTransformMakeScale(0.2, 0.2); videoWrapper.frame = CGRectMake(windowFrame.size.width - 50, windowFrame.size.height - 150, videoWrapper.frame.size.width, videoWrapper.frame.size.height); // videoWrapper.transform = CGAffineTransformMakeScale(0.2, 0.2); [UIView animateWithDuration:0.5 delay:0.0 options:UIViewAnimationOptionCurveEaseInOut animations:^ { // pageWrapper.transform = CGAffineTransformMakeScale(1.0, 1.0); pageWrapper.alpha = 1; pageWrapper.frame = CGRectMake(windowFrame.origin.x, windowFrame.origin.y, pageWrapper.frame.size.width, pageWrapper.frame.size.height); // videoWrapper.transform = CGAffineTransformMakeScale(1.0, 1.0); videoWrapper.alpha = 1; videoWrapper.frame = CGRectMake(windowFrame.origin.x, windowFrame.origin.y, videoWrapper.frame.size.width, videoWrapper.frame.size.height); } completion:^(BOOL finished) { transparentBlackSheet.alpha = 1.0; for (UIGestureRecognizer *recognizer in videoWrapper.gestureRecognizers) { if([recognizer isKindOfClass:[UITapGestureRecognizer class]]) { [videoWrapper removeGestureRecognizer:recognizer]; } } UITapGestureRecognizer* expandedTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onTapExpandedVideoView)]; expandedTap.numberOfTapsRequired = 1; expandedTap.delegate = self; [videoWrapper addGestureRecognizer:expandedTap]; isExpandedMode = TRUE; [self didExpand]; [self didReAppear]; }]; } - (void) bringToFront { // [parentView addSubview:self.view];// then, "viewDidLoad" called // [parentView addSubview:transparentBlackSheet]; // [parentView addSubview:pageWrapper]; // [parentView addSubview:videoWrapper]; if (isSetuped) { [[self getWindow] bringSubviewToFront:self.view]; [[self getWindow] bringSubviewToFront:transparentBlackSheet]; [[self getWindow] bringSubviewToFront:pageWrapper]; [[self getWindow] bringSubviewToFront:videoWrapper]; } } // //- (void) changeParentVC: (UIViewController*) parentVC { //// if (isSetuped) { //// parentView = parentVC.view; //// [parentView addSubview:self.view];// then, "viewDidLoad" called //// [parentView addSubview:transparentBlackSheet]; //// [parentView addSubview:pageWrapper]; //// [parentView addSubview:videoWrapper]; //// } //} // - (UIWindow *) getWindow { return [[[UIApplication sharedApplication] delegate] window]; } -(void)removeAllViews { [[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationSlide]; [videoWrapper removeFromSuperview]; [pageWrapper removeFromSuperview]; [transparentBlackSheet removeFromSuperview]; [self.view removeFromSuperview]; } - (void)dealloc { // NSLog(@"dealloc DraggableFloatingViewController"); } -(void) showMessageView { self.messageView.hidden = FALSE; } -(void) hideMessageView { self.messageView.hidden = TRUE; } -(void) setHideControllerTimer { if ([hideControllerTimer isValid]) { [hideControllerTimer invalidate]; } hideControllerTimer = [NSTimer scheduledTimerWithTimeInterval:3.0f target:self selector:@selector(hideControllerView) userInfo:nil repeats:NO]; } -(void) showControllerView { NSLog(@"showControllerView"); isDisplayController = true; [self setHideControllerTimer]; [UIView animateWithDuration:0.5 delay:0.0 options:UIViewAnimationOptionCurveEaseInOut animations:^ { self.controllerView.alpha = 1.0; } completion:^(BOOL finished) { }]; } -(void) hideControllerView { NSLog(@"hideControllerView"); isDisplayController = false; if ([hideControllerTimer isValid]) { [hideControllerTimer invalidate]; } [UIView animateWithDuration:0.5 delay:0.0 options:UIViewAnimationOptionCurveEaseInOut animations:^ { self.controllerView.alpha = 0.0; } completion:^(BOOL finished) { }]; } - (void) showControllerAfterExpanded { [NSTimer scheduledTimerWithTimeInterval:0.5f target:self selector:@selector(showControllerView) userInfo:nil repeats:NO]; } # pragma mark - tap action //- (void) onTapDownButton { // [self minimizeView]; //} - (void) onTapExpandedVideoView { NSLog(@"onTapExpandedVideoView"); if (self.controllerView.alpha == 0.0) { [self showControllerView]; } else if (self.controllerView.alpha == 1.0){ [self hideControllerView]; } } - (void)expandViewOnTap:(UITapGestureRecognizer*)sender { [self expandView]; [self showControllerAfterExpanded]; } #pragma mark- Pan Gesture Selector Action -(void)panAction:(UIPanGestureRecognizer *)recognizer { CGFloat touchPosInViewY = [recognizer locationInView:self.view].y; if(recognizer.state == UIGestureRecognizerStateBegan) { direction = UIPanGestureRecognizerDirectionUndefined; //storing direction CGPoint velocity = [recognizer velocityInView:recognizer.view]; [self detectPanDirection:velocity]; isMinimizingByGesture = false; //Snag the Y position of the touch when panning begins _touchPositionInHeaderY = [recognizer locationInView:videoWrapper].y; _touchPositionInHeaderX = [recognizer locationInView:videoWrapper].x; if(direction == UIPanGestureRecognizerDirectionDown) { if(videoView.frame.size.height > minimamVideoHeight) { // player.controlStyle = MPMovieControlStyleNone; NSLog(@"minimize gesture start"); isMinimizingByGesture = true; [self didStartMinimizeGesture]; } } } else if(recognizer.state == UIGestureRecognizerStateChanged) { if(direction == UIPanGestureRecognizerDirectionDown || direction == UIPanGestureRecognizerDirectionUp) { // CGFloat appendY = 20; // if (direction == UIPanGestureRecognizerDirectionUp) appendY = -appendY; CGFloat newOffsetY = touchPosInViewY - _touchPositionInHeaderY;// + appendY; // CGFloat newOffsetX = newOffsetY * 0.35; [self adjustViewOnVerticalPan:newOffsetY recognizer:recognizer]; } else if (direction==UIPanGestureRecognizerDirectionRight || direction==UIPanGestureRecognizerDirectionLeft) { [self adjustViewOnHorizontalPan:recognizer]; } } else if(recognizer.state == UIGestureRecognizerStateEnded) { CGPoint velocity = [recognizer velocityInView:recognizer.view]; if(direction == UIPanGestureRecognizerDirectionDown || direction == UIPanGestureRecognizerDirectionUp) { if(velocity.y < -flickVelocity) { // NSLog(@"flick up"); [self expandView]; if (isMinimizingByGesture == false) { [self showControllerAfterExpanded]; } [recognizer setTranslation:CGPointZero inView:recognizer.view]; return; } else if(velocity.y > flickVelocity) { // NSLog(@"flick down"); [self minimizeView]; [recognizer setTranslation:CGPointZero inView:recognizer.view]; return; } else if(recognizer.view.frame.origin.y>(windowFrame.size.width/2)) { [self minimizeView]; [recognizer setTranslation:CGPointZero inView:recognizer.view]; return; } else if(recognizer.view.frame.origin.y < (windowFrame.size.width/2) || recognizer.view.frame.origin.y < 0) { [self expandView]; if (isMinimizingByGesture == false) { [self showControllerAfterExpanded]; } [recognizer setTranslation:CGPointZero inView:recognizer.view]; return; } } else if (direction==UIPanGestureRecognizerDirectionLeft) { if(pageWrapper.alpha <= 0) { if(velocity.x < -flickVelocity || pageWrapper.alpha < 0.3) { [self fadeOutViewToLeft:recognizer completion: ^{ [self disappear]; }]; return; } else if(recognizer.view.frame.origin.x < 0) { [self disappear]; } else { [self animateMiniViewToNormalPosition:recognizer completion:nil]; } } } else if (direction==UIPanGestureRecognizerDirectionRight) { if(pageWrapper.alpha <= 0) { if(velocity.x > flickVelocity) { [self fadeOutViewToRight:recognizer completion: ^{ [self disappear]; }]; return; } if(recognizer.view.frame.origin.x > windowFrame.size.width - 50) { [self disappear]; } else { [self animateMiniViewToNormalPosition:recognizer completion:nil]; } } } isMinimizingByGesture = false; } } -(void)detectPanDirection:(CGPoint )velocity { // foldButton.hidden=TRUE; BOOL isVerticalGesture = fabs(velocity.y) > fabs(velocity.x); if (isVerticalGesture) { if (velocity.y > 0) { direction = UIPanGestureRecognizerDirectionDown; } else { direction = UIPanGestureRecognizerDirectionUp; } } else { if(velocity.x > 0) { direction = UIPanGestureRecognizerDirectionRight; } else { direction = UIPanGestureRecognizerDirectionLeft; } } } -(void)adjustViewOnVerticalPan:(CGFloat)newOffsetY recognizer:(UIPanGestureRecognizer *)recognizer { CGFloat touchPosInViewY = [recognizer locationInView:self.view].y; CGFloat progressRate = newOffsetY / finalViewOffsetY; if(progressRate >= 0.99) { progressRate = 1; newOffsetY = finalViewOffsetY; } [self calcNewFrameWithParsentage:progressRate newOffsetY:newOffsetY]; if (progressRate <= 1 && pageWrapper.frame.origin.y >= 0) { pageWrapper.frame = wFrame; videoWrapper.frame = vFrame; videoView.frame = CGRectMake( videoView.frame.origin.x, videoView.frame.origin.x, vFrame.size.width, vFrame.size.height ); self.bodyView.frame = CGRectMake( 0, videoView.frame.size.height,// keep stay on bottom of videoView self.bodyView.frame.size.width, self.bodyView.frame.size.height ); borderView.frame = CGRectMake(videoView.frame.origin.y - 1, videoView.frame.origin.x - 1, videoView.frame.size.width + 1, videoView.frame.size.height + 1); self.controllerView.frame = videoView.frame; CGFloat percentage = touchPosInViewY / windowFrame.size.height; pageWrapper.alpha = transparentBlackSheet.alpha = 1.0 - (percentage * 1.5); if (percentage > 0.2) borderView.alpha = percentage; else borderView.alpha = 0; if (isDisplayController) { self.controllerView.alpha = 1.0 - (percentage * 2); // if (percentage > 0.2) borderView.alpha = percentage; // else borderView.alpha = 0; } if(direction==UIPanGestureRecognizerDirectionDown) { // [parentView bringSubviewToFront:self.view]; [self bringToFront]; } if(direction==UIPanGestureRecognizerDirectionUp && videoView.frame.origin.y <= 10) { [self didFullExpandByGesture]; } } // what is this case...? else if (wFrame.origin.y < finalViewOffsetY && wFrame.origin.y > 0) { pageWrapper.frame = wFrame; videoWrapper.frame = vFrame; videoView.frame=CGRectMake( videoView.frame.origin.x, videoView.frame.origin.x, vFrame.size.width, vFrame.size.height); self.bodyView.frame = CGRectMake( 0, videoView.frame.size.height,// keep stay on bottom of videoView self.bodyView.frame.size.width, self.bodyView.frame.size.height ); borderView.frame = CGRectMake(videoView.frame.origin.y - 1, videoView.frame.origin.x - 1, videoView.frame.size.width + 1, videoView.frame.size.height + 1); borderView.alpha = progressRate; self.controllerView.frame = videoView.frame; } [recognizer setTranslation:CGPointZero inView:recognizer.view]; } -(void)adjustViewOnHorizontalPan:(UIPanGestureRecognizer *)recognizer { // [self.txtViewGrowing resignFirstResponder]; if(pageWrapper.alpha<=0) { CGFloat x = [recognizer locationInView:self.view].x; if (direction==UIPanGestureRecognizerDirectionLeft) { // NSLog(@"recognizer x=%f",recognizer.view.frame.origin.x); CGPoint velocity = [recognizer velocityInView:recognizer.view]; BOOL isVerticalGesture = fabs(velocity.y) > fabs(velocity.x); CGPoint translation = [recognizer translationInView:recognizer.view]; recognizer.view.center = CGPointMake(recognizer.view.center.x + translation.x, recognizer.view.center.y ); if (!isVerticalGesture) { CGFloat percentage = (x/windowFrame.size.width); recognizer.view.alpha = percentage; } [recognizer setTranslation:CGPointZero inView:recognizer.view]; } else if (direction==UIPanGestureRecognizerDirectionRight) { // NSLog(@"recognizer x=%f",recognizer.view.frame.origin.x); CGPoint velocity = [recognizer velocityInView:recognizer.view]; BOOL isVerticalGesture = fabs(velocity.y) > fabs(velocity.x); CGPoint translation = [recognizer translationInView:recognizer.view]; recognizer.view.center = CGPointMake(recognizer.view.center.x + translation.x, recognizer.view.center.y ); if (!isVerticalGesture) { if(velocity.x > 0) { CGFloat percentage = (x/windowFrame.size.width); recognizer.view.alpha =1.0- percentage; } else { CGFloat percentage = (x/windowFrame.size.width); recognizer.view.alpha =percentage; } } [recognizer setTranslation:CGPointZero inView:recognizer.view]; } } } - (void) calcNewFrameWithParsentage:(CGFloat) persentage newOffsetY:(CGFloat) newOffsetY{ CGFloat newWidth = minimamVideoWidth + ((maxW - minimamVideoWidth) * (1 - persentage)); CGFloat newHeight = newWidth * videoHeightRatio; CGFloat newOffsetX = maxW - newWidth - (finalMargin * persentage); vFrame.size.width = newWidth;//self.view.bounds.size.width - xOffset; vFrame.size.height = newHeight;//(200 - xOffset * 0.5); vFrame.origin.y = newOffsetY;//trueOffset - finalMargin * 2; wFrame.origin.y = newOffsetY; vFrame.origin.x = newOffsetX;//maxW - vFrame.size.width - finalMargin; wFrame.origin.x = newOffsetX; // vFrame.origin.y = realNewOffsetY;//trueOffset - finalMargin * 2; // wFrame.origin.y = realNewOffsetY; } -(void) setFinalFrame { vFrame.size.width = minimamVideoWidth;//self.view.bounds.size.width - xOffset; // ↓ vFrame.size.height = vFrame.size.width * videoHeightRatio;//(200 - xOffset * 0.5); vFrame.origin.y = maxH - vFrame.size.height - finalMargin;//trueOffset - finalMargin * 2; vFrame.origin.x = maxW - vFrame.size.width - finalMargin; wFrame.origin.y = vFrame.origin.y; wFrame.origin.x = vFrame.origin.x; } # pragma mark - animations -(void)expandView { // [self.txtViewGrowing resignFirstResponder]; [UIView animateWithDuration:0.5 delay:0.0 options:UIViewAnimationOptionCurveEaseInOut animations:^ { pageWrapper.frame = pageWrapperFrame; videoWrapper.frame = videoWrapperFrame; videoWrapper.alpha = 1; videoView.frame = videoWrapperFrame; pageWrapper.alpha = 1.0; transparentBlackSheet.alpha = 1.0; borderView.alpha = 0.0; self.bodyView.frame = CGRectMake(0, videoView.frame.size.height,// keep stay on bottom of videoView self.bodyView.frame.size.width, self.bodyView.frame.size.height); borderView.frame = CGRectMake(videoView.frame.origin.y - 1, videoView.frame.origin.x - 1, videoView.frame.size.width + 1, videoView.frame.size.height + 1); self.controllerView.frame = videoView.frame; } completion:^(BOOL finished) { for (UIGestureRecognizer *recognizer in videoWrapper.gestureRecognizers) { if([recognizer isKindOfClass:[UITapGestureRecognizer class]]) { [videoWrapper removeGestureRecognizer:recognizer]; } } UITapGestureRecognizer* expandedTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onTapExpandedVideoView)]; expandedTap.numberOfTapsRequired = 1; expandedTap.delegate = self; [videoWrapper addGestureRecognizer:expandedTap]; // player.controlStyle = MPMovieControlStyleDefault; // [self showVideoControl]; isExpandedMode = TRUE; // self.controllerView.hidden = FALSE; [self didExpand]; }]; } -(void)minimizeView { // self.controllerView.hidden = TRUE; [self setFinalFrame]; [self hideControllerView]; [UIView animateWithDuration:0.5 delay:0.0 options:UIViewAnimationOptionCurveEaseInOut animations:^ { pageWrapper.frame = wFrame; videoWrapper.frame = vFrame; videoView.frame=CGRectMake( videoView.frame.origin.x, videoView.frame.origin.x, vFrame.size.width, vFrame.size.height); pageWrapper.alpha=0; transparentBlackSheet.alpha=0.0; borderView.alpha = 1.0; borderView.frame = CGRectMake(videoView.frame.origin.y - 1, videoView.frame.origin.x - 1, videoView.frame.size.width + 1, videoView.frame.size.height + 1); self.controllerView.frame = videoView.frame; } completion:^(BOOL finished) { // [self hideVideoControl]; [self didMinimize]; //add tap gesture tapRecognizer = nil; if(tapRecognizer == nil) { for (UIGestureRecognizer *recognizer in videoWrapper.gestureRecognizers) { if([recognizer isKindOfClass:[UITapGestureRecognizer class]]) { [videoWrapper removeGestureRecognizer:recognizer]; } } tapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(expandViewOnTap:)]; tapRecognizer.numberOfTapsRequired = 1; tapRecognizer.delegate = self; [videoWrapper addGestureRecognizer:tapRecognizer]; } isExpandedMode=FALSE; minimizedVideoFrame = videoWrapper.frame; if(direction==UIPanGestureRecognizerDirectionDown) { // [parentView bringSubviewToFront:self.view]; [self bringToFront]; } }]; } -(void)animateMiniViewToNormalPosition:(UIPanGestureRecognizer *)recognizer completion:(void (^)())completion { [self setFinalFrame]; [UIView animateWithDuration:0.25 delay:0.0 options:UIViewAnimationOptionCurveEaseInOut animations:^ { pageWrapper.frame = wFrame; videoWrapper.frame = vFrame; videoView.frame=CGRectMake( videoView.frame.origin.x, videoView.frame.origin.x, vFrame.size.width, vFrame.size.height ); pageWrapper.alpha = 0; videoWrapper.alpha = 1; borderView.alpha = 1; self.controllerView.frame = videoView.frame; } completion:^(BOOL finished) { if (completion) completion(); }]; [recognizer setTranslation:CGPointZero inView:recognizer.view]; } -(void)fadeOutViewToRight:(UIPanGestureRecognizer *)recognizer completion:(void (^)())completion { // [self.txtViewGrowing resignFirstResponder]; vFrame.origin.x = maxW + minimamVideoWidth; wFrame.origin.x = maxW + minimamVideoWidth; [UIView animateWithDuration:0.1 delay:0.0 options:UIViewAnimationOptionCurveEaseInOut animations:^ { pageWrapper.frame = wFrame; videoWrapper.frame = vFrame; videoView.frame=CGRectMake( videoView.frame.origin.x, videoView.frame.origin.x, vFrame.size.width, vFrame.size.height); pageWrapper.alpha = 0; videoWrapper.alpha = 0; borderView.alpha = 0; self.controllerView.frame = videoView.frame; } completion:^(BOOL finished) { if (completion) completion(); [self didDisappear]; }]; [recognizer setTranslation:CGPointZero inView:recognizer.view]; } -(void)fadeOutViewToLeft:(UIPanGestureRecognizer *)recognizer completion:(void (^)())completion { // [self.txtViewGrowing resignFirstResponder]; vFrame.origin.x = -maxW; wFrame.origin.x = -maxW; [UIView animateWithDuration:0.1 delay:0.0 options:UIViewAnimationOptionCurveEaseInOut animations:^ { pageWrapper.frame = wFrame; videoWrapper.frame = vFrame; videoView.frame=CGRectMake( videoView.frame.origin.x, videoView.frame.origin.x, vFrame.size.width, vFrame.size.height); pageWrapper.alpha = 0; videoWrapper.alpha = 0; borderView.alpha = 0; self.controllerView.frame = videoView.frame; } completion:^(BOOL finished) { if (completion) completion(); [self didDisappear]; }]; [recognizer setTranslation:CGPointZero inView:recognizer.view]; } #pragma mark- Pan Gesture Delagate - (BOOL)gestureRecognizerShould:(UIGestureRecognizer *)gestureRecognizer { if(gestureRecognizer.view.frame.origin.y < 0) { return NO; } else { return YES; } } - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer { return YES; } #pragma mark- Status Bar Hidden function - (BOOL)prefersStatusBarHidden { return YES; } - (UIInterfaceOrientationMask) supportedInterfaceOrientations { return UIInterfaceOrientationMaskPortrait; } - (BOOL)shouldAutorotate { return NO; } @end ================================================ FILE: YouTubeDraggableVideo/main.m ================================================ // // main.m // YouTubeDraggableVideo // // Created by Sandeep Mukherjee on 02/02/15. // Copyright (c) 2015 Sandeep Mukherjee. All rights reserved. // #import #import "AppDelegate.h" int main(int argc, char * argv[]) { @autoreleasepool { return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); } } ================================================ FILE: YouTubeDraggableVideo.xcodeproj/project.pbxproj ================================================ // !$*UTF8*$! { archiveVersion = 1; classes = { }; objectVersion = 46; objects = { /* Begin PBXBuildFile section */ 253F2E2D1A7F5907007FD89E /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 253F2E2C1A7F5907007FD89E /* main.m */; }; 253F2E381A7F5907007FD89E /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 253F2E371A7F5907007FD89E /* Images.xcassets */; }; 253F2E3B1A7F5907007FD89E /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 253F2E391A7F5907007FD89E /* LaunchScreen.xib */; }; 253F2E471A7F5907007FD89E /* YouTubeDraggableVideoTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 253F2E461A7F5907007FD89E /* YouTubeDraggableVideoTests.m */; }; 253F2E5C1A7F6027007FD89E /* profilePhoto.png in Resources */ = {isa = PBXBuildFile; fileRef = 253F2E5B1A7F6027007FD89E /* profilePhoto.png */; }; B01147D81B33B30300D4CEB6 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = B01147D71B33B30300D4CEB6 /* AppDelegate.swift */; }; B01147DA1B33D56900D4CEB6 /* SecondViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B01147D91B33D56900D4CEB6 /* SecondViewController.swift */; }; B01147DC1B33DAC700D4CEB6 /* NSTimerHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = B01147DB1B33DAC700D4CEB6 /* NSTimerHelper.swift */; }; B0125D7B1B1BD88B005FF053 /* FirstViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0125D781B1BD88B005FF053 /* FirstViewController.swift */; }; B0125D7C1B1BD88B005FF053 /* VideoDetailViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0125D791B1BD88B005FF053 /* VideoDetailViewController.swift */; }; B0125D801B1BD897005FF053 /* DraggableFloatingViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = B0125D7F1B1BD897005FF053 /* DraggableFloatingViewController.m */; }; B04E93C31B168CEB004384E8 /* test.mp4 in Resources */ = {isa = PBXBuildFile; fileRef = B04E93C21B168CEB004384E8 /* test.mp4 */; }; B0B076F01B33F36A004A027A /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = B0B076EF1B33F36A004A027A /* AppDelegate.m */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ 253F2E411A7F5907007FD89E /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 253F2E1F1A7F5907007FD89E /* Project object */; proxyType = 1; remoteGlobalIDString = 253F2E261A7F5907007FD89E; remoteInfo = YouTubeDraggableVideo; }; /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ 253F2E271A7F5907007FD89E /* YouTubeDraggableVideo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = YouTubeDraggableVideo.app; sourceTree = BUILT_PRODUCTS_DIR; }; 253F2E2B1A7F5907007FD89E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 253F2E2C1A7F5907007FD89E /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 253F2E371A7F5907007FD89E /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 253F2E3A1A7F5907007FD89E /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; }; 253F2E401A7F5907007FD89E /* YouTubeDraggableVideoTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = YouTubeDraggableVideoTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 253F2E451A7F5907007FD89E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 253F2E461A7F5907007FD89E /* YouTubeDraggableVideoTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = YouTubeDraggableVideoTests.m; sourceTree = ""; }; 253F2E5B1A7F6027007FD89E /* profilePhoto.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = profilePhoto.png; sourceTree = ""; }; B01147D71B33B30300D4CEB6 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; B01147D91B33D56900D4CEB6 /* SecondViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SecondViewController.swift; sourceTree = ""; }; B01147DB1B33DAC700D4CEB6 /* NSTimerHelper.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NSTimerHelper.swift; sourceTree = ""; }; B0125D781B1BD88B005FF053 /* FirstViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FirstViewController.swift; sourceTree = ""; }; B0125D791B1BD88B005FF053 /* VideoDetailViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = VideoDetailViewController.swift; sourceTree = ""; }; B0125D7A1B1BD88B005FF053 /* YouTubeDraggableVideo-Bridging-Header.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "YouTubeDraggableVideo-Bridging-Header.h"; sourceTree = ""; }; B0125D7E1B1BD897005FF053 /* DraggableFloatingViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DraggableFloatingViewController.h; sourceTree = ""; }; B0125D7F1B1BD897005FF053 /* DraggableFloatingViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DraggableFloatingViewController.m; sourceTree = ""; }; B04E93C21B168CEB004384E8 /* test.mp4 */ = {isa = PBXFileReference; lastKnownFileType = file; path = test.mp4; sourceTree = ""; }; B04E93C41B168D16004384E8 /* sample.mp4 */ = {isa = PBXFileReference; lastKnownFileType = file; path = sample.mp4; sourceTree = ""; }; B0B076EE1B33F36A004A027A /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; B0B076EF1B33F36A004A027A /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ 253F2E241A7F5907007FD89E /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( ); runOnlyForDeploymentPostprocessing = 0; }; 253F2E3D1A7F5907007FD89E /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ 253F2E1E1A7F5907007FD89E = { isa = PBXGroup; children = ( 253F2E291A7F5907007FD89E /* YouTubeDraggableVideo */, 253F2E431A7F5907007FD89E /* YouTubeDraggableVideoTests */, 253F2E281A7F5907007FD89E /* Products */, ); sourceTree = ""; }; 253F2E281A7F5907007FD89E /* Products */ = { isa = PBXGroup; children = ( 253F2E271A7F5907007FD89E /* YouTubeDraggableVideo.app */, 253F2E401A7F5907007FD89E /* YouTubeDraggableVideoTests.xctest */, ); name = Products; sourceTree = ""; }; 253F2E291A7F5907007FD89E /* YouTubeDraggableVideo */ = { isa = PBXGroup; children = ( B0125D7D1B1BD897005FF053 /* Source */, B0125D771B1BD88B005FF053 /* Demo */, 253F2E371A7F5907007FD89E /* Images.xcassets */, 253F2E391A7F5907007FD89E /* LaunchScreen.xib */, B04E93C11B168CEB004384E8 /* sampleMovies */, 253F2E2A1A7F5907007FD89E /* Supporting Files */, ); path = YouTubeDraggableVideo; sourceTree = ""; }; 253F2E2A1A7F5907007FD89E /* Supporting Files */ = { isa = PBXGroup; children = ( 253F2E5B1A7F6027007FD89E /* profilePhoto.png */, 253F2E2B1A7F5907007FD89E /* Info.plist */, 253F2E2C1A7F5907007FD89E /* main.m */, ); name = "Supporting Files"; sourceTree = ""; }; 253F2E431A7F5907007FD89E /* YouTubeDraggableVideoTests */ = { isa = PBXGroup; children = ( 253F2E461A7F5907007FD89E /* YouTubeDraggableVideoTests.m */, 253F2E441A7F5907007FD89E /* Supporting Files */, ); path = YouTubeDraggableVideoTests; sourceTree = ""; }; 253F2E441A7F5907007FD89E /* Supporting Files */ = { isa = PBXGroup; children = ( 253F2E451A7F5907007FD89E /* Info.plist */, ); name = "Supporting Files"; sourceTree = ""; }; B0125D771B1BD88B005FF053 /* Demo */ = { isa = PBXGroup; children = ( B0125D791B1BD88B005FF053 /* VideoDetailViewController.swift */, B0125D781B1BD88B005FF053 /* FirstViewController.swift */, B01147D91B33D56900D4CEB6 /* SecondViewController.swift */, B01147DB1B33DAC700D4CEB6 /* NSTimerHelper.swift */, B0B076EE1B33F36A004A027A /* AppDelegate.h */, B0B076EF1B33F36A004A027A /* AppDelegate.m */, B01147D71B33B30300D4CEB6 /* AppDelegate.swift */, B0125D7A1B1BD88B005FF053 /* YouTubeDraggableVideo-Bridging-Header.h */, ); path = Demo; sourceTree = ""; }; B0125D7D1B1BD897005FF053 /* Source */ = { isa = PBXGroup; children = ( B0125D7E1B1BD897005FF053 /* DraggableFloatingViewController.h */, B0125D7F1B1BD897005FF053 /* DraggableFloatingViewController.m */, ); path = Source; sourceTree = ""; }; B04E93C11B168CEB004384E8 /* sampleMovies */ = { isa = PBXGroup; children = ( B04E93C41B168D16004384E8 /* sample.mp4 */, B04E93C21B168CEB004384E8 /* test.mp4 */, ); path = sampleMovies; sourceTree = ""; }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ 253F2E261A7F5907007FD89E /* YouTubeDraggableVideo */ = { isa = PBXNativeTarget; buildConfigurationList = 253F2E4A1A7F5907007FD89E /* Build configuration list for PBXNativeTarget "YouTubeDraggableVideo" */; buildPhases = ( 253F2E231A7F5907007FD89E /* Sources */, 253F2E241A7F5907007FD89E /* Frameworks */, 253F2E251A7F5907007FD89E /* Resources */, ); buildRules = ( ); dependencies = ( ); name = YouTubeDraggableVideo; productName = YouTubeDraggableVideo; productReference = 253F2E271A7F5907007FD89E /* YouTubeDraggableVideo.app */; productType = "com.apple.product-type.application"; }; 253F2E3F1A7F5907007FD89E /* YouTubeDraggableVideoTests */ = { isa = PBXNativeTarget; buildConfigurationList = 253F2E4D1A7F5907007FD89E /* Build configuration list for PBXNativeTarget "YouTubeDraggableVideoTests" */; buildPhases = ( 253F2E3C1A7F5907007FD89E /* Sources */, 253F2E3D1A7F5907007FD89E /* Frameworks */, 253F2E3E1A7F5907007FD89E /* Resources */, ); buildRules = ( ); dependencies = ( 253F2E421A7F5907007FD89E /* PBXTargetDependency */, ); name = YouTubeDraggableVideoTests; productName = YouTubeDraggableVideoTests; productReference = 253F2E401A7F5907007FD89E /* YouTubeDraggableVideoTests.xctest */; productType = "com.apple.product-type.bundle.unit-test"; }; /* End PBXNativeTarget section */ /* Begin PBXProject section */ 253F2E1F1A7F5907007FD89E /* Project object */ = { isa = PBXProject; attributes = { LastUpgradeCheck = 1220; ORGANIZATIONNAME = "Sandeep Mukherjee"; TargetAttributes = { 253F2E261A7F5907007FD89E = { CreatedOnToolsVersion = 6.1; DevelopmentTeam = 8ET8BLFZ87; ProvisioningStyle = Automatic; }; 253F2E3F1A7F5907007FD89E = { CreatedOnToolsVersion = 6.1; TestTargetID = 253F2E261A7F5907007FD89E; }; }; }; buildConfigurationList = 253F2E221A7F5907007FD89E /* Build configuration list for PBXProject "YouTubeDraggableVideo" */; compatibilityVersion = "Xcode 3.2"; developmentRegion = en; hasScannedForEncodings = 0; knownRegions = ( en, Base, ); mainGroup = 253F2E1E1A7F5907007FD89E; productRefGroup = 253F2E281A7F5907007FD89E /* Products */; projectDirPath = ""; projectRoot = ""; targets = ( 253F2E261A7F5907007FD89E /* YouTubeDraggableVideo */, 253F2E3F1A7F5907007FD89E /* YouTubeDraggableVideoTests */, ); }; /* End PBXProject section */ /* Begin PBXResourcesBuildPhase section */ 253F2E251A7F5907007FD89E /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( 253F2E5C1A7F6027007FD89E /* profilePhoto.png in Resources */, B04E93C31B168CEB004384E8 /* test.mp4 in Resources */, 253F2E3B1A7F5907007FD89E /* LaunchScreen.xib in Resources */, 253F2E381A7F5907007FD89E /* Images.xcassets in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; 253F2E3E1A7F5907007FD89E /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXResourcesBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ 253F2E231A7F5907007FD89E /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( B01147DA1B33D56900D4CEB6 /* SecondViewController.swift in Sources */, B01147D81B33B30300D4CEB6 /* AppDelegate.swift in Sources */, 253F2E2D1A7F5907007FD89E /* main.m in Sources */, B0125D7C1B1BD88B005FF053 /* VideoDetailViewController.swift in Sources */, B0B076F01B33F36A004A027A /* AppDelegate.m in Sources */, B0125D801B1BD897005FF053 /* DraggableFloatingViewController.m in Sources */, B0125D7B1B1BD88B005FF053 /* FirstViewController.swift in Sources */, B01147DC1B33DAC700D4CEB6 /* NSTimerHelper.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; 253F2E3C1A7F5907007FD89E /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( 253F2E471A7F5907007FD89E /* YouTubeDraggableVideoTests.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXSourcesBuildPhase section */ /* Begin PBXTargetDependency section */ 253F2E421A7F5907007FD89E /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 253F2E261A7F5907007FD89E /* YouTubeDraggableVideo */; targetProxy = 253F2E411A7F5907007FD89E /* PBXContainerItemProxy */; }; /* End PBXTargetDependency section */ /* Begin PBXVariantGroup section */ 253F2E391A7F5907007FD89E /* LaunchScreen.xib */ = { isa = PBXVariantGroup; children = ( 253F2E3A1A7F5907007FD89E /* Base */, ); name = LaunchScreen.xib; sourceTree = ""; }; /* End PBXVariantGroup section */ /* Begin XCBuildConfiguration section */ 253F2E481A7F5907007FD89E /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; COPY_PHASE_STRIP = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_TESTABILITY = YES; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_DYNAMIC_NO_PIC = NO; GCC_NO_COMMON_BLOCKS = YES; GCC_OPTIMIZATION_LEVEL = 0; GCC_PREPROCESSOR_DEFINITIONS = ( "DEBUG=1", "$(inherited)", ); GCC_SYMBOLS_PRIVATE_EXTERN = NO; GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; GCC_WARN_UNDECLARED_SELECTOR = YES; GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; IPHONEOS_DEPLOYMENT_TARGET = 12.0; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; }; name = Debug; }; 253F2E491A7F5907007FD89E /* Release */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; COPY_PHASE_STRIP = YES; ENABLE_NS_ASSERTIONS = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_NO_COMMON_BLOCKS = YES; GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; GCC_WARN_UNDECLARED_SELECTOR = YES; GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; IPHONEOS_DEPLOYMENT_TARGET = 12.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SWIFT_COMPILATION_MODE = wholemodule; VALIDATE_PRODUCT = YES; }; name = Release; }; 253F2E4B1A7F5907007FD89E /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_IDENTITY = "Apple Development"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = 8ET8BLFZ87; INFOPLIST_FILE = YouTubeDraggableVideo/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "com.vizllx.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE = ""; PROVISIONING_PROFILE_SPECIFIER = ""; SWIFT_OBJC_BRIDGING_HEADER = "YouTubeDraggableVideo/Demo/YouTubeDraggableVideo-Bridging-Header.h"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_VERSION = 5.0; }; name = Debug; }; 253F2E4C1A7F5907007FD89E /* Release */ = { isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_IDENTITY = "Apple Development"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = 8ET8BLFZ87; INFOPLIST_FILE = YouTubeDraggableVideo/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "com.vizllx.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE = ""; PROVISIONING_PROFILE_SPECIFIER = ""; SWIFT_OBJC_BRIDGING_HEADER = "YouTubeDraggableVideo/Demo/YouTubeDraggableVideo-Bridging-Header.h"; SWIFT_VERSION = 5.0; }; name = Release; }; 253F2E4E1A7F5907007FD89E /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { BUNDLE_LOADER = "$(TEST_HOST)"; FRAMEWORK_SEARCH_PATHS = ( "$(SDKROOT)/Developer/Library/Frameworks", "$(inherited)", ); GCC_PREPROCESSOR_DEFINITIONS = ( "DEBUG=1", "$(inherited)", ); INFOPLIST_FILE = YouTubeDraggableVideoTests/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "com.vizllx.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/YouTubeDraggableVideo.app/YouTubeDraggableVideo"; }; name = Debug; }; 253F2E4F1A7F5907007FD89E /* Release */ = { isa = XCBuildConfiguration; buildSettings = { BUNDLE_LOADER = "$(TEST_HOST)"; FRAMEWORK_SEARCH_PATHS = ( "$(SDKROOT)/Developer/Library/Frameworks", "$(inherited)", ); INFOPLIST_FILE = YouTubeDraggableVideoTests/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "com.vizllx.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/YouTubeDraggableVideo.app/YouTubeDraggableVideo"; }; name = Release; }; /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ 253F2E221A7F5907007FD89E /* Build configuration list for PBXProject "YouTubeDraggableVideo" */ = { isa = XCConfigurationList; buildConfigurations = ( 253F2E481A7F5907007FD89E /* Debug */, 253F2E491A7F5907007FD89E /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; 253F2E4A1A7F5907007FD89E /* Build configuration list for PBXNativeTarget "YouTubeDraggableVideo" */ = { isa = XCConfigurationList; buildConfigurations = ( 253F2E4B1A7F5907007FD89E /* Debug */, 253F2E4C1A7F5907007FD89E /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; 253F2E4D1A7F5907007FD89E /* Build configuration list for PBXNativeTarget "YouTubeDraggableVideoTests" */ = { isa = XCConfigurationList; buildConfigurations = ( 253F2E4E1A7F5907007FD89E /* Debug */, 253F2E4F1A7F5907007FD89E /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; /* End XCConfigurationList section */ }; rootObject = 253F2E1F1A7F5907007FD89E /* Project object */; } ================================================ FILE: YouTubeDraggableVideo.xcodeproj/project.xcworkspace/contents.xcworkspacedata ================================================ ================================================ FILE: YouTubeDraggableVideo.xcodeproj/project.xcworkspace/xcshareddata/YouTubeDraggableVideo.xccheckout ================================================ IDESourceControlProjectFavoriteDictionaryKey IDESourceControlProjectIdentifier B696D8E4-3947-4F0E-AE1A-BBE1F3C64F66 IDESourceControlProjectName YouTubeDraggableVideo IDESourceControlProjectOriginsDictionary C0796BA5C0F25FE444F34B630D9B7AA6F9BEA0B4 https://github.com/entotsu/DraggableYoutubeFloatingVideo.git IDESourceControlProjectPath YouTubeDraggableVideo.xcodeproj IDESourceControlProjectRelativeInstallPathDictionary C0796BA5C0F25FE444F34B630D9B7AA6F9BEA0B4 ../.. IDESourceControlProjectURL https://github.com/entotsu/DraggableYoutubeFloatingVideo.git IDESourceControlProjectVersion 111 IDESourceControlProjectWCCIdentifier C0796BA5C0F25FE444F34B630D9B7AA6F9BEA0B4 IDESourceControlProjectWCConfigurations IDESourceControlRepositoryExtensionIdentifierKey public.vcs.git IDESourceControlWCCIdentifierKey C0796BA5C0F25FE444F34B630D9B7AA6F9BEA0B4 IDESourceControlWCCName DraggableYoutubeFloatingVideo ================================================ FILE: YouTubeDraggableVideo.xcodeproj/xcuserdata/Takuya.xcuserdatad/xcschemes/YouTubeDraggableVideo.xcscheme ================================================ ================================================ FILE: YouTubeDraggableVideo.xcodeproj/xcuserdata/sandeepmukherjee.xcuserdatad/xcschemes/YouTubeDraggableVideo.xcscheme ================================================ ================================================ FILE: YouTubeDraggableVideo.xcodeproj/xcuserdata/sandeepmukherjee.xcuserdatad/xcschemes/xcschememanagement.plist ================================================ SchemeUserState YouTubeDraggableVideo.xcscheme orderHint 0 SuppressBuildableAutocreation 253F2E261A7F5907007FD89E primary 253F2E3F1A7F5907007FD89E primary ================================================ FILE: YouTubeDraggableVideoTests/Info.plist ================================================ CFBundleDevelopmentRegion en CFBundleExecutable $(EXECUTABLE_NAME) CFBundleIdentifier $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion 6.0 CFBundleName $(PRODUCT_NAME) CFBundlePackageType BNDL CFBundleShortVersionString 1.0 CFBundleSignature ???? CFBundleVersion 1 ================================================ FILE: YouTubeDraggableVideoTests/YouTubeDraggableVideoTests.m ================================================ // // YouTubeDraggableVideoTests.m // YouTubeDraggableVideoTests // // Created by Sandeep Mukherjee on 02/02/15. // Copyright (c) 2015 Sandeep Mukherjee. All rights reserved. // #import #import @interface YouTubeDraggableVideoTests : XCTestCase @end @implementation YouTubeDraggableVideoTests - (void)setUp { [super setUp]; // Put setup code here. This method is called before the invocation of each test method in the class. } - (void)tearDown { // Put teardown code here. This method is called after the invocation of each test method in the class. [super tearDown]; } - (void)testExample { // This is an example of a functional test case. XCTAssert(YES, @"Pass"); } - (void)testPerformanceExample { // This is an example of a performance test case. [self measureBlock:^{ // Put the code you want to measure the time of here. }]; } @end