text
stringlengths
9
39.2M
dir
stringlengths
25
226
lang
stringclasses
163 values
created_date
timestamp[s]
updated_date
timestamp[s]
repo_name
stringclasses
751 values
repo_full_name
stringclasses
752 values
star
int64
1.01k
183k
len_tokens
int64
1
18.5M
```objective-c // // main.m // WMPlayer // // Created by on 16/2/1. // #import <UIKit/UIKit.h> #import "AppDelegate.h" int main(int argc, char * argv[]) { @autoreleasepool { return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); } } ```
/content/code_sandbox/PlayerDemo/main.m
objective-c
2016-02-02T02:51:55
2024-08-09T08:55:27
WMPlayer
zhengwenming/WMPlayer
3,272
70
```xml <?xml version="1.0" encoding="UTF-8"?> <document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="13771" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES"> <device id="retina4_7" orientation="portrait"> <adaptation id="fullscreen"/> </device> <dependencies> <deployment identifier="iOS"/> <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13772"/> <capability name="Aspect ratio constraints" minToolsVersion="5.1"/> <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/> </dependencies> <objects> <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/> <placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/> <tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" rowHeight="274" id="KGk-i7-Jjw" customClass="VideoCell"> <rect key="frame" x="0.0" y="0.0" width="320" height="274"/> <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/> <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="KGk-i7-Jjw" id="H2p-sc-9uM"> <rect key="frame" x="0.0" y="0.0" width="320" height="273.5"/> <autoresizingMask key="autoresizingMask"/> <subviews> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="248" verticalHuggingPriority="251" text="" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="IWL-jl-1gR"> <rect key="frame" x="8" y="10" width="304" height="20.5"/> <constraints> <constraint firstAttribute="height" constant="20" id="ktW-js-jho"/> </constraints> <fontDescription key="fontDescription" type="system" pointSize="17"/> <color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> <nil key="highlightedColor"/> </label> <imageView contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="1Yl-Wr-uuU"> <rect key="frame" x="0.0" y="57.5" width="320" height="178"/> </imageView> <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="cax-82-QUE"> <rect key="frame" x="127" y="120" width="66" height="64"/> <constraints> <constraint firstAttribute="width" constant="66" id="l61-fe-fC5"/> <constraint firstAttribute="height" constant="64" id="pjZ-bj-Bxn"/> </constraints> <state key="normal" image="video_play_btn_bg"/> </button> <imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="time" translatesAutoresizingMaskIntoConstraints="NO" id="lji-oA-ZVu"> <rect key="frame" x="8" y="243.5" width="20" height="20"/> <constraints> <constraint firstAttribute="height" constant="20" id="1Nc-wi-OKe"/> <constraint firstAttribute="width" constant="20" id="7wO-kV-lW9"/> <constraint firstAttribute="width" secondItem="lji-oA-ZVu" secondAttribute="height" multiplier="1:1" id="oZS-R9-89l"/> </constraints> </imageView> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="1:30" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="xEd-9K-NaK"> <rect key="frame" x="36" y="243.5" width="42" height="20"/> <constraints> <constraint firstAttribute="width" secondItem="xEd-9K-NaK" secondAttribute="height" multiplier="21:10" id="CcP-9c-Axs"/> </constraints> <fontDescription key="fontDescription" type="system" pointSize="14"/> <color key="textColor" red="0.66666666666666663" green="0.66666666666666663" blue="0.66666666666666663" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> <nil key="highlightedColor"/> </label> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="2.22" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="yJZ-ZF-MEW"> <rect key="frame" x="117" y="243.5" width="51.5" height="20"/> <constraints> <constraint firstAttribute="width" secondItem="yJZ-ZF-MEW" secondAttribute="height" multiplier="51:20" id="TT3-sj-93r"/> </constraints> <fontDescription key="fontDescription" type="system" pointSize="14"/> <color key="textColor" red="0.66666666666666663" green="0.66666666666666663" blue="0.66666666666666663" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> <nil key="highlightedColor"/> </label> <imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="playcount" translatesAutoresizingMaskIntoConstraints="NO" id="Cor-Ow-SC1"> <rect key="frame" x="89" y="243.5" width="20" height="20"/> <constraints> <constraint firstAttribute="height" constant="20" id="23m-8A-xbS"/> <constraint firstAttribute="width" secondItem="Cor-Ow-SC1" secondAttribute="height" multiplier="1:1" id="Gga-Xx-toP"/> <constraint firstAttribute="width" constant="20" id="fwM-TP-8K8"/> </constraints> </imageView> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="IlI-mv-Igm"> <rect key="frame" x="8" y="32.5" width="304" height="17"/> <constraints> <constraint firstAttribute="height" relation="lessThanOrEqual" constant="17" id="yFa-6C-aKk"/> </constraints> <fontDescription key="fontDescription" type="system" pointSize="14"/> <color key="textColor" red="0.66666666666666663" green="0.66666666666666663" blue="0.66666666666666663" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> <nil key="highlightedColor"/> </label> </subviews> <constraints> <constraint firstItem="xEd-9K-NaK" firstAttribute="leading" secondItem="lji-oA-ZVu" secondAttribute="trailing" constant="8" id="0ko-YX-QTa"/> <constraint firstItem="IWL-jl-1gR" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="top" constant="10" id="1HL-bZ-EJ4"/> <constraint firstAttribute="bottom" secondItem="yJZ-ZF-MEW" secondAttribute="bottom" constant="10" id="1O1-pY-8gJ"/> <constraint firstItem="1Yl-Wr-uuU" firstAttribute="top" secondItem="IlI-mv-Igm" secondAttribute="bottom" constant="8" id="5Pi-gU-s1f"/> <constraint firstAttribute="bottom" secondItem="Cor-Ow-SC1" secondAttribute="bottom" constant="10" id="5kT-pc-D3c"/> <constraint firstAttribute="bottom" secondItem="xEd-9K-NaK" secondAttribute="bottom" constant="10" id="5uf-OY-5pg"/> <constraint firstItem="IWL-jl-1gR" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" constant="8" id="EnE-dH-X9s"/> <constraint firstItem="IlI-mv-Igm" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" constant="8" id="Ht5-f6-xjh"/> <constraint firstItem="Cor-Ow-SC1" firstAttribute="leading" secondItem="xEd-9K-NaK" secondAttribute="trailing" constant="11" id="P2X-MR-3BU"/> <constraint firstItem="Cor-Ow-SC1" firstAttribute="top" secondItem="1Yl-Wr-uuU" secondAttribute="bottom" constant="8" id="SgJ-ns-oEx"/> <constraint firstAttribute="trailing" secondItem="IlI-mv-Igm" secondAttribute="trailing" constant="8" id="TSs-p8-YUx"/> <constraint firstAttribute="trailing" secondItem="yJZ-ZF-MEW" secondAttribute="trailing" constant="152" id="Tvp-7J-RFT"/> <constraint firstItem="yJZ-ZF-MEW" firstAttribute="leading" secondItem="Cor-Ow-SC1" secondAttribute="trailing" constant="8" id="VsY-QZ-q8a"/> <constraint firstItem="xEd-9K-NaK" firstAttribute="top" secondItem="1Yl-Wr-uuU" secondAttribute="bottom" constant="8" id="WFb-rC-0L0"/> <constraint firstItem="lji-oA-ZVu" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" constant="8" id="WUi-sp-ygJ"/> <constraint firstItem="Cor-Ow-SC1" firstAttribute="top" secondItem="1Yl-Wr-uuU" secondAttribute="bottom" constant="8" id="Yz9-a6-hKm"/> <constraint firstAttribute="trailing" secondItem="IWL-jl-1gR" secondAttribute="trailing" constant="8" id="bRd-TN-7LL"/> <constraint firstItem="IlI-mv-Igm" firstAttribute="top" secondItem="IWL-jl-1gR" secondAttribute="bottom" constant="2" id="emc-vG-jaq"/> <constraint firstItem="cax-82-QUE" firstAttribute="centerX" secondItem="H2p-sc-9uM" secondAttribute="centerX" id="fQ1-l9-mn1"/> <constraint firstItem="cax-82-QUE" firstAttribute="centerY" secondItem="H2p-sc-9uM" secondAttribute="centerY" constant="15" id="jpI-Bl-Z7h"/> <constraint firstItem="Cor-Ow-SC1" firstAttribute="leading" secondItem="xEd-9K-NaK" secondAttribute="trailing" constant="11" id="nKI-XH-7Rq"/> <constraint firstItem="yJZ-ZF-MEW" firstAttribute="top" secondItem="1Yl-Wr-uuU" secondAttribute="bottom" constant="8" id="oFu-0R-mNA"/> <constraint firstItem="1Yl-Wr-uuU" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" id="rFG-bc-Qse"/> <constraint firstAttribute="trailing" secondItem="1Yl-Wr-uuU" secondAttribute="trailing" id="uJb-sF-fIH"/> <constraint firstAttribute="bottom" secondItem="lji-oA-ZVu" secondAttribute="bottom" constant="10" id="yBw-0X-tKB"/> <constraint firstItem="lji-oA-ZVu" firstAttribute="top" secondItem="1Yl-Wr-uuU" secondAttribute="bottom" constant="8" id="yRI-ZC-wfO"/> </constraints> </tableViewCellContentView> <connections> <outlet property="backgroundIV" destination="1Yl-Wr-uuU" id="vHG-ls-VHL"/> <outlet property="countLabel" destination="yJZ-ZF-MEW" id="91A-Si-13f"/> <outlet property="descriptionLabel" destination="IlI-mv-Igm" id="V2Q-ad-Czj"/> <outlet property="playBtn" destination="cax-82-QUE" id="jlA-T6-oOB"/> <outlet property="timeDurationLabel" destination="xEd-9K-NaK" id="AEu-7u-M06"/> <outlet property="titleLabel" destination="IWL-jl-1gR" id="ji0-zg-In0"/> </connections> <point key="canvasLocation" x="-11" y="-70"/> </tableViewCell> </objects> <resources> <image name="playcount" width="64" height="64"/> <image name="time" width="64" height="64"/> <image name="video_play_btn_bg" width="64" height="64"/> </resources> </document> ```
/content/code_sandbox/PlayerDemo/VideoCell.xib
xml
2016-02-02T02:51:55
2024-08-09T08:55:27
WMPlayer
zhengwenming/WMPlayer
3,272
3,362
```xml <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "path_to_url"> <plist version="1.0"> <dict> <key>CFBundleDevelopmentRegion</key> <string>en</string> <key>CFBundleDisplayName</key> <string>WMPlayer</string> <key>CFBundleExecutable</key> <string>$(EXECUTABLE_NAME)</string> <key>CFBundleIdentifier</key> <string>$(PRODUCT_BUNDLE_IDENTIFIER)</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>LSRequiresIPhoneOS</key> <true/> <key>NSAppTransportSecurity</key> <dict> <key>NSAllowsArbitraryLoads</key> <true/> </dict> <key>NSCameraUsageDescription</key> <string>WMPlayer</string> <key>NSMicrophoneUsageDescription</key> <string>WMPlayer</string> <key>NSPhotoLibraryAddUsageDescription</key> <string>WMPlayer</string> <key>NSPhotoLibraryUsageDescription</key> <string>WMPlayer</string> <key>UIBackgroundModes</key> <array> <string>audio</string> </array> <key>UILaunchStoryboardName</key> <string>LaunchScreen</string> <key>UIRequiredDeviceCapabilities</key> <array> <string>armv7</string> </array> <key>UISupportedInterfaceOrientations</key> <array> <string>UIInterfaceOrientationPortrait</string> </array> <key>UIViewControllerBasedStatusBarAppearance</key> <true/> </dict> </plist> ```
/content/code_sandbox/PlayerDemo/Info.plist
xml
2016-02-02T02:51:55
2024-08-09T08:55:27
WMPlayer
zhengwenming/WMPlayer
3,272
499
```objective-c /*! @header SinaNewsViewController.h @abstract Githubpath_to_url CSDN:path_to_url @author Created by zhengwenming on 16/1/19 @version 1.00 16/1/19 Creation() */ #import <UIKit/UIKit.h> #import "BaseViewController.h" @interface SinaNewsViewController : UIViewController @property (strong, nonatomic) UITableView *table; @end ```
/content/code_sandbox/PlayerDemo/ViewControllers/SinaNewsViewController.h
objective-c
2016-02-02T02:51:55
2024-08-09T08:55:27
WMPlayer
zhengwenming/WMPlayer
3,272
92
```objective-c // // CameraViewController.h // PlayerDemo // // Created by apple on 2018/8/10. // #import "BaseViewController.h" @interface CameraViewController : BaseViewController @end ```
/content/code_sandbox/PlayerDemo/ViewControllers/CameraViewController.h
objective-c
2016-02-02T02:51:55
2024-08-09T08:55:27
WMPlayer
zhengwenming/WMPlayer
3,272
44
```objective-c // // VCRotateViewController.h // PlayerDemo // // Created by apple on 2020/6/3. // #import <UIKit/UIKit.h> #import "BaseViewController.h" #import "WMPlayer.h" NS_ASSUME_NONNULL_BEGIN @interface VCRotateViewController : BaseViewController @end NS_ASSUME_NONNULL_END ```
/content/code_sandbox/PlayerDemo/ViewControllers/VCRotateViewController.h
objective-c
2016-02-02T02:51:55
2024-08-09T08:55:27
WMPlayer
zhengwenming/WMPlayer
3,272
70
```objective-c // // BaseViewController.h // WMPlayer // // Created by on 16/3/15. // #import <UIKit/UIKit.h> @interface BaseViewController : UIViewController @end ```
/content/code_sandbox/PlayerDemo/ViewControllers/BaseViewController.h
objective-c
2016-02-02T02:51:55
2024-08-09T08:55:27
WMPlayer
zhengwenming/WMPlayer
3,272
42
```objective-c // // HomeVideoCollectionViewCell.h // PlayerDemo // // Created by apple on 2018/8/10. // #import <UIKit/UIKit.h> #import "VideoDataModel.h" #import "Masonry.h" @interface HomeVideoCollectionViewCell : UICollectionViewCell @property (nonatomic , strong) VideoDataModel* DataModel; @end ```
/content/code_sandbox/PlayerDemo/HomeVideoCollectionViewCell.h
objective-c
2016-02-02T02:51:55
2024-08-09T08:55:27
WMPlayer
zhengwenming/WMPlayer
3,272
73
```objective-c /*! @header BaseNavigationController.m @abstract Githubpath_to_url CSDN:path_to_url @author Created by zhengwenming on 16/1/19 @version 1.00 16/1/19 Creation() */ #import "BaseNavigationController.h" @interface BaseNavigationController ()<UINavigationControllerDelegate> @end @implementation BaseNavigationController - (void)viewDidLoad { [super viewDidLoad]; self.navigationBar.barTintColor = [UIColor redColor]; // UIImage *backButtonImage = [[UIImage imageNamed:@"navigator_btn_back"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 30, 0, 0)]; [[UIBarButtonItem appearance] setBackButtonBackgroundImage:backButtonImage forState:UIControlStateNormal barMetrics:UIBarMetricsDefault]; self.navigationBar.tintColor = [UIColor whiteColor]; self.navigationBar.titleTextAttributes = [NSDictionary dictionaryWithObjectsAndKeys:[UIColor whiteColor],NSForegroundColorAttributeName,[UIFont boldSystemFontOfSize:17.0],NSFontAttributeName ,nil]; } - (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated{ if (self.childViewControllers.count>=1) { viewController.hidesBottomBarWhenPushed = YES; } [super pushViewController:viewController animated:animated]; // pushtabbar if (@available(iOS 11.0, *)){ // tabBraframe CGRect frame = self.tabBarController.tabBar.frame; frame.origin.y = [UIScreen mainScreen].bounds.size.height - frame.size.height; self.tabBarController.tabBar.frame = frame; } } -(BOOL)prefersStatusBarHidden{ if(self.topViewController.prefersStatusBarHidden){ return self.topViewController.prefersStatusBarHidden; } return NO; } - (UIStatusBarAnimation)preferredStatusBarUpdateAnimation{ if(self.topViewController.preferredStatusBarUpdateAnimation){ return self.topViewController.preferredStatusBarUpdateAnimation; } return UIStatusBarAnimationNone; } -(BOOL)shouldAutorotate{ if(self.topViewController.shouldAutorotate){ return self.topViewController.shouldAutorotate; } return YES; } -(UIInterfaceOrientationMask)supportedInterfaceOrientations{ if(self.topViewController.supportedInterfaceOrientations){ return self.topViewController.supportedInterfaceOrientations; } return UIInterfaceOrientationMaskPortrait; } -(UIInterfaceOrientation)preferredInterfaceOrientationForPresentation{ if(self.topViewController.preferredInterfaceOrientationForPresentation){ return self.topViewController.preferredInterfaceOrientationForPresentation; } return UIInterfaceOrientationPortrait; } @end ```
/content/code_sandbox/PlayerDemo/ViewControllers/BaseNavigationController.m
objective-c
2016-02-02T02:51:55
2024-08-09T08:55:27
WMPlayer
zhengwenming/WMPlayer
3,272
526
```objective-c // // CameraViewController.m // PlayerDemo // // Created by apple on 2018/8/10. // #import "CameraViewController.h" @interface CameraViewController () @end @implementation CameraViewController - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } -(BOOL)prefersStatusBarHidden{ return NO; } -(BOOL)shouldAutorotate{ return YES; } -(UIInterfaceOrientationMask)supportedInterfaceOrientations{ return UIInterfaceOrientationMaskPortrait; } -(UIInterfaceOrientation)preferredInterfaceOrientationForPresentation{ return UIInterfaceOrientationPortrait; } -(void)viewWillAppear:(BOOL)animated{ [super viewWillAppear:animated]; [self.navigationController setNavigationBarHidden:NO animated:YES]; } @end ```
/content/code_sandbox/PlayerDemo/ViewControllers/CameraViewController.m
objective-c
2016-02-02T02:51:55
2024-08-09T08:55:27
WMPlayer
zhengwenming/WMPlayer
3,272
177
```objective-c /*! @header BaseNavigationController.h @abstract Githubpath_to_url CSDN:path_to_url @author Created by zhengwenming on 16/1/19 @version 1.00 16/1/19 Creation() */ #import <UIKit/UIKit.h> #import "BaseViewController.h" @interface BaseNavigationController : UINavigationController @end ```
/content/code_sandbox/PlayerDemo/ViewControllers/BaseNavigationController.h
objective-c
2016-02-02T02:51:55
2024-08-09T08:55:27
WMPlayer
zhengwenming/WMPlayer
3,272
80
```objective-c /*! @header TencentNewsViewController.m @abstract Githubpath_to_url CSDN:path_to_url @author Created by zhengwenming on 16/1/19 @version 1.00 16/1/19 Creation() */ #import "TencentNewsViewController.h" #import "AppDelegate.h" #import "MJRefresh.h" #import "HomeVideoCollectionViewCell.h" #import "WMPlayerModel.h" #import "DetailViewController.h" #import "VCRotateViewController.h" @interface TencentNewsViewController ()<UICollectionViewDelegate,UICollectionViewDelegateFlowLayout,UICollectionViewDataSource>{ } @property (nonatomic, retain) UICollectionView *videoCollectionView;// @property (nonatomic, strong) NSMutableArray* videoDataAry; @end @implementation TencentNewsViewController -(UIStatusBarStyle)preferredStatusBarStyle{ return UIStatusBarStyleLightContent; } -(BOOL)prefersStatusBarHidden{ return NO; } -(BOOL)shouldAutorotate{ return YES; } -(UIInterfaceOrientationMask)supportedInterfaceOrientations{ return UIInterfaceOrientationMaskPortrait; } -(UIInterfaceOrientation)preferredInterfaceOrientationForPresentation{ return UIInterfaceOrientationPortrait; } -(void)viewWillAppear:(BOOL)animated{ [super viewWillAppear:animated]; [self.navigationController setNavigationBarHidden:NO animated:YES]; } - (void)viewDidLoad { [super viewDidLoad]; self.navigationItem.title = @""; UICollectionViewFlowLayout* videoFlowLayout = [[UICollectionViewFlowLayout alloc] init]; [videoFlowLayout setScrollDirection:UICollectionViewScrollDirectionVertical];// self.videoCollectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width,[UIScreen mainScreen].bounds.size.height) collectionViewLayout:videoFlowLayout]; self.videoCollectionView.alwaysBounceVertical = YES;// self.videoCollectionView.delegate = self; self.videoCollectionView.dataSource = self; [self.videoCollectionView setBackgroundColor:[UIColor whiteColor]]; [self.videoCollectionView registerClass:[HomeVideoCollectionViewCell class] forCellWithReuseIdentifier:@"HomeVideoCollectionViewCell"]; [self.view addSubview:self.videoCollectionView]; self.videoCollectionView.mj_header = [MJRefreshNormalHeader headerWithRefreshingTarget:self refreshingAction:@selector(refreshVideoData)]; self.videoCollectionView.mj_footer = [MJRefreshBackNormalFooter footerWithRefreshingTarget:self refreshingAction:@selector(addVideoData)]; [VideoDataModel getHomePageVideoDataWithBlock:^(NSArray *dateAry, NSError *error) { if (!error) { _videoDataAry = [NSMutableArray arrayWithArray:dateAry]; [self.videoCollectionView reloadData]; }else{ } }]; } -(void)refreshVideoData{ [VideoDataModel getHomePageVideoDataWithBlock:^(NSArray *dateAry, NSError *error) { if (!error) { _videoDataAry = [NSMutableArray arrayWithArray:dateAry]; [self.videoCollectionView.mj_header endRefreshing]; [self.videoCollectionView reloadData]; }else{ [self.videoCollectionView.mj_header endRefreshing]; } }]; } -(void)addVideoData{ [VideoDataModel getHomePageVideoDataWithBlock:^(NSArray *dateAry, NSError *error) { if (!error) { // _videoDataAry = [NSMutableArray arrayWithArray:dateAry]; [_videoDataAry addObjectsFromArray:dateAry]; [self.videoCollectionView.mj_footer endRefreshing]; [self.videoCollectionView reloadData]; }else{ [self.videoCollectionView.mj_footer endRefreshing]; } }]; } #pragma mark UICollectionViewDataSource { //Section -(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView{ return 1; } //UICollectionViewCell - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{ return _videoDataAry.count; } //UICollectionView -(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{ HomeVideoCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"HomeVideoCollectionViewCell" forIndexPath:indexPath]; cell.DataModel = self.videoDataAry[indexPath.row]; return cell; } //headerView -(CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout referenceSizeForHeaderInSection:(NSInteger)section{ return CGSizeZero; } //item - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath{ return CGSizeMake(([UIScreen mainScreen].bounds.size.width)/2 - 2, (([UIScreen mainScreen].bounds.size.width)/2 - 2)*1.6); } //Section margin -(UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section{ return UIEdgeInsetsMake(0.0,2.0,0.0,2.0); } //item - (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section{ return 0.0f; } //section - (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section{ return 0.0f; } //UICollectionView -(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{ if (indexPath.row%2==0) { VCRotateViewController *VCRotate = [VCRotateViewController new]; [self.navigationController pushViewController:VCRotate animated:YES]; }else{ VideoDataModel *videoModel = self.videoDataAry[indexPath.row]; WMPlayerModel *playerModel = [WMPlayerModel new]; // playerModel.videoURL = [NSURL URLWithString:videoModel.video_url]; playerModel.videoURL = [NSURL URLWithString:@"path_to_url"]; // playerModel.videoURL = [NSURL URLWithString:@"path_to_url"]; playerModel.title = videoModel.nickname; DetailViewController *detailVC = [DetailViewController new]; detailVC.playerModel = playerModel; [self.navigationController pushViewController:detailVC animated:YES]; } } -(void)dealloc{ NSLog(@"%@ dealloc",[self class]); [[NSNotificationCenter defaultCenter] removeObserver:self]; } @end ```
/content/code_sandbox/PlayerDemo/ViewControllers/TencentNewsViewController.m
objective-c
2016-02-02T02:51:55
2024-08-09T08:55:27
WMPlayer
zhengwenming/WMPlayer
3,272
1,265
```objective-c // // DetailViewController.h // WMVideoPlayer // // Created by on 16/2/1. // #import <UIKit/UIKit.h> #import "BaseViewController.h" #import "WMPlayer.h" @interface DetailViewController : BaseViewController @property (nonatomic, retain)WMPlayerModel *playerModel; @property (nonatomic, strong)WMPlayer *wmPlayer; @end ```
/content/code_sandbox/PlayerDemo/ViewControllers/DetailViewController.h
objective-c
2016-02-02T02:51:55
2024-08-09T08:55:27
WMPlayer
zhengwenming/WMPlayer
3,272
82
```objective-c // // VCRotateViewController.m // PlayerDemo // // Created by apple on 2020/6/3. // #import "VCRotateViewController.h" @interface VCRotateViewController ()<WMPlayerDelegate> @property (nonatomic, strong)WMPlayer *wmPlayer; @end @implementation VCRotateViewController - (BOOL)shouldAutorotate{ if (self.wmPlayer.playerModel.verticalVideo||self.wmPlayer.isLockScreen) { return NO; } return YES; } - (UIInterfaceOrientationMask)supportedInterfaceOrientations{ return UIInterfaceOrientationMaskAllButUpsideDown; } -(UIInterfaceOrientation)preferredInterfaceOrientationForPresentation{ [[UIDevice currentDevice] setValue:@(UIInterfaceOrientationLandscapeRight) forKey:@"orientation"]; return UIInterfaceOrientationLandscapeRight; } - (void)viewWillAppear:(BOOL)animated{ [super viewWillAppear:animated]; [self.navigationController setNavigationBarHidden:YES animated:NO]; } -(void)viewDidDisappear:(BOOL)animated{ [super viewDidAppear:animated]; [self.navigationController setNavigationBarHidden:NO animated:NO]; } - (void)viewDidLoad { [super viewDidLoad]; self.view.backgroundColor = [UIColor blackColor]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onDeviceOrientationChange:) name:UIDeviceOrientationDidChangeNotification object:nil ]; WMPlayerModel *playerModel = [WMPlayerModel new]; playerModel.title = @""; playerModel.videoURL = [NSURL URLWithString:@"path_to_url"]; self.wmPlayer = [[WMPlayer alloc] initWithFrame:CGRectMake(0, [WMPlayer IsiPhoneX]?34:0, self.view.frame.size.width, self.view.frame.size.width*(9.0/16))]; self.wmPlayer.delegate = self; self.wmPlayer.playerModel =playerModel; [self.view addSubview:self.wmPlayer]; [self.wmPlayer play]; } /// -(void)wmplayer:(WMPlayer *)wmplayer clickedCloseButton:(UIButton *)closeBtn{ if (wmplayer.isFullscreen) { [self.wmPlayer setIsFullscreen:NO]; [self changeInterfaceOrientation:UIInterfaceOrientationPortrait]; }else{ if (self.presentingViewController) { [self dismissViewControllerAnimated:YES completion:^{ }]; }else{ [self.navigationController popViewControllerAnimated:YES]; } } } - (void)changeInterfaceOrientation:(UIInterfaceOrientation)ori { @try { // ios16api if (@available(iOS 16.0, *)) { UIInterfaceOrientationMask oriMask = UIInterfaceOrientationMaskPortrait; if (ori == UIDeviceOrientationPortrait) { oriMask = UIInterfaceOrientationMaskPortrait; } else if (ori == UIDeviceOrientationLandscapeLeft) { oriMask = UIInterfaceOrientationMaskLandscapeRight; } else if (ori == UIDeviceOrientationLandscapeRight) { oriMask = UIInterfaceOrientationMaskLandscapeLeft; } else { return; } // appDelegate supportedInterfaceOrientationsForWindow UINavigationController *nav = self.navigationController; SEL selUpdateSupportedMethod = NSSelectorFromString(@"setNeedsUpdateOfSupportedInterfaceOrientations"); if ([nav respondsToSelector:selUpdateSupportedMethod]) { (((void (*)(id, SEL))[nav methodForSelector:selUpdateSupportedMethod])(nav, selUpdateSupportedMethod)); } NSArray *array = [[[UIApplication sharedApplication] connectedScenes] allObjects]; UIWindowScene *ws = (UIWindowScene *)array.firstObject; Class GeometryPreferences = NSClassFromString(@"UIWindowSceneGeometryPreferencesIOS"); id geometryPreferences = [[GeometryPreferences alloc] init]; [geometryPreferences setValue:@(oriMask) forKey:@"interfaceOrientations"]; SEL selGeometryUpdateMethod = NSSelectorFromString(@"requestGeometryUpdateWithPreferences:errorHandler:"); void (^ErrorBlock)(NSError *error) = ^(NSError *error){ NSLog(@"iOS 16 Error: %@",error); }; if ([ws respondsToSelector:selGeometryUpdateMethod]) { (((void (*)(id, SEL,id,id))[ws methodForSelector:selGeometryUpdateMethod])(ws, selGeometryUpdateMethod,geometryPreferences,ErrorBlock)); } // [self onDeviceOrientationChange:nil]; } else { if ([[UIDevice currentDevice] respondsToSelector:@selector(setOrientation:)]) { SEL selector = NSSelectorFromString(@"setOrientation:"); if ([UIDevice currentDevice].orientation == ori) { NSInvocation *invocationUnknow = [NSInvocation invocationWithMethodSignature:[UIDevice instanceMethodSignatureForSelector:selector]]; [invocationUnknow setSelector:selector]; [invocationUnknow setTarget:[UIDevice currentDevice]]; UIDeviceOrientation unKnowVal = UIDeviceOrientationUnknown; [invocationUnknow setArgument:&unKnowVal atIndex:2]; [invocationUnknow invoke]; } NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[UIDevice instanceMethodSignatureForSelector:selector]]; [invocation setSelector:selector]; [invocation setTarget:[UIDevice currentDevice]]; UIDeviceOrientation val = ori; [invocation setArgument:&val atIndex:2]; [invocation invoke]; } } } @catch (NSException *exception) { } @finally { } } /// -(void)wmplayer:(WMPlayer *)wmplayer clickedFullScreenButton:(UIButton *)fullScreenBtn{ if (self.wmPlayer.isFullscreen) {//--> [[UIDevice currentDevice] setValue:@(UIInterfaceOrientationPortrait) forKey:@"orientation"]; }else{//--> [self.wmPlayer setIsFullscreen:YES]; [self changeInterfaceOrientation:UIInterfaceOrientationLandscapeRight]; } [UIViewController attemptRotationToDeviceOrientation]; } // - (void)onDeviceOrientationChange:(NSNotification *)notification{ if (self.wmPlayer.isLockScreen){ return; } UIDeviceOrientation orientation = [UIDevice currentDevice].orientation; UIInterfaceOrientation interfaceOrientation = (UIInterfaceOrientation)orientation; switch (interfaceOrientation) { case UIInterfaceOrientationPortraitUpsideDown:{ NSLog(@"3---"); } break; case UIInterfaceOrientationPortrait:{ NSLog(@"0---"); [self.wmPlayer setIsFullscreen:NO]; } break; case UIInterfaceOrientationLandscapeLeft:{ NSLog(@"2---"); [self.wmPlayer setIsFullscreen:YES]; } break; case UIInterfaceOrientationLandscapeRight:{ NSLog(@"1---"); [self.wmPlayer setIsFullscreen:YES]; } break; default: break; } } - (void)dealloc{ [self.wmPlayer pause]; [self.wmPlayer removeFromSuperview]; self.wmPlayer = nil; [[NSNotificationCenter defaultCenter] removeObserver:self]; NSLog(@"DetailViewController dealloc"); } @end ```
/content/code_sandbox/PlayerDemo/ViewControllers/VCRotateViewController.m
objective-c
2016-02-02T02:51:55
2024-08-09T08:55:27
WMPlayer
zhengwenming/WMPlayer
3,272
1,425
```objective-c // // BaseViewController.m // WMPlayer // // Created by on 16/3/15. // #import "BaseViewController.h" @interface BaseViewController () @end @implementation BaseViewController - (void)viewDidLoad { [super viewDidLoad]; self.view.backgroundColor = [UIColor whiteColor]; } -(void)viewWillAppear:(BOOL)animated{ [super viewWillAppear:animated]; [self.navigationController setNavigationBarHidden:NO animated:YES]; } -(BOOL)prefersStatusBarHidden{ return NO; } - (BOOL)shouldAutorotate{ return YES; } - (UIInterfaceOrientationMask)supportedInterfaceOrientations{ return UIInterfaceOrientationMaskPortrait; } -(UIInterfaceOrientation)preferredInterfaceOrientationForPresentation{ return UIInterfaceOrientationPortrait; } @end ```
/content/code_sandbox/PlayerDemo/ViewControllers/BaseViewController.m
objective-c
2016-02-02T02:51:55
2024-08-09T08:55:27
WMPlayer
zhengwenming/WMPlayer
3,272
157
```objective-c /*! @header TencentNewsViewController.h @abstract Githubpath_to_url CSDN:path_to_url @author Created by zhengwenming on 16/1/19 @version 1.00 16/1/19 Creation() */ #import <UIKit/UIKit.h> #import "BaseViewController.h" @interface TencentNewsViewController : UIViewController @end ```
/content/code_sandbox/PlayerDemo/ViewControllers/TencentNewsViewController.h
objective-c
2016-02-02T02:51:55
2024-08-09T08:55:27
WMPlayer
zhengwenming/WMPlayer
3,272
79
```objective-c // // DetailViewController.m // WMVideoPlayer // // Created by on 16/2/1. // #import "DetailViewController.h" #import "Masonry.h" #import "FullScreenHelperViewController.h" #import "LandscapeRightViewController.h" #import "LandscapeLeftViewController.h" #import "EnterFullScreenTransition.h" #import "ExitFullScreenTransition.h" @interface DetailViewController ()<WMPlayerDelegate,UIViewControllerTransitioningDelegate> @property(nonatomic,strong) UIButton *nextBtn; @end @implementation DetailViewController //hiddenhomeIndicator -(BOOL)prefersHomeIndicatorAutoHidden{ return self.wmPlayer.isFullscreen; } -(UIStatusBarStyle)preferredStatusBarStyle{ return UIStatusBarStyleLightContent; } -(BOOL)prefersStatusBarHidden{ return self.wmPlayer.prefersStatusBarHidden; } // - (BOOL)shouldAutorotate{ return YES; } - (UIInterfaceOrientationMask)supportedInterfaceOrientations{ return UIInterfaceOrientationMaskPortrait; } -(UIInterfaceOrientation)preferredInterfaceOrientationForPresentation{ return UIInterfaceOrientationPortrait; } ///CloseButton -(void)wmplayer:(WMPlayer *)wmplayer clickedCloseButton:(UIButton *)closeBtn{ if (wmplayer.isFullscreen) { [self exitFullScreen]; }else{ if (self.presentingViewController) { [self dismissViewControllerAnimated:YES completion:^{ }]; }else{ [self.navigationController popViewControllerAnimated:YES]; } } } /// -(void)wmplayer:(WMPlayer *)wmplayer clickedFullScreenButton:(UIButton *)fullScreenBtn{ if (self.wmPlayer.viewState==PlayerViewStateSmall) { [self enterFullScreen]; } } -(void)enterFullScreen{ if (self.wmPlayer.viewState!=PlayerViewStateSmall) { return; } LandscapeRightViewController *rightVC = [[LandscapeRightViewController alloc] init]; [self presentToVC:rightVC]; } -(void)exitFullScreen{ if (self.wmPlayer.viewState!=PlayerViewStateFullScreen) { return; } self.wmPlayer.isFullscreen = NO; self.wmPlayer.viewState = PlayerViewStateAnimating; [self dismissViewControllerAnimated:YES completion:^{ self.wmPlayer.viewState = PlayerViewStateSmall; }]; } -(void)presentToVC:(FullScreenHelperViewController *)aHelperVC{ self.wmPlayer.viewState = PlayerViewStateAnimating; self.wmPlayer.beforeBounds = self.wmPlayer.bounds; self.wmPlayer.beforeCenter = self.wmPlayer.center; self.wmPlayer.parentView = self.wmPlayer.superview; self.wmPlayer.isFullscreen = YES; aHelperVC.wmPlayer = self.wmPlayer; aHelperVC.modalPresentationStyle = UIModalPresentationFullScreen; aHelperVC.transitioningDelegate = self; [self presentViewController:aHelperVC animated:YES completion:^{ self.wmPlayer.viewState = PlayerViewStateFullScreen; }]; } /** * */ - (void)onDeviceOrientationChange:(NSNotification *)notification{ if (self.wmPlayer.viewState!=PlayerViewStateSmall) { return; } if (self.wmPlayer.isLockScreen){ return; } UIDeviceOrientation orientation = [UIDevice currentDevice].orientation; UIInterfaceOrientation interfaceOrientation = (UIInterfaceOrientation)orientation; switch (interfaceOrientation) { case UIInterfaceOrientationPortraitUpsideDown:{ } break; case UIInterfaceOrientationPortrait:{ } break; case UIInterfaceOrientationLandscapeLeft:{ [self presentToVC:[LandscapeLeftViewController new]]; } break; case UIInterfaceOrientationLandscapeRight:{ [self presentToVC:[LandscapeRightViewController new]]; } break; default: break; } } - (void)viewWillAppear:(BOOL)animated{ [super viewWillAppear:animated]; [self.navigationController setNavigationBarHidden:YES animated:NO]; self.view.frame = UIScreen.mainScreen.bounds; self.wmPlayer.delegate = self; } -(void)viewDidDisappear:(BOOL)animated{ [super viewDidAppear:animated]; [self.navigationController setNavigationBarHidden:NO animated:NO]; } #pragma mark #pragma mark viewDidLoad - (void)viewDidLoad{ [super viewDidLoad]; self.view.backgroundColor = [UIColor lightGrayColor]; self.wmPlayer = [[WMPlayer alloc] initWithFrame:CGRectMake(0, [WMPlayer IsiPhoneX]?34:0, self.view.frame.size.width, self.view.frame.size.width*(9.0/16))]; self.wmPlayer.delegate = self; self.wmPlayer.playerModel = self.playerModel; [self.view addSubview:self.wmPlayer]; [self.wmPlayer play]; self.nextBtn = [UIButton buttonWithType:UIButtonTypeCustom]; self.nextBtn.frame = CGRectMake(20, 500, 100, 40); [self.nextBtn addTarget:self action:@selector(nextVideo:) forControlEvents:UIControlEventTouchUpInside]; [self.nextBtn setTitle:@"" forState:UIControlStateNormal]; self.nextBtn.backgroundColor = [UIColor cyanColor]; [self.view addSubview:self.nextBtn]; // [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onDeviceOrientationChange:) name:UIDeviceOrientationDidChangeNotification object:nil]; } -(void)nextVideo:(UIButton *)sender{ [self.wmPlayer resetWMPlayer]; WMPlayerModel *newModel = [WMPlayerModel new]; newModel.title = @""; newModel.videoURL = [NSURL URLWithString:@"path_to_url"]; self.wmPlayer.playerModel = newModel; [self.wmPlayer play]; } - (nullable id <UIViewControllerAnimatedTransitioning>)animationControllerForPresentedController:(UIViewController *)presented presentingController:(UIViewController *)presenting sourceController:(UIViewController *)source{ return [[EnterFullScreenTransition alloc] initWithPlayer:self.wmPlayer]; } - (nullable id <UIViewControllerAnimatedTransitioning>)animationControllerForDismissedController:(UIViewController *)dismissed{ return [[ExitFullScreenTransition alloc] initWithPlayer:self.wmPlayer]; } - (void)dealloc{ [self.wmPlayer pause]; [self.wmPlayer removeFromSuperview]; self.wmPlayer = nil; [[NSNotificationCenter defaultCenter] removeObserver:self]; NSLog(@"DetailViewController dealloc"); } @end ```
/content/code_sandbox/PlayerDemo/ViewControllers/DetailViewController.m
objective-c
2016-02-02T02:51:55
2024-08-09T08:55:27
WMPlayer
zhengwenming/WMPlayer
3,272
1,296
```objective-c // // RootTabBarController.h // WMVideoPlayer // // Created by on 15/12/14. // #import <UIKit/UIKit.h> @interface RootTabBarController : UITabBarController @end ```
/content/code_sandbox/PlayerDemo/UITabBarController/RootTabBarController.h
objective-c
2016-02-02T02:51:55
2024-08-09T08:55:27
WMPlayer
zhengwenming/WMPlayer
3,272
47
```objective-c // // WMTabBar.h // PlayerDemo // // Created by apple on 2018/8/10. // #import <UIKit/UIKit.h> @interface WMTabBar : UITabBar @end ```
/content/code_sandbox/PlayerDemo/UITabBarController/WMTabBar.h
objective-c
2016-02-02T02:51:55
2024-08-09T08:55:27
WMPlayer
zhengwenming/WMPlayer
3,272
49
```objective-c // // WMTabBar.m // PlayerDemo // // Created by apple on 2018/8/10. // #import "WMTabBar.h" @interface WMTabBar() @property(nonatomic,assign)UIEdgeInsets oldSafeAreaInsets; @end @implementation WMTabBar - (instancetype)initWithFrame:(CGRect)frame{ self = [super initWithFrame:frame]; if (self) { self.oldSafeAreaInsets = UIEdgeInsetsZero; } return self; } - (void)awakeFromNib { [super awakeFromNib]; self.oldSafeAreaInsets = UIEdgeInsetsZero; } - (void)safeAreaInsetsDidChange { [super safeAreaInsetsDidChange]; if (!UIEdgeInsetsEqualToEdgeInsets(self.oldSafeAreaInsets, self.safeAreaInsets)) { [self invalidateIntrinsicContentSize]; if (self.superview) { [self.superview setNeedsLayout]; [self.superview layoutSubviews]; } } } - (CGSize)sizeThatFits:(CGSize)size { size = [super sizeThatFits:size]; if (@available(iOS 11.0, *)) { float bottomInset = self.safeAreaInsets.bottom; if (bottomInset > 0 && size.height < 50 && (size.height + bottomInset < 90)) { size.height += bottomInset; } } return size; } - (void)setFrame:(CGRect)frame { if (self.superview) { if (frame.origin.y + frame.size.height != self.superview.frame.size.height) { frame.origin.y = self.superview.frame.size.height - frame.size.height; } } [super setFrame:frame]; } @end ```
/content/code_sandbox/PlayerDemo/UITabBarController/WMTabBar.m
objective-c
2016-02-02T02:51:55
2024-08-09T08:55:27
WMPlayer
zhengwenming/WMPlayer
3,272
352
```objective-c // // RootTabBarController.m // WMVideoPlayer // // Created by on 15/12/14. // #import "RootTabBarController.h" #import "BaseNavigationController.h" #import "WMTabBar.h" #import "WMPlayer.h" @interface RootTabBarController ()<UITabBarControllerDelegate>{ } @property(nonatomic,strong)NSArray *infoDataArray; @end @implementation RootTabBarController -(NSArray *)infoDataArray{ if (_infoDataArray==nil) { _infoDataArray = @[ @{@"title":@"",@"selectedImage":@"tab_live_p",@"image":@"tab_live",@"VCName":@"TencentNewsViewController"}, @{@"title":@"",@"selectedImage":@"tab_room_p",@"image":@"tab_room",@"VCName":@"CameraViewController"}, @{@"title":@"",@"selectedImage":@"tab_me_p",@"image":@"tab_me",@"VCName":@"SinaNewsViewController"}]; } return _infoDataArray; } - (void)viewDidLoad { [super viewDidLoad]; if ([WMPlayer IsiPhoneX]) { WMTabBar *wmTabBar = [[WMTabBar alloc] init]; [self setValue:wmTabBar forKey:@"tabBar"]; } NSMutableArray *viewControllers = [NSMutableArray array]; for (NSDictionary *eachInfo in self.infoDataArray) { UIViewController *aVC = [NSClassFromString(eachInfo[@"VCName"]) new]; aVC.title = eachInfo[@"title"]; BaseNavigationController *aNav = [[BaseNavigationController alloc]initWithRootViewController:aVC]; aNav.tabBarItem = [[UITabBarItem alloc]initWithTitle:nil image:[[UIImage imageNamed:eachInfo[@"image"]]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] selectedImage:[[UIImage imageNamed: eachInfo[@"selectedImage"]]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]]; aNav.tabBarItem.imageInsets = UIEdgeInsetsMake(8, 0, -8, 0); [viewControllers addObject:aNav]; } self.viewControllers = viewControllers; self.delegate = self; [self setupTabBarBackgroundImage]; } -(void)viewWillAppear:(BOOL)animated{ [super viewWillAppear:animated]; self.view.frame = UIScreen.mainScreen.bounds; } - (void)setupTabBarBackgroundImage { // // [[UITabBar appearance] setShadowImage:[UIImage new]]; UIImage *image = [UIImage imageNamed:@"tab_bg"]; // UIImage *TabBgImage = [image resizableImageWithCapInsets:UIEdgeInsetsMake(40, 100, 40, 100) resizingMode:UIImageResizingModeStretch]; self.tabBar.backgroundImage = TabBgImage; self.tabBar.shadowImage = [UIImage new]; [self.tabBar setClipsToBounds:YES]; } - (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UINavigationController *)viewController{ if ([viewController.topViewController isKindOfClass:NSClassFromString(@"CameraViewController")]) { BaseNavigationController *testNav =[[BaseNavigationController alloc]initWithRootViewController:[NSClassFromString(@"VideoRecordViewController") new]]; [self.selectedViewController presentViewController:testNav animated:YES completion:^{ }]; return NO; } return YES; } - (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController{ } -(BOOL)prefersStatusBarHidden{ if(self.selectedViewController.prefersStatusBarHidden){ return self.selectedViewController.prefersStatusBarHidden; } return NO; } - (UIStatusBarAnimation)preferredStatusBarUpdateAnimation{ if(self.selectedViewController.preferredStatusBarUpdateAnimation){ return self.selectedViewController.preferredStatusBarUpdateAnimation; } return UIStatusBarAnimationNone; } -(BOOL)shouldAutorotate{ if(self.selectedViewController.shouldAutorotate){ return self.selectedViewController.shouldAutorotate; } return YES; } -(UIInterfaceOrientationMask)supportedInterfaceOrientations{ if(self.selectedViewController.supportedInterfaceOrientations){ return self.selectedViewController.supportedInterfaceOrientations; } return UIInterfaceOrientationMaskPortrait; } -(UIInterfaceOrientation)preferredInterfaceOrientationForPresentation{ if(self.selectedViewController.preferredInterfaceOrientationForPresentation){ return self.selectedViewController.preferredInterfaceOrientationForPresentation; } return UIInterfaceOrientationPortrait; } @end ```
/content/code_sandbox/PlayerDemo/UITabBarController/RootTabBarController.m
objective-c
2016-02-02T02:51:55
2024-08-09T08:55:27
WMPlayer
zhengwenming/WMPlayer
3,272
890
```objective-c // // VideoRecordViewController.m // iShow // // Created by on 17/3/8. // // #import "VideoRecordViewController.h" #import "VideoCameraView.h" @interface VideoRecordViewController ()<VideoCameraDelegate> @property (nonatomic ,strong) UITextField* configWidth; @property (nonatomic ,strong) UITextField* configHight; @property (nonatomic ,strong) UITextField* configBit; @property (nonatomic ,strong) UITextField* configFrameRate; @property (nonatomic ,strong) UIButton* okBtn; @end @implementation VideoRecordViewController - (void)viewDidLoad { [super viewDidLoad]; } -(void)viewWillAppear:(BOOL)animated{ [super viewWillAppear:animated]; [self.navigationController setNavigationBarHidden:YES animated:NO]; [self clickOKBtn]; } -(void)clickBackHome{ [self.navigationController popViewControllerAnimated:YES]; } -(void)clickOKBtn{ int width,hight,bit,framRate; { width = 720; hight = 1280; } { bit = 2500000; } { framRate = 30; } bool needNewVideoCamera = YES; for (UIView* subView in self.view.subviews) { if ([subView isKindOfClass:[VideoCameraView class]]) { needNewVideoCamera = NO; } } if (needNewVideoCamera) { CGRect frame = [[UIScreen mainScreen] bounds]; VideoCameraView* videoCameraView = [[VideoCameraView alloc] initWithFrame:frame]; videoCameraView.delegate = self; videoCameraView.width = [NSNumber numberWithInteger:width]; videoCameraView.hight = [NSNumber numberWithInteger:hight]; videoCameraView.bit = [NSNumber numberWithInteger:bit]; videoCameraView.frameRate = [NSNumber numberWithInteger:framRate]; typeof(self) __weak weakself = self; videoCameraView.backToHomeBlock = ^(){ [weakself.navigationController dismissViewControllerAnimated:NO completion:nil]; }; [self.view addSubview:videoCameraView]; } } -(void)presentCor:(UIViewController *)cor{ [self presentViewController:cor animated:YES completion:nil]; } -(void)pushCor:(UIViewController *)cor{ [self.navigationController pushViewController:cor animated:YES]; } - (BOOL)prefersStatusBarHidden{ return YES; } -(void)dealloc{ NSLog(@"%@",self.class); } @end ```
/content/code_sandbox/PlayerDemo/CustomVideoCamera/VideoRecordViewController.m
objective-c
2016-02-02T02:51:55
2024-08-09T08:55:27
WMPlayer
zhengwenming/WMPlayer
3,272
503
```objective-c /*! @header SinaNewsViewController.m @abstract Githubpath_to_url CSDN:path_to_url @author Created by zhengwenming on 16/1/19 @version 1.00 16/1/19 Creation() */ #import "SinaNewsViewController.h" #import "VideoCell.h" #import "WMPlayer.h" #import "DetailViewController.h" #import "AppDelegate.h" #import "MJRefresh.h" #import "Masonry.h" #import "FullScreenHelperViewController.h" #import "LandscapeRightViewController.h" #import "LandscapeLeftViewController.h" #import "EnterFullScreenTransition.h" #import "ExitFullScreenTransition.h" @interface SinaNewsViewController ()<UITableViewDelegate,UITableViewDataSource,UIScrollViewDelegate,WMPlayerDelegate,UIViewControllerTransitioningDelegate>{ } @property(nonatomic,strong)VideoCell *currentCell; @property(nonatomic,strong)WMPlayer *wmPlayer; @property(nonatomic,strong)NSMutableArray *dataSource; @end @implementation SinaNewsViewController -(UIStatusBarStyle)preferredStatusBarStyle{ return UIStatusBarStyleLightContent; } -(BOOL)prefersStatusBarHidden{ return NO; } -(BOOL)shouldAutorotate{ return YES; } -(UIInterfaceOrientationMask)supportedInterfaceOrientations{ return UIInterfaceOrientationMaskPortrait; } -(UIInterfaceOrientation)preferredInterfaceOrientationForPresentation{ return UIInterfaceOrientationPortrait; } -(NSMutableArray *)dataSource{ if (_dataSource==nil) { _dataSource = [NSMutableArray array]; } return _dataSource; } -(UITableView *)table{ if(_table==nil){ _table = [[UITableView alloc] init]; _table.showsVerticalScrollIndicator = NO; _table.delegate = self; _table.dataSource = self; _table.rowHeight = 274.f; _table.separatorStyle=UITableViewCellSeparatorStyleNone; if (@available(ios 11.0,*)) { UITableView.appearance.estimatedRowHeight = 0; UITableView.appearance.estimatedSectionFooterHeight = 0; UITableView.appearance.estimatedSectionHeaderHeight = 0; } if (@available(iOS 15.0, *)) { _table.sectionHeaderTopPadding = 0; //iOS _table.prefetchingEnabled = NO; } else { // Fallback on earlier versions } [self.view addSubview:_table]; [_table mas_makeConstraints:^(MASConstraintMaker *make) { make.top.bottom.leading.trailing.equalTo(self.view); }]; } return _table; } /// -(void)wmplayer:(WMPlayer *)wmplayer clickedCloseButton:(UIButton *)closeBtn{ if (wmplayer.isFullscreen) { [self exitFullScreen]; }else{ [self.wmPlayer pause]; [self releaseWMPlayer]; self.currentCell.playBtn.hidden = NO; } } -(void)wmplayer:(WMPlayer *)wmplayer clickedFullScreenButton:(UIButton *)fullScreenBtn{ if (self.wmPlayer.viewState==PlayerViewStateSmall) { [self enterFullScreen]; } } -(void)enterFullScreen{ if (self.wmPlayer.viewState!=PlayerViewStateSmall) { return; } LandscapeRightViewController *rightVC = [[LandscapeRightViewController alloc] init]; [self presentToVC:rightVC]; } -(void)presentToVC:(FullScreenHelperViewController *)aHelperVC{ self.wmPlayer.viewState = PlayerViewStateAnimating; self.wmPlayer.beforeBounds = self.wmPlayer.bounds; self.wmPlayer.beforeCenter = self.wmPlayer.center; self.wmPlayer.parentView = self.wmPlayer.superview; self.wmPlayer.isFullscreen = YES; self.wmPlayer.backBtnStyle = BackBtnStylePop; aHelperVC.wmPlayer = self.wmPlayer; aHelperVC.modalPresentationStyle = UIModalPresentationFullScreen; aHelperVC.transitioningDelegate = self; [self presentViewController:aHelperVC animated:YES completion:^{ self.wmPlayer.viewState = PlayerViewStateFullScreen; }]; } -(void)exitFullScreen{ if (self.wmPlayer.viewState!=PlayerViewStateFullScreen) { return; } self.wmPlayer.isFullscreen = NO; self.wmPlayer.backBtnStyle = BackBtnStyleClose; self.wmPlayer.viewState = PlayerViewStateAnimating; [self dismissViewControllerAnimated:YES completion:^{ self.wmPlayer.viewState = PlayerViewStateSmall; }]; } /** * */ - (void)onDeviceOrientationChange:(NSNotification *)notification{ if (self.wmPlayer.viewState!=PlayerViewStateSmall) { return; } if (self.wmPlayer.isLockScreen){ return; } UIDeviceOrientation orientation = [UIDevice currentDevice].orientation; UIInterfaceOrientation interfaceOrientation = (UIInterfaceOrientation)orientation; switch (interfaceOrientation) { case UIInterfaceOrientationPortraitUpsideDown:{ NSLog(@"3---"); } break; case UIInterfaceOrientationPortrait:{ NSLog(@"0---"); } break; case UIInterfaceOrientationLandscapeLeft:{ NSLog(@"2---"); LandscapeLeftViewController *leftVC = [[LandscapeLeftViewController alloc] init]; [self presentToVC:leftVC]; } break; case UIInterfaceOrientationLandscapeRight:{ NSLog(@"1---"); LandscapeRightViewController *rightVC = [[LandscapeRightViewController alloc] init]; [self presentToVC:rightVC]; } break; default: break; } } - (void)viewWillAppear:(BOOL)animated{ [super viewWillAppear:animated]; self.view.frame = UIScreen.mainScreen.bounds; self.navigationController.navigationBarHidden = NO; self.wmPlayer.delegate = self; } - (void)viewDidLoad { [super viewDidLoad]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onDeviceOrientationChange:) name:UIDeviceOrientationDidChangeNotification object:nil]; [self.table registerNib:[UINib nibWithNibName:@"VideoCell" bundle:nil] forCellReuseIdentifier:@"VideoCell"]; [VideoDataModel getHomePageVideoDataWithBlock:^(NSArray *dateAry, NSError *error) { [self.dataSource addObjectsFromArray:dateAry]; [self.table reloadData]; }]; } -(NSInteger )numberOfSectionsInTableView:(UITableView *)tableView{ return 1; } -(NSInteger )tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ return self.dataSource.count; } -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ VideoCell *cell = (VideoCell *)[tableView dequeueReusableCellWithIdentifier:@"VideoCell"]; cell.videoModel = [self.dataSource objectAtIndex:indexPath.row]; cell.videoModel.indexPath = indexPath; __weak __typeof(&*self) weakSelf = self; cell.startPlayVideoBlcok = ^(UIImageView *backgroundIV, VideoDataModel *videoModel) { [weakSelf releaseWMPlayer]; weakSelf.currentCell = (VideoCell *)backgroundIV.superview.superview; WMPlayerModel *playerModel = [WMPlayerModel new]; playerModel.title = videoModel.nickname; playerModel.videoURL = [NSURL URLWithString:videoModel.video_url]; // playerModel.videoURL = [NSURL URLWithString:@"path_to_url"]; playerModel.indexPath = indexPath; weakSelf.wmPlayer = [[WMPlayer alloc] initWithFrame:backgroundIV.bounds]; weakSelf.wmPlayer.delegate = weakSelf; weakSelf.wmPlayer.playerModel = playerModel; [backgroundIV addSubview:weakSelf.wmPlayer]; weakSelf.wmPlayer.backBtnStyle = BackBtnStyleClose; [backgroundIV bringSubviewToFront:weakSelf.wmPlayer]; [weakSelf.wmPlayer play]; [weakSelf.table reloadData]; weakSelf.wmPlayer.oldFrameToWindow = [weakSelf.wmPlayer convertRect:weakSelf.wmPlayer.bounds toView:[UIApplication sharedApplication].keyWindow]; }; if (self.wmPlayer&&self.wmPlayer.superview) { if (indexPath.row==self.currentCell.videoModel.indexPath.row) { cell.playBtn.hidden = YES; }else{ cell.playBtn.hidden = NO; } }else{ cell.playBtn.hidden = NO; } return cell; } #pragma mark scrollView delegate - (void)scrollViewDidScroll:(UIScrollView *)scrollView{ if(scrollView ==self.table){ if (self.wmPlayer==nil) { return; } if (self.wmPlayer.superview) { CGRect rectInTableView = [self.table rectForRowAtIndexPath:self.currentCell.videoModel.indexPath]; CGRect rectInSuperview = [self.table convertRect:rectInTableView toView:[self.table superview]]; if (rectInSuperview.origin.y<-self.currentCell.backgroundIV.frame.size.height||rectInSuperview.origin.y>[UIScreen mainScreen].bounds.size.height-([WMPlayer IsiPhoneX]?88:64)-([WMPlayer IsiPhoneX]?83:49)) {// [self.currentCell.playBtn.superview bringSubviewToFront:self.currentCell.playBtn]; } } } } /** * WMPlayer */ -(void)releaseWMPlayer{ [self.wmPlayer removeFromSuperview]; self.wmPlayer = nil; } - (nullable id <UIViewControllerAnimatedTransitioning>)animationControllerForPresentedController:(UIViewController *)presented presentingController:(UIViewController *)presenting sourceController:(UIViewController *)source{ return [[EnterFullScreenTransition alloc] initWithPlayer:self.wmPlayer]; } - (nullable id <UIViewControllerAnimatedTransitioning>)animationControllerForDismissedController:(UIViewController *)dismissed{ return [[ExitFullScreenTransition alloc] initWithPlayer:self.wmPlayer]; } -(void)dealloc{ NSLog(@"%@ dealloc",[self class]); [self releaseWMPlayer]; [[NSNotificationCenter defaultCenter] removeObserver:self]; } @end ```
/content/code_sandbox/PlayerDemo/ViewControllers/SinaNewsViewController.m
objective-c
2016-02-02T02:51:55
2024-08-09T08:55:27
WMPlayer
zhengwenming/WMPlayer
3,272
2,034
```objective-c // // SDAVAssetExportSession.h // // This file is part of the SDAVAssetExportSession package. // // // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. // #import <Foundation/Foundation.h> #import <AVFoundation/AVFoundation.h> @protocol SDAVAssetExportSessionDelegate; /** * An `SDAVAssetExportSession` object transcodes the contents of an AVAsset source object to create an output * of the form described by specified video and audio settings. It implements most of the API of Apple provided * `AVAssetExportSession` but with the capability to provide you own video and audio settings instead of the * limited set of Apple provided presets. * * After you have initialized an export session with the asset that contains the source media, video and audio * settings, and the output file type (outputFileType), you can start the export running by invoking * `exportAsynchronouslyWithCompletionHandler:`. Because the export is performed asynchronously, this method * returns immediately you can observe progress to check on the progress. * * The completion handler you supply to `exportAsynchronouslyWithCompletionHandler:` is called whether the export * fails, completes, or is cancelled. Upon completion, the status property indicates whether the export has * completed successfully. If it has failed, the value of the error property supplies additional information * about the reason for the failure. */ @interface SDAVAssetExportSession : NSObject @property (nonatomic, weak) id<SDAVAssetExportSessionDelegate> delegate; /** * The asset with which the export session was initialized. */ @property (nonatomic, strong, readonly) AVAsset *asset; /** * Indicates whether video composition is enabled for export, and supplies the instructions for video composition. * * You can observe this property using key-value observing. */ @property (nonatomic, copy) AVVideoComposition *videoComposition; /** * Indicates whether non-default audio mixing is enabled for export, and supplies the parameters for audio mixing. */ @property (nonatomic, copy) AVAudioMix *audioMix; /** * The type of file to be written by the session. * * The value is a UTI string corresponding to the file type to use when writing the asset. * For a list of constants specifying UTIs for standard file types, see `AV Foundation Constants Reference`. * * You can observe this property using key-value observing. */ @property (nonatomic, copy) NSString *outputFileType; /** * The URL of the export sessions output. * * You can observe this property using key-value observing. */ @property (nonatomic, copy) NSURL *outputURL; /** * The settings used for input video track. * * The dictionarys keys are from <CoreVideo/CVPixelBuffer.h>. */ @property (nonatomic, copy) NSDictionary *videoInputSettings; /** * The settings used for encoding the video track. * * A value of nil specifies that appended output should not be re-encoded. * The dictionarys keys are from <AVFoundation/AVVideoSettings.h>. */ @property (nonatomic, copy) NSDictionary *videoSettings; /** * The settings used for encoding the audio track. * * A value of nil specifies that appended output should not be re-encoded. * The dictionarys keys are from <CoreVideo/CVPixelBuffer.h>. */ @property (nonatomic, copy) NSDictionary *audioSettings; /** * The time range to be exported from the source. * * The default time range of an export session is `kCMTimeZero` to `kCMTimePositiveInfinity`, * meaning that (modulo a possible limit on file length) the full duration of the asset will be exported. * * You can observe this property using key-value observing. * */ @property (nonatomic, assign) CMTimeRange timeRange; /** * Indicates whether the movie should be optimized for network use. * * You can observe this property using key-value observing. */ @property (nonatomic, assign) BOOL shouldOptimizeForNetworkUse; /** * The metadata to be written to the output file by the export session. */ @property (nonatomic, copy) NSArray *metadata; /** * Describes the error that occurred if the export status is `AVAssetExportSessionStatusFailed` * or `AVAssetExportSessionStatusCancelled`. * * If there is no error to report, the value of this property is nil. */ @property (nonatomic, strong, readonly) NSError *error; /** * The progress of the export on a scale from 0 to 1. * * * A value of 0 means the export has not yet begun, 1 means the export is complete. * * Unlike Apple provided `AVAssetExportSession`, this property can be observed using key-value observing. */ @property (nonatomic, assign, readonly) float progress; /** * The status of the export session. * * For possible values, see AVAssetExportSessionStatus. * * You can observe this property using key-value observing. (TODO) */ @property (nonatomic, assign, readonly) AVAssetExportSessionStatus status; /** * Returns an asset export session configured with a specified asset. * * @param asset The asset you want to export * @return An asset export session initialized to export `asset`. */ + (id)exportSessionWithAsset:(AVAsset *)asset; /** * Initializes an asset export session with a specified asset. * * @param asset The asset you want to export * @return An asset export session initialized to export `asset`. */ - (id)initWithAsset:(AVAsset *)asset; /** * Starts the asynchronous execution of an export session. * * This method starts an asynchronous export operation and returns immediately. status signals the terminal * state of the export session, and if a failure occurs, error describes the problem. * * If internal preparation for export fails, handler is invoked synchronously. The handler may also be called * asynchronously, after the method returns, in the following cases: * * 1. If a failure occurs during the export, including failures of loading, re-encoding, or writing media data to the output. * 2. If cancelExport is invoked. * 3. After the export session succeeds, having completely written its output to the outputURL. * * @param handler A block that is invoked when writing is complete or in the event of writing failure. */ - (void)exportAsynchronouslyWithCompletionHandler:(void (^)())handler; /** * Cancels the execution of an export session. * * You can invoke this method when the export is running. */ - (void)cancelExport; @end @protocol SDAVAssetExportSessionDelegate <NSObject> - (void)exportSession:(SDAVAssetExportSession *)exportSession renderFrame:(CVPixelBufferRef)pixelBuffer withPresentationTime:(CMTime)presentationTime toBuffer:(CVPixelBufferRef)renderBuffer; @end ```
/content/code_sandbox/PlayerDemo/CustomVideoCamera/SDAVAssetExportSession.h
objective-c
2016-02-02T02:51:55
2024-08-09T08:55:27
WMPlayer
zhengwenming/WMPlayer
3,272
1,421
```objective-c // // VideoCameraView.h // addproject // // Created by on 17/3/3. // #import <UIKit/UIKit.h> #import "GPUImage.h" /** @param UIButton */ typedef void(^clickBackToHomeBtnBlock)(); @protocol VideoCameraDelegate <NSObject>// - (void)presentCor:(UIViewController*)cor;// - (void)pushCor:(UIViewController*)cor;// @end @interface VideoCameraView : UIView{ GPUImageVideoCamera *videoCamera; GPUImageOutput<GPUImageInput> *filter; GPUImageMovieWriter *movieWriter; NSString *pathToMovie; GPUImageView *filteredVideoView; CALayer *_focusLayer; NSTimer *myTimer; UILabel *timeLabel; NSDate *fromdate; CGRect mainScreenFrame; } @property (nonatomic , copy) clickBackToHomeBtnBlock backToHomeBlock; @property (nonatomic , strong) NSNumber* width; @property (nonatomic , strong) NSNumber* hight; @property (nonatomic , strong) NSNumber* bit; @property (nonatomic , strong) NSNumber* frameRate; @property (nonatomic, assign) id<VideoCameraDelegate>delegate;// - (instancetype)initWithFrame:(CGRect)frame NS_DESIGNATED_INITIALIZER; @end ```
/content/code_sandbox/PlayerDemo/CustomVideoCamera/VideoCameraView.h
objective-c
2016-02-02T02:51:55
2024-08-09T08:55:27
WMPlayer
zhengwenming/WMPlayer
3,272
267
```objective-c // // VideoRecordViewController.h // iShow // // Created by on 17/3/8. // // #import <UIKit/UIKit.h> #import "BaseViewController.h" @interface VideoRecordViewController : BaseViewController @end ```
/content/code_sandbox/PlayerDemo/CustomVideoCamera/VideoRecordViewController.h
objective-c
2016-02-02T02:51:55
2024-08-09T08:55:27
WMPlayer
zhengwenming/WMPlayer
3,272
52
```objective-c // // UIView+Tools.h // VideoRecord // // Created by guimingsu on 14-8-25. // #import <UIKit/UIKit.h> @interface UIView (Tools) -(void)makeCornerRadius:(float)radius borderColor:(UIColor*)bColor borderWidth:(float)bWidth; @end ```
/content/code_sandbox/PlayerDemo/CustomVideoCamera/UIView+Tools.h
objective-c
2016-02-02T02:51:55
2024-08-09T08:55:27
WMPlayer
zhengwenming/WMPlayer
3,272
67
```xml // // EditingPublishingDynamicViewController.m // iShow // // Created by on 17/3/18. // // #import "EditingPublishingDynamicViewController.h" #import "MBProgressHUD.h" #import "AFNetworking.h" #import <CoreLocation/CoreLocation.h> #import "Masonry.h" #import <AVFoundation/AVFoundation.h> #import "VideoDataModel.h" #import "WMPlayer.h" #define SCREEN_LayoutScaleBaseOnIPHEN6(x) (([UIScreen mainScreen].bounds.size.width)/375.00 * x) #define kSignatureContextLengths 20 #define COLOR_FONT_LIGHTGRAY 0x999999 #define COLOR_LINEVIEW_DARKGRAY 0x666666 #define COLOR_BACKBG_DARKGRAY 0x666666 #define COLOR_FONT_YELLOW 0xFDD854 #define COLOR_FONT_WHITE 0xFFFFFF #define RGB16(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0] @interface EditingPublishingDynamicViewController ()<UITextViewDelegate,CLLocationManagerDelegate> { MBProgressHUD* HUD; BOOL isExceed_cai; } @property (nonatomic ,strong) UIImage* videoCoverImg; @property (strong, nonatomic) UILabel *limitLabel; @property (strong, nonatomic) UITextView *contentTextField; @property (strong, nonatomic) UIButton* lefthWXBtn; @property (strong, nonatomic) UIButton* rightWXBtn; @property (strong, nonatomic) CLLocationManager* locationManager; @property (strong, nonatomic) NSString* cityName; @end @implementation EditingPublishingDynamicViewController - (void)viewDidLoad { [super viewDidLoad]; self.navigationController.navigationBarHidden = YES; // _videoCoverImg = [[AppDelegate appDelegate].cmImageSize getImage:[[_videoURL absoluteString ] stringByReplacingOccurrencesOfString:@"file://" withString:@""]]; _videoCoverImg = [self getImage:[[_videoURL absoluteString ] stringByReplacingOccurrencesOfString:@"file://" withString:@""]]; UIImageView* bgImgView = [[UIImageView alloc] initWithImage:_videoCoverImg]; [self.view addSubview:bgImgView]; UIView* superView = self.view; bgImgView.frame = self.view.bounds; [bgImgView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.left.width.height.equalTo(superView); }]; UIBlurEffect *blurEffrct =[UIBlurEffect effectWithStyle:UIBlurEffectStyleDark]; // UIVisualEffectView* visualEffectView = [[UIVisualEffectView alloc]initWithEffect:blurEffrct]; visualEffectView.alpha = .7; [bgImgView addSubview:visualEffectView]; visualEffectView.frame = self.view.bounds; [visualEffectView mas_makeConstraints:^(MASConstraintMaker *make) { make.right.left.top.bottom.equalTo(superView); }]; UIView* headerBar = [[UIView alloc] init]; [self.view addSubview:headerBar]; [headerBar mas_makeConstraints:^(MASConstraintMaker *make) { make.left.right.equalTo(self.view); make.top.equalTo(self.view).offset([WMPlayer IsiPhoneX]?34:0); make.width.equalTo(@(100)); }]; headerBar.alpha = .8; UILabel* titleLabel = [[UILabel alloc] init]; titleLabel.text = @""; titleLabel.textColor = [UIColor whiteColor]; [headerBar addSubview:titleLabel]; [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.centerX.centerY.equalTo(headerBar); }]; UIButton* nextBtn = [[UIButton alloc] init]; [nextBtn setTitle:@"" forState:UIControlStateNormal]; [nextBtn.titleLabel setFont:[UIFont systemFontOfSize:15]]; [nextBtn addTarget:self action:@selector(saveVideoToLoacl) forControlEvents:UIControlEventTouchUpInside]; [headerBar addSubview:nextBtn]; [nextBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.right.bottom.top.equalTo(headerBar); make.width.equalTo(@(100)); }]; UIButton* BackToVideoCammer = [[UIButton alloc] init]; [BackToVideoCammer setImage:[UIImage imageNamed:@"BackToVideoCammer"] forState:UIControlStateNormal]; [BackToVideoCammer addTarget:self action:@selector(backToEditVideoCor) forControlEvents:UIControlEventTouchUpInside]; [headerBar addSubview:BackToVideoCammer]; [BackToVideoCammer mas_makeConstraints:^(MASConstraintMaker *make) { make.left.bottom.top.equalTo(headerBar); make.width.equalTo(@(60)); }]; UIImageView* changeImageView = [[UIImageView alloc] init]; // changeImageView.image = [[AppDelegate appDelegate].cmImageSize getImage:[[_videoURL absoluteString ] stringByReplacingOccurrencesOfString:@"file://" withString:@""]]; changeImageView.image = [self getImage:[[_videoURL absoluteString ] stringByReplacingOccurrencesOfString:@"file://" withString:@""]]; // [[AppDelegate appDelegate].cmImageSize getImage:[[_videoURL absoluteString ] stringByReplacingOccurrencesOfString:@"file://" withString:@""]] changeImageView.contentMode = UIViewContentModeScaleAspectFill; changeImageView.clipsToBounds = YES; [superView addSubview:changeImageView]; [changeImageView mas_makeConstraints:^(MASConstraintMaker *make) { make.centerX.equalTo(superView); make.width.height.equalTo(@(SCREEN_LayoutScaleBaseOnIPHEN6(150))); make.top.equalTo(superView).offset(SCREEN_LayoutScaleBaseOnIPHEN6( 85.5)); }]; // [[AppDelegate appDelegate].cmImageSize setImagesRounded:changeImageView cornerRadiusValue:3 borderWidthValue:0 borderColorWidthValue:[UIColor clearColor] ]; changeImageView.layer.masksToBounds = YES; changeImageView.layer.cornerRadius = 3; UIButton* changeVideoCovBtn = [UIButton new]; changeVideoCovBtn.titleLabel.font = [UIFont systemFontOfSize:SCREEN_LayoutScaleBaseOnIPHEN6(13.0)]; changeVideoCovBtn.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:.5]; // [changeVideoCovBtn setTitle:@"" forState:UIControlStateNormal]; [changeVideoCovBtn setTitle:@"" forState:UIControlStateNormal]; [changeImageView addSubview:changeVideoCovBtn]; [changeVideoCovBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.left.right.bottom.equalTo(changeImageView); make.height.equalTo(@(SCREEN_LayoutScaleBaseOnIPHEN6(30))); }]; // [[AppDelegate appDelegate].cmImageSize setButtonsRounded:changeVideoCovBtn cornerRadiusValue:SCREEN_LayoutScaleBaseOnIPHEN6(3) borderWidthValue:0 borderColorWidthValue:RGB16(COLOR_FONT_WHITE)]; changeVideoCovBtn.layer.masksToBounds = YES; changeVideoCovBtn.layer.cornerRadius = SCREEN_LayoutScaleBaseOnIPHEN6(3); UIView* bottomBarView0 = [[UIView alloc] init]; [superView addSubview:bottomBarView0]; bottomBarView0.backgroundColor = [UIColor blackColor]; [bottomBarView0 mas_makeConstraints:^(MASConstraintMaker *make) { make.bottom.left.right.equalTo(superView); make.height.equalTo(@(SCREEN_LayoutScaleBaseOnIPHEN6(390))); }]; bottomBarView0.alpha = .7; UIView* bottomBarView = [[UIView alloc] init]; [superView addSubview:bottomBarView]; bottomBarView.backgroundColor = [UIColor clearColor]; [bottomBarView mas_makeConstraints:^(MASConstraintMaker *make) { make.bottom.left.right.equalTo(superView); make.height.equalTo(@(SCREEN_LayoutScaleBaseOnIPHEN6(390))); }]; UIButton* backBtn = [UIButton new]; backBtn.titleLabel.font = [UIFont systemFontOfSize:SCREEN_LayoutScaleBaseOnIPHEN6(18.0)]; [backBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; backBtn.backgroundColor = RGB16(COLOR_FONT_YELLOW); [backBtn setTitle:@"" forState:UIControlStateNormal]; [backBtn addTarget:self action:@selector(publishingDynamic:) forControlEvents:UIControlEventTouchUpInside]; [bottomBarView addSubview:backBtn]; [backBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(bottomBarView).offset(SCREEN_LayoutScaleBaseOnIPHEN6(40.0)); make.right.equalTo(bottomBarView).offset(-SCREEN_LayoutScaleBaseOnIPHEN6(40.0)); make.bottom.equalTo(bottomBarView).offset(-SCREEN_LayoutScaleBaseOnIPHEN6(38.0)); make.height.equalTo(@(SCREEN_LayoutScaleBaseOnIPHEN6(45.0))); }]; // [[AppDelegate appDelegate].cmImageSize setButtonsRounded:backBtn cornerRadiusValue:SCREEN_LayoutScaleBaseOnIPHEN6(45.0)/2.0 borderWidthValue:0 borderColorWidthValue:RGB16(COLOR_FONT_WHITE)]; backBtn.layer.masksToBounds = YES; backBtn.layer.cornerRadius = SCREEN_LayoutScaleBaseOnIPHEN6(45.0)/2.0; UILabel* leftWXLabel = [UILabel new]; leftWXLabel.font = [UIFont systemFontOfSize:SCREEN_LayoutScaleBaseOnIPHEN6(12.0)]; leftWXLabel.textColor = RGB16(COLOR_FONT_LIGHTGRAY); leftWXLabel.text = @""; [bottomBarView addSubview:leftWXLabel]; [leftWXLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.centerX.equalTo(bottomBarView).offset(-SCREEN_LayoutScaleBaseOnIPHEN6(60.0)); make.bottom.equalTo(backBtn.mas_top).offset(-SCREEN_LayoutScaleBaseOnIPHEN6(33.0)); }]; UILabel* rightWXLabel = [UILabel new]; rightWXLabel.font = [UIFont systemFontOfSize:SCREEN_LayoutScaleBaseOnIPHEN6(12.0)]; rightWXLabel.textColor = RGB16(COLOR_FONT_LIGHTGRAY); rightWXLabel.text = @""; [bottomBarView addSubview:rightWXLabel]; [rightWXLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.centerX.equalTo(bottomBarView).offset(SCREEN_LayoutScaleBaseOnIPHEN6(60.0)); make.bottom.equalTo(backBtn.mas_top).offset(-SCREEN_LayoutScaleBaseOnIPHEN6(33.0)); }]; _lefthWXBtn = [UIButton new]; /*kInitvitionFriendImage*/ [_lefthWXBtn setImage:[UIImage imageNamed:@""] forState:UIControlStateSelected]; [_lefthWXBtn setImage:[UIImage imageNamed:@""] forState:UIControlStateNormal]; [_lefthWXBtn addTarget:self action:@selector(clickWXFriendSShareBtn:) forControlEvents:UIControlEventTouchUpInside]; [bottomBarView addSubview:_lefthWXBtn]; [_lefthWXBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.centerX.equalTo(leftWXLabel); make.bottom.equalTo(leftWXLabel.mas_top).offset(-SCREEN_LayoutScaleBaseOnIPHEN6(10.0)); make.width.height.equalTo(@(SCREEN_LayoutScaleBaseOnIPHEN6(44.0))); }]; _rightWXBtn = [UIButton new]; [_rightWXBtn setImage:[UIImage imageNamed:@""] forState:UIControlStateSelected]; [_rightWXBtn setImage:[UIImage imageNamed:@""] forState:UIControlStateNormal]; [_rightWXBtn addTarget:self action:@selector(clickWeChatShareBtn:) forControlEvents:UIControlEventTouchUpInside]; [bottomBarView addSubview:_rightWXBtn]; [_rightWXBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.centerX.equalTo(rightWXLabel); make.bottom.equalTo(rightWXLabel.mas_top).offset(-SCREEN_LayoutScaleBaseOnIPHEN6(10.0)); make.width.height.equalTo(@(SCREEN_LayoutScaleBaseOnIPHEN6(44.0))); }]; UILabel* shareTipLabel = [UILabel new]; shareTipLabel.font = [UIFont systemFontOfSize:SCREEN_LayoutScaleBaseOnIPHEN6(12.0)]; shareTipLabel.textColor = [UIColor whiteColor];; shareTipLabel.text = @""; [bottomBarView addSubview:shareTipLabel]; [shareTipLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.centerX.equalTo(bottomBarView); make.bottom.equalTo(_rightWXBtn.mas_top).offset(-SCREEN_LayoutScaleBaseOnIPHEN6(27.0)); }]; UIView* leftLineView = [UIView new]; leftLineView.backgroundColor = RGB16(COLOR_LINEVIEW_DARKGRAY); [bottomBarView addSubview:leftLineView]; [leftLineView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(bottomBarView).offset(SCREEN_LayoutScaleBaseOnIPHEN6(40.0)); make.right.equalTo(shareTipLabel.mas_left).offset(-SCREEN_LayoutScaleBaseOnIPHEN6(8.0)); make.height.equalTo(@(0.7)); make.centerY.equalTo(shareTipLabel); }]; UIView* rightLineView = [UIView new]; rightLineView.backgroundColor = RGB16(COLOR_LINEVIEW_DARKGRAY); [bottomBarView addSubview:rightLineView]; [rightLineView mas_makeConstraints:^(MASConstraintMaker *make) { make.right.equalTo(bottomBarView).offset(-SCREEN_LayoutScaleBaseOnIPHEN6(40.0)); make.left.equalTo(shareTipLabel.mas_right).offset(SCREEN_LayoutScaleBaseOnIPHEN6(8.0)); make.height.equalTo(@(0.7)); make.centerY.equalTo(shareTipLabel); }]; _contentTextField = [[UITextView alloc ] init]; _contentTextField.returnKeyType = UIReturnKeyDone; _contentTextField.text = @"(20)"; _contentTextField.textColor = [UIColor lightGrayColor]; [_contentTextField setFont:[UIFont systemFontOfSize:SCREEN_LayoutScaleBaseOnIPHEN6(15.0)]]; [_contentTextField setDelegate:self]; [bottomBarView addSubview:_contentTextField]; [_contentTextField mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(bottomBarView).offset(SCREEN_LayoutScaleBaseOnIPHEN6(30)); make.bottom.equalTo(shareTipLabel.mas_top).offset(-SCREEN_LayoutScaleBaseOnIPHEN6(70)); make.left.equalTo(bottomBarView).offset(SCREEN_LayoutScaleBaseOnIPHEN6(20)); make.right.equalTo(bottomBarView).offset(-SCREEN_LayoutScaleBaseOnIPHEN6(20)); }]; // [[AppDelegate appDelegate].cmImageSize setTextViewsRounded:_contentTextField cornerRadiusValue:4 borderWidthValue:0 borderColorWidthValue:[UIColor clearColor]]; _contentTextField.layer.masksToBounds = YES; _contentTextField.layer.cornerRadius = 4; _limitLabel = [[UILabel alloc] init]; _limitLabel.text = @"0/20"; _limitLabel.font = [UIFont systemFontOfSize:SCREEN_LayoutScaleBaseOnIPHEN6(13.0)]; _limitLabel.textColor = [UIColor blackColor]; [bottomBarView addSubview:_limitLabel]; [_limitLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.bottom.equalTo(_contentTextField.mas_bottom).offset(-SCREEN_LayoutScaleBaseOnIPHEN6(5)); make.right.equalTo(_contentTextField.mas_right).offset(-SCREEN_LayoutScaleBaseOnIPHEN6(5)); // make.center.equalTo(_contentTextField); }]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(notCloseCor) name:@"closeVideoCamerThird" object:nil]; // Do any additional setup after loading the view. } -(void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; // _cityName = [AppDelegate appDelegate].appDelegatePlatformUserStructure.userCity; //// 1. // _locationManager = [[CLLocationManager alloc] init]; //// 2. // _locationManager.delegate = self; // //3. // [_locationManager setDesiredAccuracy:kCLLocationAccuracyBest]; // //4.4.14.2 // if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8) { // [_locationManager requestWhenInUseAuthorization];//4.1 //// [_locationManager requestAlwaysAuthorization];//4.2 // } //// 5.0 // [_locationManager startUpdatingLocation]; } //#pragma mark - CLLocationManagerDelegate - //-(void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations { // CLLocation *newLocation = locations[0]; // // CLLocationCoordinate2D oldCoordinate = newLocation.coordinate; // // NSLog(@"%f,%f",oldCoordinate.longitude,oldCoordinate.latitude); // // // // [manager stopUpdatingLocation]; // // // // CLGeocoder *geocoder = [[CLGeocoder alloc]init]; // // [geocoder reverseGeocodeLocation:newLocation completionHandler:^(NSArray<CLPlacemark *> * _Nullable placemarks, NSError * _Nullable error) { // // // // for (CLPlacemark *place in placemarks) { // // NSLog(@"name,%@",place.name); // // // NSLog(@"thoroughfare,%@",place.thoroughfare); // // // NSLog(@"subThoroughfare,%@",place.subThoroughfare); // // // NSLog(@"locality,%@",place.locality); // // _cityName = place.locality; // if ([_cityName hasSuffix:@""]) { // _cityName = [_cityName stringByReplacingOccurrencesOfString:@"" withString:@""]; // NSLog(@"NewCity:%@",_cityName); // } // // // NSLog(@"subLocality,%@",place.subLocality); // // // NSLog(@"country,%@",place.country); // // // // } // // }]; // //} -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{ [_contentTextField resignFirstResponder]; } #pragma mark - keyboard events - /// - (void) keyboardWillShow:(NSNotification *)notification { // if (SCREEN_MODE_IPHONE5) { // // // CGFloat kbHeight = [[notification.userInfo objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue].size.height; // // //inputTextView panel(INTERVAL_KEYBOARD) // // CGFloat offset = (panelInputTextView.frame.origin.y+panelInputTextView.frame.size.height+INTERVAL_KEYBOARD) - (self.frame.size.height - kbHeight); // CGFloat offset = kbHeight - (ScreenHeight - _fourShareBgView.frame.origin.y); // // // // double duration = [[notification.userInfo objectForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue]; // // // // if(offset > 0) { // [UIView animateWithDuration:duration animations:^{ // self.frame = CGRectMake(0.0f, -offset, self.frame.size.width, self.frame.size.height); // }]; // } // // } } /// - (void) keyboardWillHide:(NSNotification *)notify { // // // double duration = [[notify.userInfo objectForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue]; // // // // [UIView animateWithDuration:duration animations:^{ // self.frame = CGRectMake(0, 0, self.frame.size.width, self.frame.size.height); // }]; } #pragma mark textViewDelegate -(BOOL)textViewShouldBeginEditing:(UITextView *)textView { if (textView.tag == 0) { textView.text = @""; textView.textColor = [UIColor blackColor]; textView.tag = 1; } return YES; } -(void)textViewDidChange:(UITextView *)textView { if ([textView.text length] == 0) { // textView.text = @"..."; // textView.textColor = [UIColor lightGrayColor]; // textView.tag = 0 ; } NSString *lengthString; if ([textView.text length] > kSignatureContextLengths) { lengthString = [[NSString alloc] initWithFormat:@":%lu/%d",(unsigned long)[textView.text length],kSignatureContextLengths]; _limitLabel.textColor = [UIColor redColor]; isExceed_cai = YES; } else { lengthString = [[NSString alloc] initWithFormat:@"%lu/%d",(unsigned long)[textView.text length],kSignatureContextLengths]; _limitLabel.textColor = [UIColor blackColor]; isExceed_cai = NO; } _limitLabel.text = lengthString; } -(BOOL)textViewShouldEndEditing:(UITextView *)textView { if ([textView.text length] == 0) { textView.text = @"(20)"; textView.textColor = [UIColor lightGrayColor]; textView.tag = 0 ; } return YES; } // - (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text { if ([text isEqualToString:@"\n"]) { [_contentTextField resignFirstResponder]; return NO; } return YES; } - (IBAction)publishingDynamic:(id)sender { HUD = [MBProgressHUD showHUDAddedTo:self.view animated:YES ]; HUD.labelText = @""; [HUD hide:YES afterDelay:2.0]; dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ [self.navigationController dismissViewControllerAnimated:YES completion:nil]; }); // // if ([_contentTextField.text length] > kSignatureContextLengths) { // return; // } // HUD = [MBProgressHUD showHUDAddedTo:self.view animated:YES ]; // HUD.labelText = @""; } -(void)backToEditVideoCor { [[NSNotificationCenter defaultCenter] removeObserver:self]; [self.navigationController popViewControllerAnimated:YES]; } -(void)saveVideoToLoacl { HUD = [MBProgressHUD showHUDAddedTo:self.view animated:YES]; HUD.labelText = @""; [HUD hide:YES afterDelay:1.0]; UISaveVideoAtPathToSavedPhotosAlbum([[_videoURL absoluteString ] stringByReplacingOccurrencesOfString:@"file://" withString:@""], nil, nil, nil); } /** @param sender Btn */ - (void)clickWXFriendSShareBtn:(UIButton *)sender { if (!sender.selected) { sender.selected = YES; _rightWXBtn.selected = NO; }else { sender.selected = NO; } } /** @param sender Btn */ - (void)clickWeChatShareBtn:(UIButton *)sender { if (!sender.selected) { sender.selected = YES; _lefthWXBtn.selected = NO; }else { sender.selected = NO; } } -(void)notCloseCor { [[UIApplication sharedApplication] setStatusBarHidden:NO]; [[NSNotificationCenter defaultCenter] removeObserver:self]; // [[NSNotificationCenter defaultCenter] postNotificationName:kTabBarHiddenNONotification object:self]; [self.navigationController popToRootViewControllerAnimated:NO]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } - (BOOL)prefersStatusBarHidden { return YES; } #pragma mark URL -(UIImage *)getImage:(NSString *)videoURL { AVURLAsset *asset = [[AVURLAsset alloc] initWithURL:[NSURL fileURLWithPath:videoURL] options:nil]; AVAssetImageGenerator *gen = [[AVAssetImageGenerator alloc] initWithAsset:asset]; gen.appliesPreferredTrackTransform = YES; CMTime time = CMTimeMakeWithSeconds(0.0, 600); NSError *error = nil; CMTime actualTime; CGImageRef image = [gen copyCGImageAtTime:time actualTime:&actualTime error:&error]; UIImage *thumb = [[UIImage alloc] initWithCGImage:image]; CGImageRelease(image); return thumb; } -(void)dealloc { NSLog(@"%@",self.class); } @end ```
/content/code_sandbox/PlayerDemo/CustomVideoCamera/EditingPublishingDynamicViewController.mm
xml
2016-02-02T02:51:55
2024-08-09T08:55:27
WMPlayer
zhengwenming/WMPlayer
3,272
5,061
```xml // // MusicItemCollectionViewCell.m // addproject // // Created by on 17/3/3. // #import "MusicItemCollectionViewCell.h" #import "UIView+Tools.h" #import "Masonry.h" @implementation MusicItemCollectionViewCell -(instancetype)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { // self.backgroundColor = [UIColor colorWithRed:arc4random_uniform(255)/255.0 green:arc4random_uniform(255)/255.0 blue:arc4random_uniform(255)/255.0 alpha:1]; // 83, 115 _iconImgView = [[UIImageView alloc] init]; [self addSubview:_iconImgView]; [_iconImgView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(self).offset(10); make.width.height.equalTo(@(70)); make.centerX.equalTo(self); }]; [_iconImgView makeCornerRadius:35 borderColor:nil borderWidth:0]; _iconImgView.layer.masksToBounds = YES; _nameLabel = [[UILabel alloc] init]; _nameLabel.textColor = [UIColor grayColor]; [_nameLabel setFont:[UIFont systemFontOfSize:11]]; _nameLabel.textAlignment = NSTextAlignmentCenter; [self addSubview:_nameLabel]; [_nameLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.centerX.equalTo(self); make.top.equalTo(_iconImgView.mas_bottom).offset(5); make.left.right.equalTo(_iconImgView); }]; _CheckMarkImgView = [[UIImageView alloc] init]; _CheckMarkImgView.image = [UIImage imageNamed:@"EditVideoCheckmark"]; [self addSubview:_CheckMarkImgView]; _CheckMarkImgView.frame = CGRectMake(0, 0, 83, 115); _CheckMarkImgView.contentMode = UIViewContentModeScaleToFill; _CheckMarkImgView.hidden = YES; } return self; } @end ```
/content/code_sandbox/PlayerDemo/CustomVideoCamera/MusicItemCollectionViewCell.mm
xml
2016-02-02T02:51:55
2024-08-09T08:55:27
WMPlayer
zhengwenming/WMPlayer
3,272
414
```objective-c // // MusicItemCollectionViewCell.h // addproject // // Created by on 17/3/3. // #import <UIKit/UIKit.h> @interface MusicItemCollectionViewCell : UICollectionViewCell @property (nonatomic,strong) UIImageView* iconImgView; @property (nonatomic,strong) UILabel* nameLabel; @property (nonatomic,strong) UIImageView* CheckMarkImgView; @end ```
/content/code_sandbox/PlayerDemo/CustomVideoCamera/MusicItemCollectionViewCell.h
objective-c
2016-02-02T02:51:55
2024-08-09T08:55:27
WMPlayer
zhengwenming/WMPlayer
3,272
78
```objective-c // // EditingPublishingDynamicViewController.h // iShow // // Created by on 17/3/18. // // #import <UIKit/UIKit.h> #import "BaseViewController.h" @interface EditingPublishingDynamicViewController : BaseViewController @property(nonatomic,retain) NSURL * videoURL; @end ```
/content/code_sandbox/PlayerDemo/CustomVideoCamera/EditingPublishingDynamicViewController.h
objective-c
2016-02-02T02:51:55
2024-08-09T08:55:27
WMPlayer
zhengwenming/WMPlayer
3,272
65
```objective-c // // UIView+Tools.m // VideoRecord // // Created by guimingsu on 14-8-25. // #import "UIView+Tools.h" @implementation UIView (Tools) -(void)makeCornerRadius:(float)radius borderColor:(UIColor *)bColor borderWidth:(float)bWidth{ self.layer.borderWidth = bWidth; if (bColor != nil) { self.layer.borderColor = bColor.CGColor; } self.layer.cornerRadius = radius; self.layer.masksToBounds = YES; } @end ```
/content/code_sandbox/PlayerDemo/CustomVideoCamera/UIView+Tools.m
objective-c
2016-02-02T02:51:55
2024-08-09T08:55:27
WMPlayer
zhengwenming/WMPlayer
3,272
114
```xml // // SDAVAssetExportSession.m // // This file is part of the SDAVAssetExportSession package. // // // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. // #import "SDAVAssetExportSession.h" @interface SDAVAssetExportSession () @property (nonatomic, assign, readwrite) float progress; @property (nonatomic, strong) AVAssetReader *reader; @property (nonatomic, strong) AVAssetReaderVideoCompositionOutput *videoOutput; @property (nonatomic, strong) AVAssetReaderAudioMixOutput *audioOutput; @property (nonatomic, strong) AVAssetWriter *writer; @property (nonatomic, strong) AVAssetWriterInput *videoInput; @property (nonatomic, strong) AVAssetWriterInputPixelBufferAdaptor *videoPixelBufferAdaptor; @property (nonatomic, strong) AVAssetWriterInput *audioInput; @property (nonatomic, strong) dispatch_queue_t inputQueue; @property (nonatomic, strong) void (^completionHandler)(); @end @implementation SDAVAssetExportSession { NSError *_error; NSTimeInterval duration; CMTime lastSamplePresentationTime; } + (id)exportSessionWithAsset:(AVAsset *)asset { return [SDAVAssetExportSession.alloc initWithAsset:asset]; } - (id)initWithAsset:(AVAsset *)asset { if ((self = [super init])) { _asset = asset; _timeRange = CMTimeRangeMake(kCMTimeZero, kCMTimePositiveInfinity); } return self; } - (void)exportAsynchronouslyWithCompletionHandler:(void (^)())handler { NSParameterAssert(handler != nil); [self cancelExport]; self.completionHandler = handler; if (!self.outputURL) { _error = [NSError errorWithDomain:AVFoundationErrorDomain code:AVErrorExportFailed userInfo:@ { NSLocalizedDescriptionKey: @"Output URL not set" }]; handler(); return; } NSError *readerError; self.reader = [AVAssetReader.alloc initWithAsset:self.asset error:&readerError]; if (readerError) { _error = readerError; handler(); return; } NSError *writerError; self.writer = [AVAssetWriter assetWriterWithURL:self.outputURL fileType:self.outputFileType error:&writerError]; if (writerError) { _error = writerError; handler(); return; } self.reader.timeRange = self.timeRange; self.writer.shouldOptimizeForNetworkUse = self.shouldOptimizeForNetworkUse; self.writer.metadata = self.metadata; NSArray *videoTracks = [self.asset tracksWithMediaType:AVMediaTypeVideo]; if (CMTIME_IS_VALID(self.timeRange.duration) && !CMTIME_IS_POSITIVE_INFINITY(self.timeRange.duration)) { duration = CMTimeGetSeconds(self.timeRange.duration); } else { duration = CMTimeGetSeconds(self.asset.duration); } // // Video output // if (videoTracks.count > 0) { self.videoOutput = [AVAssetReaderVideoCompositionOutput assetReaderVideoCompositionOutputWithVideoTracks:videoTracks videoSettings:self.videoInputSettings]; self.videoOutput.alwaysCopiesSampleData = NO; if (self.videoComposition) { self.videoOutput.videoComposition = self.videoComposition; } else { self.videoOutput.videoComposition = [self buildDefaultVideoComposition]; } if ([self.reader canAddOutput:self.videoOutput]) { [self.reader addOutput:self.videoOutput]; } // // Video input // self.videoInput = [AVAssetWriterInput assetWriterInputWithMediaType:AVMediaTypeVideo outputSettings:self.videoSettings]; self.videoInput.expectsMediaDataInRealTime = NO; if ([self.writer canAddInput:self.videoInput]) { [self.writer addInput:self.videoInput]; } NSDictionary *pixelBufferAttributes = @ { (id)kCVPixelBufferPixelFormatTypeKey: @(kCVPixelFormatType_32BGRA), (id)kCVPixelBufferWidthKey: @(self.videoOutput.videoComposition.renderSize.width), (id)kCVPixelBufferHeightKey: @(self.videoOutput.videoComposition.renderSize.height), @"IOSurfaceOpenGLESTextureCompatibility": @YES, @"IOSurfaceOpenGLESFBOCompatibility": @YES, }; self.videoPixelBufferAdaptor = [AVAssetWriterInputPixelBufferAdaptor assetWriterInputPixelBufferAdaptorWithAssetWriterInput:self.videoInput sourcePixelBufferAttributes:pixelBufferAttributes]; } // //Audio output // NSArray *audioTracks = [self.asset tracksWithMediaType:AVMediaTypeAudio]; if (audioTracks.count > 0) { self.audioOutput = [AVAssetReaderAudioMixOutput assetReaderAudioMixOutputWithAudioTracks:audioTracks audioSettings:nil]; self.audioOutput.alwaysCopiesSampleData = NO; self.audioOutput.audioMix = self.audioMix; if ([self.reader canAddOutput:self.audioOutput]) { [self.reader addOutput:self.audioOutput]; } } else { // Just in case this gets reused self.audioOutput = nil; } // // Audio input // if (self.audioOutput) { self.audioInput = [AVAssetWriterInput assetWriterInputWithMediaType:AVMediaTypeAudio outputSettings:self.audioSettings]; self.audioInput.expectsMediaDataInRealTime = NO; if ([self.writer canAddInput:self.audioInput]) { [self.writer addInput:self.audioInput]; } } [self.writer startWriting]; [self.reader startReading]; [self.writer startSessionAtSourceTime:self.timeRange.start]; __block BOOL videoCompleted = NO; __block BOOL audioCompleted = NO; __weak typeof(self) wself = self; self.inputQueue = dispatch_queue_create("VideoEncoderInputQueue", DISPATCH_QUEUE_SERIAL); if (videoTracks.count > 0) { [self.videoInput requestMediaDataWhenReadyOnQueue:self.inputQueue usingBlock:^ { if (![wself encodeReadySamplesFromOutput:wself.videoOutput toInput:wself.videoInput]) { @synchronized(wself) { videoCompleted = YES; if (audioCompleted) { [wself finish]; } } } }]; } else { videoCompleted = YES; } if (!self.audioOutput) { audioCompleted = YES; } else { [self.audioInput requestMediaDataWhenReadyOnQueue:self.inputQueue usingBlock:^ { if (![wself encodeReadySamplesFromOutput:wself.audioOutput toInput:wself.audioInput]) { @synchronized(wself) { audioCompleted = YES; if (videoCompleted) { [wself finish]; } } } }]; } } - (BOOL)encodeReadySamplesFromOutput:(AVAssetReaderOutput *)output toInput:(AVAssetWriterInput *)input { while (input.isReadyForMoreMediaData) { CMSampleBufferRef sampleBuffer = [output copyNextSampleBuffer]; if (sampleBuffer) { BOOL handled = NO; BOOL error = NO; if (self.reader.status != AVAssetReaderStatusReading || self.writer.status != AVAssetWriterStatusWriting) { handled = YES; error = YES; } if (!handled && self.videoOutput == output) { // update the video progress lastSamplePresentationTime = CMSampleBufferGetPresentationTimeStamp(sampleBuffer); lastSamplePresentationTime = CMTimeSubtract(lastSamplePresentationTime, self.timeRange.start); self.progress = duration == 0 ? 1 : CMTimeGetSeconds(lastSamplePresentationTime) / duration; if ([self.delegate respondsToSelector:@selector(exportSession:renderFrame:withPresentationTime:toBuffer:)]) { CVPixelBufferRef pixelBuffer = (CVPixelBufferRef)CMSampleBufferGetImageBuffer(sampleBuffer); CVPixelBufferRef renderBuffer = NULL; CVPixelBufferPoolCreatePixelBuffer(NULL, self.videoPixelBufferAdaptor.pixelBufferPool, &renderBuffer); [self.delegate exportSession:self renderFrame:pixelBuffer withPresentationTime:lastSamplePresentationTime toBuffer:renderBuffer]; if (![self.videoPixelBufferAdaptor appendPixelBuffer:renderBuffer withPresentationTime:lastSamplePresentationTime]) { error = YES; } CVPixelBufferRelease(renderBuffer); handled = YES; } } if (!handled && ![input appendSampleBuffer:sampleBuffer]) { error = YES; } CFRelease(sampleBuffer); if (error) { return NO; } } else { [input markAsFinished]; return NO; } } return YES; } - (AVMutableVideoComposition *)buildDefaultVideoComposition { AVMutableVideoComposition *videoComposition = [AVMutableVideoComposition videoComposition]; AVAssetTrack *videoTrack = [[self.asset tracksWithMediaType:AVMediaTypeVideo] objectAtIndex:0]; // get the frame rate from videoSettings, if not set then try to get it from the video track, // if not set (mainly when asset is AVComposition) then use the default frame rate of 30 float trackFrameRate = 0; if (self.videoSettings) { NSDictionary *videoCompressionProperties = [self.videoSettings objectForKey:AVVideoCompressionPropertiesKey]; if (videoCompressionProperties) { NSNumber *frameRate = [videoCompressionProperties objectForKey:AVVideoAverageNonDroppableFrameRateKey]; if (frameRate) { trackFrameRate = frameRate.floatValue; } } } else { trackFrameRate = [videoTrack nominalFrameRate]; } if (trackFrameRate == 0) { trackFrameRate = 30; } videoComposition.frameDuration = CMTimeMake(1, trackFrameRate); CGSize targetSize = CGSizeMake([self.videoSettings[AVVideoWidthKey] floatValue], [self.videoSettings[AVVideoHeightKey] floatValue]); CGSize naturalSize = [videoTrack naturalSize]; CGAffineTransform transform = videoTrack.preferredTransform; CGFloat videoAngleInDegree = atan2(transform.b, transform.a) * 180 / M_PI; if (videoAngleInDegree == 90 || videoAngleInDegree == -90) { CGFloat width = naturalSize.width; naturalSize.width = naturalSize.height; naturalSize.height = width; } videoComposition.renderSize = naturalSize; // center inside { float ratio; float xratio = targetSize.width / naturalSize.width; float yratio = targetSize.height / naturalSize.height; ratio = MIN(xratio, yratio); float postWidth = naturalSize.width * ratio; float postHeight = naturalSize.height * ratio; float transx = (targetSize.width - postWidth) / 2; float transy = (targetSize.height - postHeight) / 2; CGAffineTransform matrix = CGAffineTransformMakeTranslation(transx / xratio, transy / yratio); matrix = CGAffineTransformScale(matrix, ratio / xratio, ratio / yratio); transform = CGAffineTransformConcat(transform, matrix); } // Make a "pass through video track" video composition. AVMutableVideoCompositionInstruction *passThroughInstruction = [AVMutableVideoCompositionInstruction videoCompositionInstruction]; passThroughInstruction.timeRange = CMTimeRangeMake(kCMTimeZero, self.asset.duration); AVMutableVideoCompositionLayerInstruction *passThroughLayer = [AVMutableVideoCompositionLayerInstruction videoCompositionLayerInstructionWithAssetTrack:videoTrack]; [passThroughLayer setTransform:transform atTime:kCMTimeZero]; passThroughInstruction.layerInstructions = @[passThroughLayer]; videoComposition.instructions = @[passThroughInstruction]; return videoComposition; } - (void)finish { // Synchronized block to ensure we never cancel the writer before calling finishWritingWithCompletionHandler if (self.reader.status == AVAssetReaderStatusCancelled || self.writer.status == AVAssetWriterStatusCancelled) { return; } if (self.writer.status == AVAssetWriterStatusFailed) { [self complete]; } else if (self.reader.status == AVAssetReaderStatusFailed) { [self.writer cancelWriting]; [self complete]; } else { [self.writer finishWritingWithCompletionHandler:^ { [self complete]; }]; } } - (void)complete { if (self.writer.status == AVAssetWriterStatusFailed || self.writer.status == AVAssetWriterStatusCancelled) { [NSFileManager.defaultManager removeItemAtURL:self.outputURL error:nil]; } if (self.completionHandler) { self.completionHandler(); self.completionHandler = nil; } } - (NSError *)error { if (_error) { return _error; } else { return self.writer.error ? : self.reader.error; } } - (AVAssetExportSessionStatus)status { switch (self.writer.status) { default: case AVAssetWriterStatusUnknown: return AVAssetExportSessionStatusUnknown; case AVAssetWriterStatusWriting: return AVAssetExportSessionStatusExporting; case AVAssetWriterStatusFailed: return AVAssetExportSessionStatusFailed; case AVAssetWriterStatusCompleted: return AVAssetExportSessionStatusCompleted; case AVAssetWriterStatusCancelled: return AVAssetExportSessionStatusCancelled; } } - (void)cancelExport { if (self.inputQueue) { dispatch_async(self.inputQueue, ^ { [self.writer cancelWriting]; [self.reader cancelReading]; [self complete]; [self reset]; }); } } - (void)reset { _error = nil; self.progress = 0; self.reader = nil; self.videoOutput = nil; self.audioOutput = nil; self.writer = nil; self.videoInput = nil; self.videoPixelBufferAdaptor = nil; self.audioInput = nil; self.inputQueue = nil; self.completionHandler = nil; } @end ```
/content/code_sandbox/PlayerDemo/CustomVideoCamera/SDAVAssetExportSession.mm
xml
2016-02-02T02:51:55
2024-08-09T08:55:27
WMPlayer
zhengwenming/WMPlayer
3,272
3,090
```objective-c // // EditVideoViewController.h // iShow // // Created by on 17/3/8. // // #import <UIKit/UIKit.h> #import "BaseViewController.h" @interface EditVideoViewController : BaseViewController @property(nonatomic,retain) NSURL * videoURL; @property (nonatomic , strong) NSNumber* width; @property (nonatomic , strong) NSNumber* hight; @property (nonatomic , strong) NSNumber* bit; @property (nonatomic , strong) NSNumber* frameRate; @end ```
/content/code_sandbox/PlayerDemo/CustomVideoCamera/EditVideoViewController.h
objective-c
2016-02-02T02:51:55
2024-08-09T08:55:27
WMPlayer
zhengwenming/WMPlayer
3,272
103
```objective-c // // VideoCameraView.m // addproject // // Created by on 17/3/3. // #import "VideoCameraView.h" #import "GPUImageMovieWriter.h" #import "GPUImageBeautifyFilter.h" #import "LFGPUImageEmptyFilter.h" #import <AVFoundation/AVFoundation.h> #import <AssetsLibrary/AssetsLibrary.h> #import "EditVideoViewController.h" #import "MBProgressHUD.h" #import "UIView+Tools.h" #import "SDAVAssetExportSession.h" #import "TZImagePickerController.h" #import "TZImageManager.h" #import "EditingPublishingDynamicViewController.h" #import <Photos/Photos.h> #import <Photos/PHImageManager.h> #define VIDEO_FOLDER @"videoFolder" #define UIColorFromRGB(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0] #define SCREEN_WIDTH [UIScreen mainScreen].bounds.size.width #define SCREEN_HEIGHT [UIScreen mainScreen].bounds.size.height #define TIMER_INTERVAL 0.05 typedef NS_ENUM(NSInteger, CameraManagerDevicePosition) { CameraManagerDevicePositionBack, CameraManagerDevicePositionFront, }; @interface VideoCameraView ()<TZImagePickerControllerDelegate> { float preLayerWidth;// float preLayerHeight;// float preLayerHWRate; // NSMutableArray* urlArray; float totalTime; // 10 float currentTime; // float lastTime; // UIView* progressPreView; // float progressStep; // MBProgressHUD* HUD; } @property (nonatomic ,strong) UIButton *camerafilterChangeButton; @property (nonatomic ,strong) UIButton *cameraPositionChangeButton; @property (nonatomic, assign) CameraManagerDevicePosition position; @property (nonatomic, strong) UIButton *photoCaptureButton; @property (nonatomic, strong) UIButton *cameraChangeButton; @property (nonatomic, strong) UIButton *dleButton; @property (nonatomic, strong) UIButton *inputLocalVieoBtn; @property (nonatomic, strong) NSMutableArray *lastAry; @property (nonatomic, strong) UIView* btView; @property (nonatomic, assign) BOOL isRecoding; @end @implementation VideoCameraView - (instancetype) initWithFrame:(CGRect)frame{ if (!(self = [super initWithFrame:frame])) { return nil; } if (totalTime==0) { totalTime =10; } [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(notCloseCor) name:@"closeVideoCamerOne" object:nil]; lastTime = 0; progressStep = SCREEN_WIDTH*TIMER_INTERVAL/totalTime; preLayerWidth = SCREEN_WIDTH; preLayerHeight = SCREEN_HEIGHT; preLayerHWRate =preLayerHeight/preLayerWidth; _lastAry = [[NSMutableArray alloc] init]; urlArray = [[NSMutableArray alloc]init]; [self createVideoFolderIfNotExist]; mainScreenFrame = frame; videoCamera = [[GPUImageVideoCamera alloc] initWithSessionPreset:AVCaptureSessionPreset1280x720 cameraPosition:AVCaptureDevicePositionBack]; if ([videoCamera.inputCamera lockForConfiguration:nil]) { // if ([videoCamera.inputCamera isFocusModeSupported:AVCaptureFocusModeContinuousAutoFocus]) { [videoCamera.inputCamera setFocusMode:AVCaptureFocusModeContinuousAutoFocus]; } // if ([videoCamera.inputCamera isExposureModeSupported:AVCaptureExposureModeContinuousAutoExposure]) { [videoCamera.inputCamera setExposureMode:AVCaptureExposureModeContinuousAutoExposure]; } // if ([videoCamera.inputCamera isWhiteBalanceModeSupported:AVCaptureWhiteBalanceModeContinuousAutoWhiteBalance]) { [videoCamera.inputCamera setWhiteBalanceMode:AVCaptureWhiteBalanceModeContinuousAutoWhiteBalance]; } [videoCamera.inputCamera unlockForConfiguration]; } _position = CameraManagerDevicePositionBack; // videoCamera.frameRate = 10; videoCamera.outputImageOrientation = UIInterfaceOrientationPortrait; [videoCamera addAudioInputsAndOutputs]; videoCamera.horizontallyMirrorFrontFacingCamera = YES; videoCamera.horizontallyMirrorRearFacingCamera = NO; filter = [[LFGPUImageEmptyFilter alloc] init]; filteredVideoView = [[GPUImageView alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; [videoCamera addTarget:filter]; [filter addTarget:filteredVideoView]; [videoCamera startCameraCapture]; [self addSomeView]; UITapGestureRecognizer *singleFingerOne = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(cameraViewTapAction:)]; singleFingerOne.numberOfTouchesRequired = 1; // singleFingerOne.numberOfTapsRequired = 1; //tap [filteredVideoView addGestureRecognizer:singleFingerOne]; [self addSubview:filteredVideoView]; // [videoCamera removeAllTargets]; // filter = [[GPUImageBeautifyFilter alloc] init]; // [videoCamera addTarget:beautifyFilter]; // [beautifyFilter addTarget:filteredVideoView]; return self; } - (void) addSomeView{ // 253 91 73 timeLabel = [[UILabel alloc] initWithFrame:CGRectMake(20.0, 27.0, 80, 26.0)]; timeLabel.font = [UIFont systemFontOfSize:13.0f]; timeLabel.text = @" 00:00"; timeLabel.textAlignment = NSTextAlignmentCenter; timeLabel.backgroundColor = [UIColor colorWithRed:253/256.0 green:91/256.0 blue:73/256.0 alpha:1]; timeLabel.textColor = [UIColor whiteColor]; [filteredVideoView addSubview:timeLabel]; // [[AppDelegate appDelegate].cmImageSize setLabelsRounded:timeLabel cornerRadiusValue:2 borderWidthValue:0 borderColorWidthValue:[UIColor clearColor]]; timeLabel.hidden = YES; _btView = [[UIView alloc]initWithFrame:CGRectMake(SCREEN_WIDTH/2 - 36.5, SCREEN_HEIGHT - 125, 73, 73)]; [_btView makeCornerRadius:36.5 borderColor:nil borderWidth:0]; _btView.backgroundColor = [UIColor colorWithRed:(float)0xfe/256.0 green:(float)0x65/256.0 blue:(float)0x53/256.0 alpha:1]; [filteredVideoView addSubview:_btView]; _photoCaptureButton = [[UIButton alloc] initWithFrame:CGRectMake(SCREEN_WIDTH/2 - 31.5, SCREEN_HEIGHT- 120, 63, 63)]; _photoCaptureButton.backgroundColor = [UIColor colorWithRed:(float)0xfe/256.0 green:(float)0x65/256.0 blue:(float)0x53/256.0 alpha:1]; [_photoCaptureButton addTarget:self action:@selector(startRecording:) forControlEvents:UIControlEventTouchUpInside]; [_photoCaptureButton makeCornerRadius:31.5 borderColor:[UIColor blackColor] borderWidth:1.5]; [filteredVideoView addSubview:_photoCaptureButton]; _camerafilterChangeButton = [[UIButton alloc] init]; _camerafilterChangeButton.frame = CGRectMake(SCREEN_WIDTH - 160, 25, 30.0, 30.0); UIImage* img = [UIImage imageNamed:@"beautyOFF"]; [_camerafilterChangeButton setImage:img forState:UIControlStateNormal]; [_camerafilterChangeButton setImage:[UIImage imageNamed:@"beautyON"] forState:UIControlStateSelected]; [_camerafilterChangeButton addTarget:self action:@selector(changebeautifyFilterBtn:) forControlEvents:UIControlEventTouchUpInside]; [filteredVideoView addSubview:_camerafilterChangeButton]; UIButton* backBtn = [[UIButton alloc] initWithFrame:CGRectMake(SCREEN_WIDTH - 60, 25, 30, 30)]; [backBtn setImage:[UIImage imageNamed:@"BackToHome"] forState:UIControlStateNormal]; [backBtn addTarget:self action:@selector(clickBackToHome) forControlEvents:UIControlEventTouchUpInside]; [filteredVideoView addSubview:backBtn]; _cameraPositionChangeButton = [[UIButton alloc] initWithFrame:CGRectMake(SCREEN_WIDTH - 110, 25, 30, 30)]; UIImage* img2 = [UIImage imageNamed:@"cammera"]; [_cameraPositionChangeButton setImage:img2 forState:UIControlStateNormal]; [_cameraPositionChangeButton addTarget:self action:@selector(changeCameraPositionBtn:) forControlEvents:UIControlEventTouchUpInside]; [filteredVideoView addSubview:_cameraPositionChangeButton]; _cameraChangeButton = [[UIButton alloc] init]; _cameraChangeButton.hidden = YES; _cameraChangeButton.frame = CGRectMake(SCREEN_WIDTH - 100 , SCREEN_HEIGHT - 105.0, 52.6, 50.0); UIImage* img3 = [UIImage imageNamed:@"complete"]; [_cameraChangeButton setImage:img3 forState:UIControlStateNormal]; [_cameraChangeButton addTarget:self action:@selector(stopRecording:) forControlEvents:UIControlEventTouchUpInside]; [filteredVideoView addSubview:_cameraChangeButton]; _dleButton = [[UIButton alloc] init]; _dleButton.hidden = YES; _dleButton.frame = CGRectMake( 50 , SCREEN_HEIGHT - 105.0, 50, 50.0); UIImage* img4 = [UIImage imageNamed:@"del"]; [_dleButton setImage:img4 forState:UIControlStateNormal]; [_dleButton addTarget:self action:@selector(clickDleBtn:) forControlEvents:UIControlEventTouchUpInside]; [filteredVideoView addSubview:_dleButton]; _inputLocalVieoBtn = [[UIButton alloc] init]; _inputLocalVieoBtn.frame = CGRectMake( 50 , SCREEN_HEIGHT - 105.0, 50, 50.0); UIImage* img5 = [UIImage imageNamed:@"record_ico_input_1"]; [_inputLocalVieoBtn setImage:img5 forState:UIControlStateNormal]; [_inputLocalVieoBtn addTarget:self action:@selector(clickInputBtn:) forControlEvents:UIControlEventTouchUpInside]; [filteredVideoView addSubview:_inputLocalVieoBtn]; progressPreView = [[UIView alloc]initWithFrame:CGRectMake(0, SCREEN_HEIGHT -4 , 0, 4)]; progressPreView.backgroundColor = UIColorFromRGB(0xffc738); [progressPreView makeCornerRadius:2 borderColor:nil borderWidth:0]; [filteredVideoView addSubview:progressPreView]; } - (IBAction)startRecording:(UIButton*)sender { _inputLocalVieoBtn.hidden = YES; if (!sender.selected) { lastTime = currentTime; [_lastAry addObject:[NSString stringWithFormat:@"%f",lastTime]]; _camerafilterChangeButton.hidden = YES; _cameraPositionChangeButton.hidden = YES; timeLabel.hidden = NO; _dleButton.hidden = YES; sender.selected = YES; pathToMovie = [NSHomeDirectory() stringByAppendingPathComponent:[NSString stringWithFormat:@"tmp/Movie%lu.mov",(unsigned long)urlArray.count]]; unlink([pathToMovie UTF8String]); // If a file already exists, AVAssetWriter won't let you record new frames, so delete the old movie NSURL *movieURL = [NSURL fileURLWithPath:pathToMovie]; movieWriter = [[GPUImageMovieWriter alloc] initWithMovieURL:movieURL size:CGSizeMake(720.0, 1280.0)]; movieWriter.encodingLiveVideo = YES; movieWriter.shouldPassthroughAudio = YES; [filter addTarget:movieWriter]; videoCamera.audioEncodingTarget = movieWriter; [movieWriter startRecording]; _isRecoding = YES; _photoCaptureButton.backgroundColor = [UIColor colorWithRed:(float)0xfd/256.0 green:(float)0xd8/256.0 blue:(float)0x54/256.0 alpha:1]; _btView.backgroundColor = [UIColor colorWithRed:(float)0xfd/256.0 green:(float)0xd8/256.0 blue:(float)0x54/256.0 alpha:1]; fromdate = [NSDate date]; myTimer = [NSTimer scheduledTimerWithTimeInterval:TIMER_INTERVAL target:self selector:@selector(updateTimer:) userInfo:nil repeats:YES]; }else{ _camerafilterChangeButton.hidden = NO; _cameraPositionChangeButton.hidden = NO; sender.selected = NO; videoCamera.audioEncodingTarget = nil; NSLog(@"Path %@",pathToMovie); if (pathToMovie == nil) { return; } _btView.backgroundColor = [UIColor colorWithRed:(float)0xfe/256.0 green:(float)0x65/256.0 blue:(float)0x53/256.0 alpha:1]; _photoCaptureButton.backgroundColor = [UIColor colorWithRed:(float)0xfe/256.0 green:(float)0x65/256.0 blue:(float)0x53/256.0 alpha:1]; // UISaveVideoAtPathToSavedPhotosAlbum(pathToMovie, nil, nil, nil); if (_isRecoding) { [movieWriter finishRecording]; [filter removeTarget:movieWriter]; [urlArray addObject:[NSURL URLWithString:[NSString stringWithFormat:@"file://%@",pathToMovie]]]; _isRecoding = NO; } [myTimer invalidate]; myTimer = nil; if (urlArray.count) { _dleButton.hidden = NO; } } } - (IBAction)stopRecording:(id)sender { videoCamera.audioEncodingTarget = nil; NSLog(@"Path %@",pathToMovie); if (pathToMovie == nil) { return; } // UISaveVideoAtPathToSavedPhotosAlbum(pathToMovie, nil, nil, nil); if (_isRecoding) { [movieWriter finishRecording]; [filter removeTarget:movieWriter]; _isRecoding = NO; } timeLabel.text = @" 00:00"; [myTimer invalidate]; myTimer = nil; HUD = [MBProgressHUD showHUDAddedTo:self animated:YES]; HUD.labelText = @"..."; if (_photoCaptureButton.selected) { [urlArray addObject:[NSURL URLWithString:[NSString stringWithFormat:@"file://%@",pathToMovie]]]; } // [urlArray addObject:[NSURL URLWithString:[NSString stringWithFormat:@"file://%@",pathToMovie]]]; // [self mergeAndExportVideosAtFileURLs:urlArray]; NSString *path = [self getVideoMergeFilePathString]; dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ [self mergeAndExportVideos:urlArray withOutPath:path]; [urlArray removeAllObjects]; [_lastAry removeAllObjects]; currentTime = 0; lastTime = 0; _dleButton.hidden = YES; [progressPreView setFrame:CGRectMake(0, SCREEN_HEIGHT - 4, 0, 4)]; _btView.backgroundColor = [UIColor colorWithRed:250/256.0 green:211/256.0 blue:75/256.0 alpha:1]; _photoCaptureButton.backgroundColor = [UIColor colorWithRed:250/256.0 green:211/256.0 blue:75/256.0 alpha:1]; _photoCaptureButton.selected = NO; _cameraChangeButton.hidden = YES; }); // path_to_url // path_to_url //[movieWriter cancelRecording]; } -(void)clickDleBtn:(UIButton*)sender { float progressWidth = [_lastAry.lastObject floatValue]/10*SCREEN_WIDTH; [progressPreView setFrame:CGRectMake(0, SCREEN_HEIGHT - 4, progressWidth, 4)]; currentTime = [_lastAry.lastObject floatValue]; timeLabel.text = [NSString stringWithFormat:@" 00:0%.0f",currentTime]; if (urlArray.count) { [urlArray removeLastObject]; [_lastAry removeLastObject]; if (urlArray.count == 0) { _dleButton.hidden = YES; } if (currentTime < 3) { _cameraChangeButton.hidden = YES; } } } -(void)clickInputBtn:(UIButton*)sender { TZImagePickerController* imagePickerVc = [[TZImagePickerController alloc] initWithMaxImagesCount:1 delegate:self]; imagePickerVc.isSelectOriginalPhoto = NO; imagePickerVc.allowTakePicture = NO; imagePickerVc.allowPickingImage = NO; imagePickerVc.allowPickingGif = NO; imagePickerVc.allowPickingVideo = YES; imagePickerVc.sortAscendingByModificationDate = YES; [imagePickerVc setDidFinishPickingVideoHandle:^(UIImage *coverImage,id asset) { HUD = [MBProgressHUD showHUDAddedTo:self animated:YES]; HUD.labelText = @"..."; if (iOS8Later) { PHAsset* myasset = asset; PHVideoRequestOptions *options = [[PHVideoRequestOptions alloc] init]; // options.version = PHImageRequestOptionsVersionCurrent; options.deliveryMode = PHVideoRequestOptionsDeliveryModeAutomatic; PHImageManager *manager = [PHImageManager defaultManager]; [manager requestAVAssetForVideo:myasset options:options resultHandler:^(AVAsset * _Nullable asset, AVAudioMix * _Nullable audioMix, NSDictionary * _Nullable info) { dispatch_async(dispatch_get_main_queue(), ^{ AVURLAsset *urlAsset = (AVURLAsset *)asset; NSURL *url = urlAsset.URL; NSData* videoData = [NSData dataWithContentsOfFile:[[url absoluteString ] stringByReplacingOccurrencesOfString:@"file://" withString:@""]]; if (videoData.length>1024*1024*4.5) { HUD.labelText = @"5M,"; [HUD hide:YES afterDelay:1.5]; }else{ EditingPublishingDynamicViewController* cor = [[EditingPublishingDynamicViewController alloc] init]; cor.videoURL = url; [[NSNotificationCenter defaultCenter] removeObserver:self]; [videoCamera stopCameraCapture]; // [[AppDelegate appDelegate] pushViewController:cor animated:YES]; if (self.delegate&&[self.delegate respondsToSelector:@selector(pushCor:)]) { [self.delegate pushCor:cor]; } [self removeFromSuperview]; } }); }]; }else { dispatch_async(dispatch_get_main_queue(), ^{ ALAsset* myasset = asset; NSURL *videoURL =[myasset valueForProperty:ALAssetPropertyAssetURL]; NSURL *url = videoURL; NSData* videoData = [NSData dataWithContentsOfFile:[[url absoluteString ] stringByReplacingOccurrencesOfString:@"file://" withString:@""]]; if (videoData.length>1024*1024*4.5) { HUD.labelText = @"5M,"; [HUD hide:YES afterDelay:1.5]; }else { EditingPublishingDynamicViewController* cor = [[EditingPublishingDynamicViewController alloc] init]; cor.videoURL = url; [[NSNotificationCenter defaultCenter] removeObserver:self]; [videoCamera stopCameraCapture]; // [[AppDelegate appDelegate] pushViewController:cor animated:YES]; if (self.delegate&&[self.delegate respondsToSelector:@selector(pushCor:)]) { [self.delegate pushCor:cor]; } [self removeFromSuperview]; } }); } NSLog(@""); }]; // [[AppDelegate appDelegate] presentViewController:imagePickerVc animated:YES completion:^{ // }]; if (self.delegate&&[self.delegate respondsToSelector:@selector(presentCor:)]) { [self.delegate presentCor:imagePickerVc]; } } - (void)mergeAndExportVideos:(NSArray*)videosPathArray withOutPath:(NSString*)outpath{ if (videosPathArray.count == 0) { return; } // AVMutableComposition *mixComposition = [[AVMutableComposition alloc] init]; // AVMutableCompositionTrack *audioTrack = [mixComposition addMutableTrackWithMediaType:AVMediaTypeAudio preferredTrackID:kCMPersistentTrackID_Invalid]; // AVMutableCompositionTrack *videoTrack = [mixComposition addMutableTrackWithMediaType:AVMediaTypeVideo preferredTrackID:kCMPersistentTrackID_Invalid]; UIImage* waterImg = [UIImage imageNamed:@"LDWatermark"]; CMTime totalDuration = kCMTimeZero; for (int i = 0; i < videosPathArray.count; i++) { // AVURLAsset *asset = [AVURLAsset assetWithURL:[NSURL URLWithString:videosPathArray[i]]]; NSDictionary* options = @{AVURLAssetPreferPreciseDurationAndTimingKey:@YES}; AVAsset* asset = [AVURLAsset URLAssetWithURL:videosPathArray[i] options:options]; NSError *erroraudio = nil; //AVAsset AVAssetTrack *assetAudioTrack = [[asset tracksWithMediaType:AVMediaTypeAudio] firstObject]; // BOOL ba = [audioTrack insertTimeRange:CMTimeRangeMake(kCMTimeZero, asset.duration) ofTrack:assetAudioTrack atTime:totalDuration error:&erroraudio]; NSLog(@"erroraudio:%@%d",erroraudio,ba); NSError *errorVideo = nil; AVAssetTrack *assetVideoTrack = [[asset tracksWithMediaType:AVMediaTypeVideo]firstObject]; BOOL bl = [videoTrack insertTimeRange:CMTimeRangeMake(kCMTimeZero, asset.duration) ofTrack:assetVideoTrack atTime:totalDuration error:&errorVideo]; NSLog(@"errorVideo:%@%d",errorVideo,bl); totalDuration = CMTimeAdd(totalDuration, asset.duration); } NSLog(@"%@",NSHomeDirectory()); //layer layer //2017 04 19 del by hyy CGSize videoSize = [videoTrack naturalSize]; CALayer* aLayer = [CALayer layer]; aLayer.contents = (id)waterImg.CGImage; aLayer.frame = CGRectMake(videoSize.width - waterImg.size.width - 30, videoSize.height - waterImg.size.height*3, waterImg.size.width, waterImg.size.height); aLayer.opacity = 0.9; CALayer *parentLayer = [CALayer layer]; CALayer *videoLayer = [CALayer layer]; parentLayer.frame = CGRectMake(0, 0, videoSize.width, videoSize.height); videoLayer.frame = CGRectMake(0, 0, videoSize.width, videoSize.height); [parentLayer addSublayer:videoLayer]; [parentLayer addSublayer:aLayer]; AVMutableVideoComposition* videoComp = [AVMutableVideoComposition videoComposition]; videoComp.renderSize = videoSize; videoComp.frameDuration = CMTimeMake(1, 30); videoComp.animationTool = [AVVideoCompositionCoreAnimationTool videoCompositionCoreAnimationToolWithPostProcessingAsVideoLayer:videoLayer inLayer:parentLayer]; AVMutableVideoCompositionInstruction* instruction = [AVMutableVideoCompositionInstruction videoCompositionInstruction]; instruction.timeRange = CMTimeRangeMake(kCMTimeZero, [mixComposition duration]); AVAssetTrack* mixVideoTrack = [[mixComposition tracksWithMediaType:AVMediaTypeVideo] objectAtIndex:0]; AVMutableVideoCompositionLayerInstruction* layerInstruction = [AVMutableVideoCompositionLayerInstruction videoCompositionLayerInstructionWithAssetTrack:mixVideoTrack]; instruction.layerInstructions = [NSArray arrayWithObject:layerInstruction]; videoComp.instructions = [NSArray arrayWithObject: instruction]; NSURL *mergeFileURL = [NSURL fileURLWithPath:outpath]; // AVAssetExportSession *exporter = [[AVAssetExportSession alloc] initWithAsset:mixComposition presetName:AVAssetExportPreset1280x720]; exporter.videoComposition = videoComp; /* exporter.progress This property is not key-value observable. kvo NStimer */ exporter.outputURL = mergeFileURL; exporter.outputFileType = AVFileTypeQuickTimeMovie; exporter.shouldOptimizeForNetworkUse = YES; [exporter exportAsynchronouslyWithCompletionHandler:^{ dispatch_async(dispatch_get_main_queue(), ^{ [videoCamera stopCameraCapture]; EditVideoViewController* view = [[EditVideoViewController alloc]init]; view.width = _width; view.hight = _hight; view.bit = _bit; view.frameRate = _frameRate; view.videoURL = [NSURL fileURLWithPath:outpath];; [[NSNotificationCenter defaultCenter] removeObserver:self]; // [[AppDelegate sharedAppDelegate] pushViewController:view animated:YES]; if (self.delegate&&[self.delegate respondsToSelector:@selector(pushCor:)]) { [self.delegate pushCor:view]; } [self removeFromSuperview]; }); }]; //// UIImage* waterImg = [UIImage imageNamed:@"LDWatermark"]; // CMTime totalDuration = kCMTimeZero; // for (int i = 0; i < videosPathArray.count; i++) { //// AVURLAsset *asset = [AVURLAsset assetWithURL:[NSURL URLWithString:videosPathArray[i]]]; // NSDictionary* options = @{AVURLAssetPreferPreciseDurationAndTimingKey:@YES}; // AVAsset* asset = [AVURLAsset URLAssetWithURL:videosPathArray[i] options:options]; // // NSError *erroraudio = nil; // //AVAsset // AVAssetTrack *assetAudioTrack = [[asset tracksWithMediaType:AVMediaTypeAudio] firstObject]; // // // BOOL ba = [audioTrack insertTimeRange:CMTimeRangeMake(kCMTimeZero, asset.duration) // ofTrack:assetAudioTrack // atTime:totalDuration // error:&erroraudio]; // // NSLog(@"erroraudio:%@%d",erroraudio,ba); // NSError *errorVideo = nil; // AVAssetTrack *assetVideoTrack = [[asset tracksWithMediaType:AVMediaTypeVideo]firstObject]; // BOOL bl = [videoTrack insertTimeRange:CMTimeRangeMake(kCMTimeZero, asset.duration) // ofTrack:assetVideoTrack // atTime:totalDuration // error:&errorVideo]; // // NSLog(@"errorVideo:%@%d",errorVideo,bl); // totalDuration = CMTimeAdd(totalDuration, asset.duration); // } // NSLog(@"%@",NSHomeDirectory()); // // //layer layer // //2017 04 19 del by hyy //// CGSize videoSize = [videoTrack naturalSize]; //// CALayer* aLayer = [CALayer layer]; //// aLayer.contents = (id)waterImg.CGImage; //// aLayer.frame = CGRectMake(videoSize.width - waterImg.size.width - 30, videoSize.height - waterImg.size.height*3, waterImg.size.width, waterImg.size.height); //// aLayer.opacity = 0.9; //// //// CALayer *parentLayer = [CALayer layer]; //// CALayer *videoLayer = [CALayer layer]; //// parentLayer.frame = CGRectMake(0, 0, videoSize.width, videoSize.height); //// videoLayer.frame = CGRectMake(0, 0, videoSize.width, videoSize.height); //// [parentLayer addSublayer:videoLayer]; //// [parentLayer addSublayer:aLayer]; //// AVMutableVideoComposition* videoComp = [AVMutableVideoComposition videoComposition]; //// videoComp.renderSize = videoSize; //// //// //// videoComp.frameDuration = CMTimeMake(1, 30); //// videoComp.animationTool = [AVVideoCompositionCoreAnimationTool videoCompositionCoreAnimationToolWithPostProcessingAsVideoLayer:videoLayer inLayer:parentLayer]; //// AVMutableVideoCompositionInstruction* instruction = [AVMutableVideoCompositionInstruction videoCompositionInstruction]; //// //// instruction.timeRange = CMTimeRangeMake(kCMTimeZero, [mixComposition duration]); //// AVAssetTrack* mixVideoTrack = [[mixComposition tracksWithMediaType:AVMediaTypeVideo] objectAtIndex:0]; //// AVMutableVideoCompositionLayerInstruction* layerInstruction = [AVMutableVideoCompositionLayerInstruction videoCompositionLayerInstructionWithAssetTrack:mixVideoTrack]; //// instruction.layerInstructions = [NSArray arrayWithObject:layerInstruction]; //// videoComp.instructions = [NSArray arrayWithObject: instruction]; // // // NSURL *mergeFileURL = [NSURL fileURLWithPath:outpath]; // // // // AVAssetExportSession *exporter = [[AVAssetExportSession alloc] initWithAsset:mixComposition // presetName:AVAssetExportPreset1280x720]; //// exporter.videoComposition = videoComp; // /* // exporter.progress // // This property is not key-value observable. // kvo // NStimer // */ // exporter.outputURL = mergeFileURL; // exporter.outputFileType = AVFileTypeQuickTimeMovie; // exporter.shouldOptimizeForNetworkUse = YES; // [exporter exportAsynchronouslyWithCompletionHandler:^{ // dispatch_async(dispatch_get_main_queue(), ^{ // // [videoCamera stopCameraCapture]; // // EditVideoViewController* view = [[EditVideoViewController alloc]init]; // view.width = _width; // view.hight = _hight; // view.bit = _bit; // view.frameRate = _frameRate; // view.videoURL = [NSURL fileURLWithPath:outpath];; // [[NSNotificationCenter defaultCenter] removeObserver:self]; // [[AppDelegate sharedAppDelegate] pushViewController:view animated:YES]; // [self removeFromSuperview]; // }); // // // }]; } - (UIViewController *)getCurrentVC { UIViewController *result = nil; UIWindow * window = [[UIApplication sharedApplication] keyWindow]; if (window.windowLevel != UIWindowLevelNormal) { NSArray *windows = [[UIApplication sharedApplication] windows]; for(UIWindow * tmpWin in windows) { if (tmpWin.windowLevel == UIWindowLevelNormal) { window = tmpWin; break; } } } UIView *frontView = [[window subviews] objectAtIndex:0]; id nextResponder = [frontView nextResponder]; if ([nextResponder isKindOfClass:[UIViewController class]]) result = nextResponder; else result = window.rootViewController; return result; } // mp4 - (NSString *)getVideoMergeFilePathString { // NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); // NSString *path = [paths objectAtIndex:0]; //Temp NSString *tempPath = NSTemporaryDirectory(); NSString* path = [tempPath stringByAppendingPathComponent:VIDEO_FOLDER]; NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; formatter.dateFormat = @"yyyyMMddHHmmss"; NSString *nowTimeStr = [formatter stringFromDate:[NSDate dateWithTimeIntervalSinceNow:0]]; NSString *fileName = [[path stringByAppendingPathComponent:nowTimeStr] stringByAppendingString:@"merge.mov"]; return fileName; } - (void)createVideoFolderIfNotExist { // NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); // NSString *path = [paths objectAtIndex:0]; //Temp NSString *tempPath = NSTemporaryDirectory(); NSString *folderPath = [tempPath stringByAppendingPathComponent:VIDEO_FOLDER]; NSFileManager *fileManager = [NSFileManager defaultManager]; BOOL isDir = NO; BOOL isDirExist = [fileManager fileExistsAtPath:folderPath isDirectory:&isDir]; if(!(isDirExist && isDir)) { BOOL bCreateDir = [fileManager createDirectoryAtPath:folderPath withIntermediateDirectories:YES attributes:nil error:nil]; if(!bCreateDir){ NSLog(@""); } } } -(void)clickBackToHome { [[NSNotificationCenter defaultCenter] removeObserver:self]; [videoCamera stopCameraCapture]; if (_isRecoding) { [movieWriter cancelRecording]; [filter removeTarget:movieWriter]; _isRecoding = NO; } [myTimer invalidate]; myTimer = nil; if (self.backToHomeBlock) { NSLog(@"clickBacktoHome"); self.backToHomeBlock(); [self removeFromSuperview]; } // [self.navigationController popToRootViewControllerAnimated:YES]; } -(void)changeCameraPositionBtn:(UIButton*)sender{ switch (_position) { case CameraManagerDevicePositionBack: { if (videoCamera.cameraPosition == AVCaptureDevicePositionBack) { [videoCamera pauseCameraCapture]; _position = CameraManagerDevicePositionFront; // dispatch_async(dispatch_get_global_queue(0, 0), ^{ [videoCamera rotateCamera]; [videoCamera resumeCameraCapture]; sender.selected = YES; [videoCamera removeAllTargets]; // filter = [[GPUImageBeautifyFilter alloc] init]; _camerafilterChangeButton.selected = YES; filter = [[GPUImageBeautifyFilter alloc] init]; [videoCamera addTarget:filter]; [filter addTarget:filteredVideoView]; // }); } } break; case CameraManagerDevicePositionFront: { if (videoCamera.cameraPosition == AVCaptureDevicePositionFront) { [videoCamera pauseCameraCapture]; _position = CameraManagerDevicePositionBack; // dispatch_async(dispatch_get_global_queue(0, 0), ^{ [videoCamera rotateCamera]; [videoCamera resumeCameraCapture]; sender.selected = NO; [videoCamera removeAllTargets]; _camerafilterChangeButton.selected = NO; filter = [[LFGPUImageEmptyFilter alloc] init]; [videoCamera addTarget:filter]; [filter addTarget:filteredVideoView]; // }); } } break; default: break; } if ([videoCamera.inputCamera lockForConfiguration:nil] && [videoCamera.inputCamera isExposureModeSupported:AVCaptureExposureModeContinuousAutoExposure]) { [videoCamera.inputCamera setExposureMode:AVCaptureExposureModeContinuousAutoExposure]; [videoCamera.inputCamera unlockForConfiguration]; } } - (void)changebeautifyFilterBtn:(UIButton*)sender{ if (!sender.selected) { sender.selected = YES; [videoCamera removeAllTargets]; // filter = [[GPUImageBeautifyFilter alloc] init]; filter = [[GPUImageBeautifyFilter alloc] init]; [videoCamera addTarget:filter]; [filter addTarget:filteredVideoView]; }else { sender.selected = NO; [videoCamera removeAllTargets]; filter = [[LFGPUImageEmptyFilter alloc] init]; [videoCamera addTarget:filter]; [filter addTarget:filteredVideoView]; } } - (void)updateTimer:(NSTimer *)sender{ // NSDateFormatter *dateFormator = [[NSDateFormatter alloc] init]; // dateFormator.dateFormat = @"HH:mm:ss"; // NSDate *todate = [NSDate date]; // NSCalendar *calendar = [NSCalendar currentCalendar]; // NSInteger unitFlags = NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit | // NSHourCalendarUnit | NSMinuteCalendarUnit | NSSecondCalendarUnit; // NSDateComponents *comps = [calendar components:unitFlags fromDate:fromdate toDate:todate options:NSCalendarWrapComponents]; // //NSInteger hour = [comps hour]; // //NSInteger min = [comps minute]; // //NSInteger sec = [comps second]; // NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSCalendarIdentifierGregorian]; // NSDate *timer = [gregorian dateFromComponents:comps]; // NSString *date = [dateFormator stringFromDate:timer]; currentTime += TIMER_INTERVAL; // timeLabel.text = [NSString stringWithFormat:@" 00:02%d",(int)currentTime]; if (currentTime>=10) { timeLabel.text = [NSString stringWithFormat:@" 00:%d",(int)currentTime]; }else { timeLabel.text = [NSString stringWithFormat:@" 00:0%.0f",currentTime]; } float progressWidth = progressPreView.frame.size.width+progressStep; [progressPreView setFrame:CGRectMake(0, SCREEN_HEIGHT - 4, progressWidth, 4)]; if (currentTime>3) { _cameraChangeButton.hidden = NO; } // if (currentTime>=totalTime) { _photoCaptureButton.enabled = NO; [self stopRecording:nil]; } } - (void)setfocusImage{ UIImage *focusImage = [UIImage imageNamed:@"96"]; UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, focusImage.size.width, focusImage.size.height)]; imageView.image = focusImage; CALayer *layer = imageView.layer; layer.hidden = YES; [filteredVideoView.layer addSublayer:layer]; _focusLayer = layer; } - (void)layerAnimationWithPoint:(CGPoint)point { if (_focusLayer) { CALayer *focusLayer = _focusLayer; focusLayer.hidden = NO; [CATransaction begin]; [CATransaction setDisableActions:YES]; [focusLayer setPosition:point]; focusLayer.transform = CATransform3DMakeScale(2.0f,2.0f,1.0f); [CATransaction commit]; CABasicAnimation *animation = [ CABasicAnimation animationWithKeyPath: @"transform" ]; animation.toValue = [ NSValue valueWithCATransform3D: CATransform3DMakeScale(1.0f,1.0f,1.0f)]; // animation.delegate = self; animation.duration = 0.3f; animation.repeatCount = 1; animation.removedOnCompletion = NO; animation.fillMode = kCAFillModeForwards; [focusLayer addAnimation: animation forKey:@"animation"]; // 0.5 [self performSelector:@selector(focusLayerNormal) withObject:self afterDelay:0.5f]; } } - (void)animationDidStop:(CAAnimation *)anim finished:(BOOL)flag { } - (void)focusLayerNormal { filteredVideoView.userInteractionEnabled = YES; _focusLayer.hidden = YES; } /** @abstract UI */ - (CGPoint)convertToPointOfInterestFromViewCoordinates:(CGPoint)viewCoordinates { CGPoint pointOfInterest = CGPointMake(.5f, .5f); CGSize frameSize = filteredVideoView.frame.size; CGSize apertureSize = CGSizeMake(1280, 720);// CGPoint point = viewCoordinates; CGFloat apertureRatio = apertureSize.height / apertureSize.width; CGFloat viewRatio = frameSize.width / frameSize.height; CGFloat xc = .5f; CGFloat yc = .5f; if (viewRatio > apertureRatio) { CGFloat y2 = frameSize.height; CGFloat x2 = frameSize.height * apertureRatio; CGFloat x1 = frameSize.width; CGFloat blackBar = (x1 - x2) / 2; if (point.x >= blackBar && point.x <= blackBar + x2) { xc = point.y / y2; yc = 1.f - ((point.x - blackBar) / x2); } }else { CGFloat y2 = frameSize.width / apertureRatio; CGFloat y1 = frameSize.height; CGFloat x2 = frameSize.width; CGFloat blackBar = (y1 - y2) / 2; if (point.y >= blackBar && point.y <= blackBar + y2) { xc = ((point.y - blackBar) / y2); yc = 1.f - (point.x / x2); } } pointOfInterest = CGPointMake(xc, yc); return pointOfInterest; } -(void)cameraViewTapAction:(UITapGestureRecognizer *)tgr { if (tgr.state == UIGestureRecognizerStateRecognized && (_focusLayer == nil || _focusLayer.hidden)) { CGPoint location = [tgr locationInView:filteredVideoView]; [self setfocusImage]; [self layerAnimationWithPoint:location]; AVCaptureDevice *device = videoCamera.inputCamera; // CGPoint pointOfInterest = CGPointMake(0.5f, 0.5f); // NSLog(@"taplocation x = %f y = %f", location.x, location.y); // CGSize frameSize = [filteredVideoView frame].size; // // if ([videoCamera cameraPosition] == AVCaptureDevicePositionFront) { // location.x = frameSize.width - location.x; // } // // pointOfInterest = CGPointMake(location.y / frameSize.height, 1.f - (location.x / frameSize.width)); CGPoint pointOfInterest = [self convertToPointOfInterestFromViewCoordinates:location]; NSError *error; if ([device lockForConfiguration:&error]) { if ([device isFocusPointOfInterestSupported] && [device isFocusModeSupported:AVCaptureFocusModeContinuousAutoFocus]) { [device setFocusPointOfInterest:pointOfInterest]; [device setFocusMode:AVCaptureFocusModeContinuousAutoFocus]; } if([device isExposurePointOfInterestSupported] && [device isExposureModeSupported:AVCaptureExposureModeContinuousAutoExposure]) { [device setExposurePointOfInterest:pointOfInterest]; [device setExposureMode:AVCaptureExposureModeContinuousAutoExposure]; } [device unlockForConfiguration]; NSLog(@"FOCUS OK"); } else { NSLog(@"ERROR = %@", error); } } } -(void)notCloseCor { [self clickBackToHome]; } -(void)dealloc { NSLog(@"%@",self.class); } @end ```
/content/code_sandbox/PlayerDemo/CustomVideoCamera/VideoCameraView.m
objective-c
2016-02-02T02:51:55
2024-08-09T08:55:27
WMPlayer
zhengwenming/WMPlayer
3,272
8,952
```xml #import "LFGPUImageEmptyFilter.h" #if TARGET_IPHONE_SIMULATOR || TARGET_OS_IPHONE NSString *const kLFGPUImageEmptyFragmentShaderString = SHADER_STRING ( varying highp vec2 textureCoordinate; uniform sampler2D inputImageTexture; void main() { lowp vec4 textureColor = texture2D(inputImageTexture, textureCoordinate); gl_FragColor = vec4((textureColor.rgb), textureColor.w); } ); #else NSString *const kGPUImageInvertFragmentShaderString = SHADER_STRING ( varying vec2 textureCoordinate; uniform sampler2D inputImageTexture; void main() { vec4 textureColor = texture2D(inputImageTexture, textureCoordinate); gl_FragColor = vec4((textureColor.rgb), textureColor.w); } ); #endif @implementation LFGPUImageEmptyFilter - (id)init; { if (!(self = [super initWithFragmentShaderFromString:kLFGPUImageEmptyFragmentShaderString])) { return nil; } return self; } @end ```
/content/code_sandbox/PlayerDemo/CustomVideoCamera/Filters/LFGPUImageEmptyFilter.mm
xml
2016-02-02T02:51:55
2024-08-09T08:55:27
WMPlayer
zhengwenming/WMPlayer
3,272
231
```objective-c //#import "GPUImageFilter.h" #import "GPUImage.h" @interface LFGPUImageEmptyFilter : GPUImageFilter { } @end ```
/content/code_sandbox/PlayerDemo/CustomVideoCamera/Filters/LFGPUImageEmptyFilter.h
objective-c
2016-02-02T02:51:55
2024-08-09T08:55:27
WMPlayer
zhengwenming/WMPlayer
3,272
31
```objective-c // // GPUImageBeautifyFilter.h // BeautifyFaceDemo // // Created by guikz on 16/4/28. // #import "GPUImage.h" @class GPUImageCombinationFilter; @interface GPUImageBeautifyFilter : GPUImageFilterGroup { GPUImageBilateralFilter *bilateralFilter; GPUImageCannyEdgeDetectionFilter *cannyEdgeFilter; GPUImageCombinationFilter *combinationFilter; GPUImageHSBFilter *hsbFilter; } @end ```
/content/code_sandbox/PlayerDemo/CustomVideoCamera/Filters/GPUImageBeautifyFilter.h
objective-c
2016-02-02T02:51:55
2024-08-09T08:55:27
WMPlayer
zhengwenming/WMPlayer
3,272
111
```xml // // GPUImageBeautifyFilter.m // BeautifyFaceDemo // // Created by guikz on 16/4/28. // #import "GPUImageBeautifyFilter.h" // Internal CombinationFilter(It should not be used outside) @interface GPUImageCombinationFilter : GPUImageThreeInputFilter { GLint smoothDegreeUniform; } @property (nonatomic, assign) CGFloat intensity; @end NSString *const kGPUImageBeautifyFragmentShaderString = SHADER_STRING ( varying highp vec2 textureCoordinate; varying highp vec2 textureCoordinate2; varying highp vec2 textureCoordinate3; uniform sampler2D inputImageTexture; uniform sampler2D inputImageTexture2; uniform sampler2D inputImageTexture3; uniform mediump float smoothDegree; void main() { highp vec4 bilateral = texture2D(inputImageTexture, textureCoordinate); highp vec4 canny = texture2D(inputImageTexture2, textureCoordinate2); highp vec4 origin = texture2D(inputImageTexture3,textureCoordinate3); highp vec4 smooth; lowp float r = origin.r; lowp float g = origin.g; lowp float b = origin.b; if (canny.r < 0.2 && r > 0.3725 && g > 0.1568 && b > 0.0784 && r > b && (max(max(r, g), b) - min(min(r, g), b)) > 0.0588 && abs(r-g) > 0.0588) { smooth = (1.0 - smoothDegree) * (origin - bilateral) + bilateral; } else { smooth = origin; } smooth.r = log(1.0 + 0.2 * smooth.r)/log(1.2); smooth.g = log(1.0 + 0.2 * smooth.g)/log(1.2); smooth.b = log(1.0 + 0.2 * smooth.b)/log(1.2); gl_FragColor = smooth; } ); @implementation GPUImageCombinationFilter - (id)init { if (self = [super initWithFragmentShaderFromString:kGPUImageBeautifyFragmentShaderString]) { smoothDegreeUniform = [filterProgram uniformIndex:@"smoothDegree"]; } self.intensity = 0.5; return self; } - (void)setIntensity:(CGFloat)intensity { _intensity = intensity; [self setFloat:intensity forUniform:smoothDegreeUniform program:filterProgram]; } @end @implementation GPUImageBeautifyFilter - (id)init; { if (!(self = [super init])) { return nil; } // First pass: face smoothing filter bilateralFilter = [[GPUImageBilateralFilter alloc] init]; bilateralFilter.distanceNormalizationFactor = 4.0; [self addFilter:bilateralFilter]; // Second pass: edge detection cannyEdgeFilter = [[GPUImageCannyEdgeDetectionFilter alloc] init]; [self addFilter:cannyEdgeFilter]; // Third pass: combination bilateral, edge detection and origin combinationFilter = [[GPUImageCombinationFilter alloc] init]; [self addFilter:combinationFilter]; // Adjust HSB hsbFilter = [[GPUImageHSBFilter alloc] init]; [hsbFilter adjustBrightness:1.1]; [hsbFilter adjustSaturation:1.1]; [bilateralFilter addTarget:combinationFilter]; [cannyEdgeFilter addTarget:combinationFilter]; [combinationFilter addTarget:hsbFilter]; self.initialFilters = [NSArray arrayWithObjects:bilateralFilter,cannyEdgeFilter,combinationFilter,nil]; self.terminalFilter = hsbFilter; return self; } #pragma mark - #pragma mark GPUImageInput protocol - (void)newFrameReadyAtTime:(CMTime)frameTime atIndex:(NSInteger)textureIndex; { for (GPUImageOutput<GPUImageInput> *currentFilter in self.initialFilters) { if (currentFilter != self.inputFilterToIgnoreForUpdates) { if (currentFilter == combinationFilter) { textureIndex = 2; } [currentFilter newFrameReadyAtTime:frameTime atIndex:textureIndex]; } } } - (void)setInputFramebuffer:(GPUImageFramebuffer *)newInputFramebuffer atIndex:(NSInteger)textureIndex; { for (GPUImageOutput<GPUImageInput> *currentFilter in self.initialFilters) { if (currentFilter == combinationFilter) { textureIndex = 2; } [currentFilter setInputFramebuffer:newInputFramebuffer atIndex:textureIndex]; } } @end ```
/content/code_sandbox/PlayerDemo/CustomVideoCamera/Filters/GPUImageBeautifyFilter.mm
xml
2016-02-02T02:51:55
2024-08-09T08:55:27
WMPlayer
zhengwenming/WMPlayer
3,272
1,014
```objective-c // // VideoDataModel.h // PlayerDemo // // Created by apple on 2018/8/10. // #import <Foundation/Foundation.h> #import <Foundation/Foundation.h> @interface CommentDataModel : NSObject /** id */ @property (nonatomic ,strong) NSString* dynamicID; /** UID */ @property (nonatomic ,strong) NSString* referUID; /** ID */ @property (nonatomic ,strong) NSString* selfUID; /** */ @property (nonatomic ,strong) NSString* selfNickName; /** */ @property (nonatomic ,strong) NSString* content; /** */ @property (nonatomic ,strong) NSString* createdTime; /** */ @property (nonatomic ,strong) NSString* faceurl; /** */ @property (nonatomic ,strong) NSString* iconIndex; /** @param DynamicID ID @param page @param block blockdatearyerror */ +(void)getCommentDataWithBlockWithDynamicID:(NSString*)DynamicID forFlag:(int)flag AndPage:(NSString*)page ForHandelBlock:(void (^)(NSArray* dateAry, int code))block; @end @interface VideoDataModel : NSObject @property (nonatomic, strong) NSIndexPath *indexPath; /** */ @property (nonatomic ,strong) NSString* title; /** */ @property (nonatomic ,strong) NSString* location; /** */ @property (nonatomic ,strong) NSString* nickname; /** */ @property (nonatomic ,strong) NSString* avatar_thumb; /** */ @property (nonatomic ,strong) NSString* video_url; /** */ @property (nonatomic ,strong) NSString* cover_url; /** */ @property (nonatomic ,strong) NSString* stats_tips; /** */ @property (nonatomic ,strong) NSString* comment_count; /** */ @property (nonatomic ,strong) NSString* digg_count; /** */ @property (nonatomic ,strong) NSString* play_count; /** */ @property (nonatomic ,strong) NSString* share_count; @property (nonatomic ,strong) NSString* AuthorUid; @property (nonatomic ,strong) NSString* dyid; /** */ @property (nonatomic ,strong) NSString* iconIndex; /** video @param block blockdatearyerror */ +(void)getHomePageVideoDataWithBlock:(void (^)(NSArray* dateAry, NSError* error))block; @end ```
/content/code_sandbox/PlayerDemo/DataManager/VideoDataModel.h
objective-c
2016-02-02T02:51:55
2024-08-09T08:55:27
WMPlayer
zhengwenming/WMPlayer
3,272
477
```objective-c // // VideoDataModel.m // PlayerDemo // // Created by apple on 2018/8/10. // #import "VideoDataModel.h" #import "AFNetworking.h" @implementation CommentDataModel -(id)initCommentDataWithDic:(NSDictionary*)Dic { if (self = [super init]) { /* content = "\U6211\U6765\U53d1\U4e00\U6761\U54c8\U54c8"; "created_time" = 1490157509; "dynamic_id" = 39; faceurl = "path_to_url"; "from_nickname" = "\U9633\U773c\U7684\U718a"; "from_uid" = 80061831; "iconindex" = 1000; "refer_uid" = "<null>"; */ if ([Dic objectForKey:@"content"] && ![[Dic objectForKey:@"content"] isKindOfClass:[NSNull class]]) { self.content = [Dic objectForKey:@"content"]; } if ([Dic objectForKey:@"created_time"] && ![[Dic objectForKey:@"created_time"] isKindOfClass:[NSNull class]]) { self.createdTime = [self updateTimeForRow:[Dic objectForKey:@"created_time"]]; } if ([Dic objectForKey:@"dynamic_id"] && ![[Dic objectForKey:@"dynamic_id"] isKindOfClass:[NSNull class]]) { self.dynamicID = [Dic objectForKey:@"dynamic_id"]; } int iconIndex = 0; if ([Dic objectForKey:@"iconindex"] && ![[Dic objectForKey:@"iconindex"] isKindOfClass:[NSNull class]]) { iconIndex = [[Dic objectForKey:@"iconindex"] intValue]; } self.iconIndex = [NSString stringWithFormat:@"%d",iconIndex]; if ([Dic objectForKey:@"faceurl"] && ![[Dic objectForKey:@"faceurl"] isKindOfClass:[NSNull class]]) { if (iconIndex == 1000) { // self.faceurl = [[NSBundle mainBundle]pathForResource:kDefaultAvatarIcon ofType:kPngName]; }else { self.faceurl = [Dic objectForKey:@"faceurl"]; } } if ([Dic objectForKey:@"from_nickname"] && ![[Dic objectForKey:@"from_nickname"] isKindOfClass:[NSNull class]]) { self.selfNickName = [Dic objectForKey:@"from_nickname"]; } if ([Dic objectForKey:@"from_uid"] && ![[Dic objectForKey:@"from_uid"] isKindOfClass:[NSNull class]]) { self.selfUID = [Dic objectForKey:@"from_uid"]; } if ([Dic objectForKey:@"refer_uid"] && ![[Dic objectForKey:@"refer_uid"] isKindOfClass:[NSNull class]]) { self.referUID = [Dic objectForKey:@"refer_uid"]; } } return self; } - (NSString *)updateTimeForRow:(NSString *)createTimeString { // 1466386762.345715 6 NSTimeInterval currentTime = [[NSDate date] timeIntervalSince1970]; // ( 13) NSTimeInterval createTime = [createTimeString longLongValue]; // NSTimeInterval time = currentTime - createTime; NSInteger sec = time/60; if (sec<60) { return [NSString stringWithFormat:@"%ld",(long)sec]; } // NSInteger hours = time/3600; if (hours<24) { return [NSString stringWithFormat:@"%ld",(long)hours]; } // NSInteger days = time/3600/24; if (days < 30) { return [NSString stringWithFormat:@"%ld",(long)days]; } // NSInteger months = time/3600/24/30; if (months < 12) { return [NSString stringWithFormat:@"%ld",(long)months]; } // NSInteger years = time/3600/24/30/12; return [NSString stringWithFormat:@"%ld",(long)years]; } +(void)getCommentDataWithBlockWithDynamicID:(NSString*)DynamicID forFlag:(int)flag AndPage:(NSString*)page ForHandelBlock:(void (^)(NSArray* dateAry, int code))block { } @end @implementation VideoDataModel -(id)initVideoDataWithDic:(NSDictionary*)Dic { if (self = [super init]) { if ([Dic objectForKey:@"data"] && ![[Dic objectForKey:@"data"] isKindOfClass:[NSNull class]]) { NSDictionary* videoInfo = [Dic objectForKey:@"data"]; self.title = [videoInfo objectForKey:@"text"]; self.stats_tips = [videoInfo objectForKey:@"tips"]; self.location = [videoInfo objectForKey:@"location"]; if ([videoInfo objectForKey:@"author"] && ![[videoInfo objectForKey:@"author"] isKindOfClass:[NSNull class]]) { NSDictionary* authorDic = [videoInfo objectForKey:@"author"]; self.nickname = [authorDic objectForKey:@"nickname"]; self.avatar_thumb = [[[authorDic objectForKey:@"avatar_thumb"] objectForKey:@"url_list"] objectAtIndex:0]; } if ([videoInfo objectForKey:@"video"] && ![[videoInfo objectForKey:@"video"] isKindOfClass:[NSNull class]]) { NSDictionary* videoUrlDic = [videoInfo objectForKey:@"video"]; self.cover_url = [[[videoUrlDic objectForKey:@"cover"] objectForKey:@"url_list"] objectAtIndex:0]; self.video_url = [[videoUrlDic objectForKey:@"download_url"] objectAtIndex:0]; } if ([videoInfo objectForKey:@"stats"] && ![[videoInfo objectForKey:@"stats"] isKindOfClass:[NSNull class]]) { NSDictionary* statsDic = [videoInfo objectForKey:@"stats"]; self.comment_count = [NSString stringWithFormat:@"%d",[[statsDic objectForKey:@"comment_count"] intValue]]; self.digg_count = [NSString stringWithFormat:@"%d",[[statsDic objectForKey:@"digg_count"] intValue]]; self.play_count = [NSString stringWithFormat:@"%d",[[statsDic objectForKey:@"play_count"] intValue]]; self.share_count = [NSString stringWithFormat:@"%d",[[statsDic objectForKey:@"share_count"] intValue]]; } } } return self; } +(void)getHomePageVideoDataWithBlock:(void (^)(NSArray* dateAry, NSError* error))block { // NSString *apiString = @"path_to_url"; // NSString *apiString = @"path_to_url"; NSString *apiString = @"path_to_url"; AFHTTPSessionManager* afManager = [AFHTTPSessionManager manager]; afManager.requestSerializer.timeoutInterval = 30; [afManager GET:apiString parameters:nil progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) { if([[responseObject objectForKey:@"status_code"] intValue] != 0){ return ; }else { NSArray* getFromResponse = [responseObject objectForKey:@"data"]; NSMutableArray* mutablePosts = [NSMutableArray arrayWithCapacity:[getFromResponse count]]; for (NSDictionary* attributes in getFromResponse) { VideoDataModel* dataModel = [[VideoDataModel alloc] initVideoDataWithDic:attributes]; [mutablePosts addObject:dataModel]; } if (block) { block([NSArray arrayWithArray:mutablePosts],nil); } } } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) { if (block) { block([NSArray array],error); } }]; } @end ```
/content/code_sandbox/PlayerDemo/DataManager/VideoDataModel.m
objective-c
2016-02-02T02:51:55
2024-08-09T08:55:27
WMPlayer
zhengwenming/WMPlayer
3,272
1,545
```xml <?xml version="1.0" encoding="UTF-8"?> <document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14113" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="01J-lp-oVM"> <device id="retina4_7" orientation="portrait"> <adaptation id="fullscreen"/> </device> <dependencies> <deployment identifier="iOS"/> <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14088"/> <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/> </dependencies> <scenes> <!--View Controller--> <scene sceneID="EHf-IW-A2E"> <objects> <viewController id="01J-lp-oVM" sceneMemberID="viewController"> <layoutGuides> <viewControllerLayoutGuide type="top" id="Llm-lL-Icb"/> <viewControllerLayoutGuide type="bottom" id="xb3-aO-Qok"/> </layoutGuides> <view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3"> <rect key="frame" x="0.0" y="0.0" width="375" height="667"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> </view> </viewController> <placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/> </objects> <point key="canvasLocation" x="53" y="375"/> </scene> </scenes> </document> ```
/content/code_sandbox/PlayerDemo/Base.lproj/LaunchScreen.storyboard
xml
2016-02-02T02:51:55
2024-08-09T08:55:27
WMPlayer
zhengwenming/WMPlayer
3,272
456
```unknown // !$*UTF8*$! { archiveVersion = 1; classes = { }; objectVersion = 46; objects = { /* Begin PBXBuildFile section */ 181BB50A2487FD73003C1FEE /* VCRotateViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 181BB5092487FD73003C1FEE /* VCRotateViewController.m */; }; 18745CFE211D20E80010E46F /* VideoDataModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 18745CFD211D20E80010E46F /* VideoDataModel.m */; }; 18745D01211D283B0010E46F /* HomeVideoCollectionViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 18745D00211D283B0010E46F /* HomeVideoCollectionViewCell.m */; }; 18745D04211D3ADC0010E46F /* CameraViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 18745D03211D3ADC0010E46F /* CameraViewController.m */; }; 18745D07211D57020010E46F /* WMTabBar.m in Sources */ = {isa = PBXBuildFile; fileRef = 18745D06211D57020010E46F /* WMTabBar.m */; }; 1885A0F72472CF2200059B3E /* FullScreenHelperViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 1885A0F62472CF2200059B3E /* FullScreenHelperViewController.m */; }; 1885A1032475490900059B3E /* EnterFullScreenTransition.m in Sources */ = {isa = PBXBuildFile; fileRef = 1885A1022475490900059B3E /* EnterFullScreenTransition.m */; }; 1885A1062475492E00059B3E /* ExitFullScreenTransition.m in Sources */ = {isa = PBXBuildFile; fileRef = 1885A1052475492E00059B3E /* ExitFullScreenTransition.m */; }; 18A54BFA21C3AFED0052670A /* DetailViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 18A54BF921C3AFED0052670A /* DetailViewController.m */; }; 18B862FD248BFC2900795947 /* LandscapeRightViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 18B862F9248BFC2900795947 /* LandscapeRightViewController.m */; }; 18B862FE248BFC2900795947 /* LandscapeLeftViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 18B862FA248BFC2900795947 /* LandscapeLeftViewController.m */; }; 507D9D100C07A70640F9F52A /* Pods_PlayerDemo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3CDD1E457181DFCA30210454 /* Pods_PlayerDemo.framework */; }; 700C154B217A132B004717EE /* OpenGLES.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 700C154A217A132B004717EE /* OpenGLES.framework */; }; 700C154F217A1344004717EE /* libbz2.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 700C154E217A1344004717EE /* libbz2.tbd */; }; 700C1551217A1353004717EE /* libiconv.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 700C1550217A1353004717EE /* libiconv.tbd */; }; 700C1553217A135F004717EE /* VideoToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 700C1552217A135F004717EE /* VideoToolbox.framework */; }; 700C1554217A137F004717EE /* libz.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 700C154C217A133D004717EE /* libz.tbd */; }; 701DCC8F1F52FD27003ACAB6 /* gzh.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 701DCC8E1F52FD27003ACAB6 /* gzh.jpg */; }; 70763CC620CD4A5400DCB7BE /* MediaPlayer.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 70763CC520CD4A5400DCB7BE /* MediaPlayer.framework */; }; 70763CD420CD5C9700DCB7BE /* WMPlayerModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 70763CC920CD5C9700DCB7BE /* WMPlayerModel.m */; }; 70763CD720CD5C9700DCB7BE /* WMLightView.m in Sources */ = {isa = PBXBuildFile; fileRef = 70763CD020CD5C9700DCB7BE /* WMLightView.m */; }; 70763CD820CD5C9700DCB7BE /* FastForwardView.m in Sources */ = {isa = PBXBuildFile; fileRef = 70763CD120CD5C9700DCB7BE /* FastForwardView.m */; }; 70763CD920CD5C9700DCB7BE /* WMPlayer.m in Sources */ = {isa = PBXBuildFile; fileRef = 70763CD220CD5C9700DCB7BE /* WMPlayer.m */; }; 70763CDE20CD5D0200DCB7BE /* WMPlayer.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 70763CDA20CD5D0200DCB7BE /* WMPlayer.bundle */; }; BF1624A81DF50011006209D1 /* RootTabBarController.m in Sources */ = {isa = PBXBuildFile; fileRef = BF16244A1DF50011006209D1 /* RootTabBarController.m */; }; BF1624A91DF50011006209D1 /* VideoCell.m in Sources */ = {isa = PBXBuildFile; fileRef = BF16244C1DF50011006209D1 /* VideoCell.m */; }; BF1624AA1DF50011006209D1 /* VideoCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = BF16244D1DF50011006209D1 /* VideoCell.xib */; }; BF1624AB1DF50011006209D1 /* BaseNavigationController.m in Sources */ = {isa = PBXBuildFile; fileRef = BF1624501DF50011006209D1 /* BaseNavigationController.m */; }; BF1624AC1DF50011006209D1 /* BaseViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = BF1624521DF50011006209D1 /* BaseViewController.m */; }; BF1624AF1DF50011006209D1 /* SinaNewsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = BF1624581DF50011006209D1 /* SinaNewsViewController.m */; }; BF1624B11DF50011006209D1 /* TencentNewsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = BF16245B1DF50011006209D1 /* TencentNewsViewController.m */; }; C4EC7F411DF4FCD2006E9820 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = C4EC7F401DF4FCD2006E9820 /* main.m */; }; C4EC7F441DF4FCD2006E9820 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = C4EC7F431DF4FCD2006E9820 /* AppDelegate.m */; }; C4EC7F4C1DF4FCD3006E9820 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C4EC7F4B1DF4FCD3006E9820 /* Assets.xcassets */; }; C4EC7F4F1DF4FCD3006E9820 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = C4EC7F4D1DF4FCD3006E9820 /* LaunchScreen.storyboard */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ 181BB5082487FD73003C1FEE /* VCRotateViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = VCRotateViewController.h; sourceTree = "<group>"; }; 181BB5092487FD73003C1FEE /* VCRotateViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = VCRotateViewController.m; sourceTree = "<group>"; }; 18745CFC211D20E80010E46F /* VideoDataModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = VideoDataModel.h; sourceTree = "<group>"; }; 18745CFD211D20E80010E46F /* VideoDataModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = VideoDataModel.m; sourceTree = "<group>"; }; 18745CFF211D283B0010E46F /* HomeVideoCollectionViewCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = HomeVideoCollectionViewCell.h; sourceTree = "<group>"; }; 18745D00211D283B0010E46F /* HomeVideoCollectionViewCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = HomeVideoCollectionViewCell.m; sourceTree = "<group>"; }; 18745D02211D3ADC0010E46F /* CameraViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CameraViewController.h; sourceTree = "<group>"; }; 18745D03211D3ADC0010E46F /* CameraViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CameraViewController.m; sourceTree = "<group>"; }; 18745D05211D57020010E46F /* WMTabBar.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WMTabBar.h; sourceTree = "<group>"; }; 18745D06211D57020010E46F /* WMTabBar.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = WMTabBar.m; sourceTree = "<group>"; }; 1885A0F52472CF2200059B3E /* FullScreenHelperViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FullScreenHelperViewController.h; sourceTree = "<group>"; }; 1885A0F62472CF2200059B3E /* FullScreenHelperViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FullScreenHelperViewController.m; sourceTree = "<group>"; }; 1885A1012475490900059B3E /* EnterFullScreenTransition.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = EnterFullScreenTransition.h; sourceTree = "<group>"; }; 1885A1022475490900059B3E /* EnterFullScreenTransition.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = EnterFullScreenTransition.m; sourceTree = "<group>"; }; 1885A1042475492E00059B3E /* ExitFullScreenTransition.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ExitFullScreenTransition.h; sourceTree = "<group>"; }; 1885A1052475492E00059B3E /* ExitFullScreenTransition.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ExitFullScreenTransition.m; sourceTree = "<group>"; }; 18A54BF921C3AFED0052670A /* DetailViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DetailViewController.m; sourceTree = "<group>"; }; 18B862F9248BFC2900795947 /* LandscapeRightViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LandscapeRightViewController.m; sourceTree = "<group>"; }; 18B862FA248BFC2900795947 /* LandscapeLeftViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LandscapeLeftViewController.m; sourceTree = "<group>"; }; 18B862FB248BFC2900795947 /* LandscapeLeftViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LandscapeLeftViewController.h; sourceTree = "<group>"; }; 18B862FC248BFC2900795947 /* LandscapeRightViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LandscapeRightViewController.h; sourceTree = "<group>"; }; 3CDD1E457181DFCA30210454 /* Pods_PlayerDemo.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_PlayerDemo.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 700C154A217A132B004717EE /* OpenGLES.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGLES.framework; path = System/Library/Frameworks/OpenGLES.framework; sourceTree = SDKROOT; }; 700C154C217A133D004717EE /* libz.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libz.tbd; path = usr/lib/libz.tbd; sourceTree = SDKROOT; }; 700C154E217A1344004717EE /* libbz2.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libbz2.tbd; path = usr/lib/libbz2.tbd; sourceTree = SDKROOT; }; 700C1550217A1353004717EE /* libiconv.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libiconv.tbd; path = usr/lib/libiconv.tbd; sourceTree = SDKROOT; }; 700C1552217A135F004717EE /* VideoToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = VideoToolbox.framework; path = System/Library/Frameworks/VideoToolbox.framework; sourceTree = SDKROOT; }; 701DCC8E1F52FD27003ACAB6 /* gzh.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = gzh.jpg; sourceTree = "<group>"; }; 70763C9620CBC54D00DCB7BE /* PlayerDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = PlayerDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; 70763CC520CD4A5400DCB7BE /* MediaPlayer.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MediaPlayer.framework; path = System/Library/Frameworks/MediaPlayer.framework; sourceTree = SDKROOT; }; 70763CC820CD5C9700DCB7BE /* WMLightView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WMLightView.h; sourceTree = "<group>"; }; 70763CC920CD5C9700DCB7BE /* WMPlayerModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WMPlayerModel.m; sourceTree = "<group>"; }; 70763CCA20CD5C9700DCB7BE /* FastForwardView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FastForwardView.h; sourceTree = "<group>"; }; 70763CCE20CD5C9700DCB7BE /* WMPlayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WMPlayer.h; sourceTree = "<group>"; }; 70763CCF20CD5C9700DCB7BE /* WMPlayerModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WMPlayerModel.h; sourceTree = "<group>"; }; 70763CD020CD5C9700DCB7BE /* WMLightView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WMLightView.m; sourceTree = "<group>"; }; 70763CD120CD5C9700DCB7BE /* FastForwardView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FastForwardView.m; sourceTree = "<group>"; }; 70763CD220CD5C9700DCB7BE /* WMPlayer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WMPlayer.m; sourceTree = "<group>"; }; 70763CDA20CD5D0200DCB7BE /* WMPlayer.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; path = WMPlayer.bundle; sourceTree = "<group>"; }; A41F0B6E980617F314AD7227 /* Pods-PlayerDemo.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-PlayerDemo.release.xcconfig"; path = "Pods/Target Support Files/Pods-PlayerDemo/Pods-PlayerDemo.release.xcconfig"; sourceTree = "<group>"; }; AD4E1C1A77CA0A18F1DFB6AE /* Pods-PlayerDemo.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-PlayerDemo.debug.xcconfig"; path = "Pods/Target Support Files/Pods-PlayerDemo/Pods-PlayerDemo.debug.xcconfig"; sourceTree = "<group>"; }; BF1624491DF50011006209D1 /* RootTabBarController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RootTabBarController.h; sourceTree = "<group>"; }; BF16244A1DF50011006209D1 /* RootTabBarController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RootTabBarController.m; sourceTree = "<group>"; }; BF16244B1DF50011006209D1 /* VideoCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VideoCell.h; sourceTree = "<group>"; }; BF16244C1DF50011006209D1 /* VideoCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VideoCell.m; sourceTree = "<group>"; }; BF16244D1DF50011006209D1 /* VideoCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = VideoCell.xib; sourceTree = "<group>"; }; BF16244F1DF50011006209D1 /* BaseNavigationController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BaseNavigationController.h; sourceTree = "<group>"; }; BF1624501DF50011006209D1 /* BaseNavigationController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BaseNavigationController.m; sourceTree = "<group>"; }; BF1624511DF50011006209D1 /* BaseViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BaseViewController.h; sourceTree = "<group>"; }; BF1624521DF50011006209D1 /* BaseViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BaseViewController.m; sourceTree = "<group>"; }; BF1624531DF50011006209D1 /* DetailViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DetailViewController.h; sourceTree = "<group>"; }; BF1624571DF50011006209D1 /* SinaNewsViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SinaNewsViewController.h; sourceTree = "<group>"; }; BF1624581DF50011006209D1 /* SinaNewsViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SinaNewsViewController.m; sourceTree = "<group>"; }; BF16245A1DF50011006209D1 /* TencentNewsViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TencentNewsViewController.h; sourceTree = "<group>"; }; BF16245B1DF50011006209D1 /* TencentNewsViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TencentNewsViewController.m; sourceTree = "<group>"; }; C4EC7F401DF4FCD2006E9820 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; }; C4EC7F421DF4FCD2006E9820 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; }; C4EC7F431DF4FCD2006E9820 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; }; C4EC7F4B1DF4FCD3006E9820 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; }; C4EC7F4E1DF4FCD3006E9820 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; }; C4EC7F501DF4FCD3006E9820 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ C4EC7F391DF4FCD2006E9820 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( 700C1554217A137F004717EE /* libz.tbd in Frameworks */, 700C1553217A135F004717EE /* VideoToolbox.framework in Frameworks */, 700C1551217A1353004717EE /* libiconv.tbd in Frameworks */, 700C154F217A1344004717EE /* libbz2.tbd in Frameworks */, 700C154B217A132B004717EE /* OpenGLES.framework in Frameworks */, 70763CC620CD4A5400DCB7BE /* MediaPlayer.framework in Frameworks */, 507D9D100C07A70640F9F52A /* Pods_PlayerDemo.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ 70763CC720CD5C9700DCB7BE /* WMPlayer */ = { isa = PBXGroup; children = ( 70763CDA20CD5D0200DCB7BE /* WMPlayer.bundle */, 70763CCF20CD5C9700DCB7BE /* WMPlayerModel.h */, 70763CC920CD5C9700DCB7BE /* WMPlayerModel.m */, 70763CCE20CD5C9700DCB7BE /* WMPlayer.h */, 70763CD220CD5C9700DCB7BE /* WMPlayer.m */, 70763CC820CD5C9700DCB7BE /* WMLightView.h */, 70763CD020CD5C9700DCB7BE /* WMLightView.m */, 70763CCA20CD5C9700DCB7BE /* FastForwardView.h */, 70763CD120CD5C9700DCB7BE /* FastForwardView.m */, 1885A0F52472CF2200059B3E /* FullScreenHelperViewController.h */, 1885A0F62472CF2200059B3E /* FullScreenHelperViewController.m */, 18B862FB248BFC2900795947 /* LandscapeLeftViewController.h */, 18B862FA248BFC2900795947 /* LandscapeLeftViewController.m */, 18B862FC248BFC2900795947 /* LandscapeRightViewController.h */, 18B862F9248BFC2900795947 /* LandscapeRightViewController.m */, 1885A1012475490900059B3E /* EnterFullScreenTransition.h */, 1885A1022475490900059B3E /* EnterFullScreenTransition.m */, 1885A1042475492E00059B3E /* ExitFullScreenTransition.h */, 1885A1052475492E00059B3E /* ExitFullScreenTransition.m */, ); path = WMPlayer; sourceTree = SOURCE_ROOT; }; 8AAEEC1312C0C3531902D027 /* Pods */ = { isa = PBXGroup; children = ( AD4E1C1A77CA0A18F1DFB6AE /* Pods-PlayerDemo.debug.xcconfig */, A41F0B6E980617F314AD7227 /* Pods-PlayerDemo.release.xcconfig */, ); name = Pods; sourceTree = "<group>"; }; 9CB412B180A011467ACD0171 /* Frameworks */ = { isa = PBXGroup; children = ( 700C1552217A135F004717EE /* VideoToolbox.framework */, 700C1550217A1353004717EE /* libiconv.tbd */, 700C154E217A1344004717EE /* libbz2.tbd */, 700C154C217A133D004717EE /* libz.tbd */, 700C154A217A132B004717EE /* OpenGLES.framework */, 70763CC520CD4A5400DCB7BE /* MediaPlayer.framework */, 3CDD1E457181DFCA30210454 /* Pods_PlayerDemo.framework */, ); name = Frameworks; sourceTree = "<group>"; }; BF1623B61DF50011006209D1 /* DataManager */ = { isa = PBXGroup; children = ( 18745CFC211D20E80010E46F /* VideoDataModel.h */, 18745CFD211D20E80010E46F /* VideoDataModel.m */, ); path = DataManager; sourceTree = "<group>"; }; BF1624481DF50011006209D1 /* UITabBarController */ = { isa = PBXGroup; children = ( BF1624491DF50011006209D1 /* RootTabBarController.h */, BF16244A1DF50011006209D1 /* RootTabBarController.m */, 18745D05211D57020010E46F /* WMTabBar.h */, 18745D06211D57020010E46F /* WMTabBar.m */, ); path = UITabBarController; sourceTree = "<group>"; }; BF16244E1DF50011006209D1 /* ViewControllers */ = { isa = PBXGroup; children = ( BF16244F1DF50011006209D1 /* BaseNavigationController.h */, BF1624501DF50011006209D1 /* BaseNavigationController.m */, BF1624511DF50011006209D1 /* BaseViewController.h */, BF1624521DF50011006209D1 /* BaseViewController.m */, BF16245A1DF50011006209D1 /* TencentNewsViewController.h */, BF16245B1DF50011006209D1 /* TencentNewsViewController.m */, 18745D02211D3ADC0010E46F /* CameraViewController.h */, 18745D03211D3ADC0010E46F /* CameraViewController.m */, BF1624571DF50011006209D1 /* SinaNewsViewController.h */, BF1624581DF50011006209D1 /* SinaNewsViewController.m */, BF1624531DF50011006209D1 /* DetailViewController.h */, 18A54BF921C3AFED0052670A /* DetailViewController.m */, 181BB5082487FD73003C1FEE /* VCRotateViewController.h */, 181BB5092487FD73003C1FEE /* VCRotateViewController.m */, ); path = ViewControllers; sourceTree = "<group>"; }; C4EC7F331DF4FCD2006E9820 = { isa = PBXGroup; children = ( C4EC7F3E1DF4FCD2006E9820 /* PlayerDemo */, 8AAEEC1312C0C3531902D027 /* Pods */, 9CB412B180A011467ACD0171 /* Frameworks */, 70763C9620CBC54D00DCB7BE /* PlayerDemo.app */, ); sourceTree = "<group>"; }; C4EC7F3E1DF4FCD2006E9820 /* PlayerDemo */ = { isa = PBXGroup; children = ( C4EC7F421DF4FCD2006E9820 /* AppDelegate.h */, C4EC7F431DF4FCD2006E9820 /* AppDelegate.m */, 70763CC720CD5C9700DCB7BE /* WMPlayer */, BF1623B61DF50011006209D1 /* DataManager */, BF1624481DF50011006209D1 /* UITabBarController */, BF16244B1DF50011006209D1 /* VideoCell.h */, BF16244C1DF50011006209D1 /* VideoCell.m */, BF16244D1DF50011006209D1 /* VideoCell.xib */, 18745CFF211D283B0010E46F /* HomeVideoCollectionViewCell.h */, 18745D00211D283B0010E46F /* HomeVideoCollectionViewCell.m */, BF16244E1DF50011006209D1 /* ViewControllers */, C4EC7F4B1DF4FCD3006E9820 /* Assets.xcassets */, C4EC7F4D1DF4FCD3006E9820 /* LaunchScreen.storyboard */, C4EC7F501DF4FCD3006E9820 /* Info.plist */, C4EC7F3F1DF4FCD2006E9820 /* Supporting Files */, ); path = PlayerDemo; sourceTree = "<group>"; }; C4EC7F3F1DF4FCD2006E9820 /* Supporting Files */ = { isa = PBXGroup; children = ( 701DCC8E1F52FD27003ACAB6 /* gzh.jpg */, C4EC7F401DF4FCD2006E9820 /* main.m */, ); name = "Supporting Files"; sourceTree = "<group>"; }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ C4EC7F3B1DF4FCD2006E9820 /* PlayerDemo */ = { isa = PBXNativeTarget; buildConfigurationList = C4EC7F531DF4FCD3006E9820 /* Build configuration list for PBXNativeTarget "PlayerDemo" */; buildPhases = ( D4D31148F85F770E5848B158 /* [CP] Check Pods Manifest.lock */, C4EC7F381DF4FCD2006E9820 /* Sources */, C4EC7F391DF4FCD2006E9820 /* Frameworks */, C4EC7F3A1DF4FCD2006E9820 /* Resources */, E6EC241C6DCD1D5BE4DA5E68 /* [CP] Embed Pods Frameworks */, ); buildRules = ( ); dependencies = ( ); name = PlayerDemo; productName = PlayerDemo; productReference = 70763C9620CBC54D00DCB7BE /* PlayerDemo.app */; productType = "com.apple.product-type.application"; }; /* End PBXNativeTarget section */ /* Begin PBXProject section */ C4EC7F341DF4FCD2006E9820 /* Project object */ = { isa = PBXProject; attributes = { LastUpgradeCheck = 1420; ORGANIZATIONNAME = "DS-Team"; TargetAttributes = { C4EC7F3B1DF4FCD2006E9820 = { CreatedOnToolsVersion = 7.2; DevelopmentTeam = 7D992WX2BB; }; }; }; buildConfigurationList = C4EC7F371DF4FCD2006E9820 /* Build configuration list for PBXProject "PlayerDemo" */; compatibilityVersion = "Xcode 3.2"; developmentRegion = en; hasScannedForEncodings = 0; knownRegions = ( en, Base, "zh-Hans", ); mainGroup = C4EC7F331DF4FCD2006E9820; productRefGroup = C4EC7F331DF4FCD2006E9820; projectDirPath = ""; projectRoot = ""; targets = ( C4EC7F3B1DF4FCD2006E9820 /* PlayerDemo */, ); }; /* End PBXProject section */ /* Begin PBXResourcesBuildPhase section */ C4EC7F3A1DF4FCD2006E9820 /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( C4EC7F4F1DF4FCD3006E9820 /* LaunchScreen.storyboard in Resources */, C4EC7F4C1DF4FCD3006E9820 /* Assets.xcassets in Resources */, BF1624AA1DF50011006209D1 /* VideoCell.xib in Resources */, 701DCC8F1F52FD27003ACAB6 /* gzh.jpg in Resources */, 70763CDE20CD5D0200DCB7BE /* WMPlayer.bundle in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ D4D31148F85F770E5848B158 /* [CP] Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputPaths = ( "${PODS_PODFILE_DIR_PATH}/Podfile.lock", "${PODS_ROOT}/Manifest.lock", ); name = "[CP] Check Pods Manifest.lock"; outputPaths = ( "$(DERIVED_FILE_DIR)/Pods-PlayerDemo-checkManifestLockResult.txt", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; E6EC241C6DCD1D5BE4DA5E68 /* [CP] Embed Pods Frameworks */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputPaths = ( "${PODS_ROOT}/Target Support Files/Pods-PlayerDemo/Pods-PlayerDemo-frameworks.sh", "${BUILT_PRODUCTS_DIR}/AFNetworking/AFNetworking.framework", "${BUILT_PRODUCTS_DIR}/GPUImage/GPUImage.framework", "${BUILT_PRODUCTS_DIR}/MJRefresh/MJRefresh.framework", "${BUILT_PRODUCTS_DIR}/Masonry/Masonry.framework", "${BUILT_PRODUCTS_DIR}/SDWebImage/SDWebImage.framework", "${BUILT_PRODUCTS_DIR}/TZImagePickerController/TZImagePickerController.framework", ); name = "[CP] Embed Pods Frameworks"; outputPaths = ( "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/AFNetworking.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/GPUImage.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MJRefresh.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Masonry.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SDWebImage.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/TZImagePickerController.framework", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-PlayerDemo/Pods-PlayerDemo-frameworks.sh\"\n"; showEnvVarsInLog = 0; }; /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ C4EC7F381DF4FCD2006E9820 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( BF1624A81DF50011006209D1 /* RootTabBarController.m in Sources */, 1885A1032475490900059B3E /* EnterFullScreenTransition.m in Sources */, 18745CFE211D20E80010E46F /* VideoDataModel.m in Sources */, 1885A1062475492E00059B3E /* ExitFullScreenTransition.m in Sources */, 70763CD820CD5C9700DCB7BE /* FastForwardView.m in Sources */, 18B862FE248BFC2900795947 /* LandscapeLeftViewController.m in Sources */, BF1624A91DF50011006209D1 /* VideoCell.m in Sources */, 18A54BFA21C3AFED0052670A /* DetailViewController.m in Sources */, 18745D01211D283B0010E46F /* HomeVideoCollectionViewCell.m in Sources */, BF1624AC1DF50011006209D1 /* BaseViewController.m in Sources */, 70763CD720CD5C9700DCB7BE /* WMLightView.m in Sources */, BF1624B11DF50011006209D1 /* TencentNewsViewController.m in Sources */, BF1624AF1DF50011006209D1 /* SinaNewsViewController.m in Sources */, 70763CD920CD5C9700DCB7BE /* WMPlayer.m in Sources */, 181BB50A2487FD73003C1FEE /* VCRotateViewController.m in Sources */, 18745D04211D3ADC0010E46F /* CameraViewController.m in Sources */, C4EC7F441DF4FCD2006E9820 /* AppDelegate.m in Sources */, BF1624AB1DF50011006209D1 /* BaseNavigationController.m in Sources */, 18745D07211D57020010E46F /* WMTabBar.m in Sources */, 70763CD420CD5C9700DCB7BE /* WMPlayerModel.m in Sources */, 1885A0F72472CF2200059B3E /* FullScreenHelperViewController.m in Sources */, 18B862FD248BFC2900795947 /* LandscapeRightViewController.m in Sources */, C4EC7F411DF4FCD2006E9820 /* main.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXSourcesBuildPhase section */ /* Begin PBXVariantGroup section */ C4EC7F4D1DF4FCD3006E9820 /* LaunchScreen.storyboard */ = { isa = PBXVariantGroup; children = ( C4EC7F4E1DF4FCD3006E9820 /* Base */, ); name = LaunchScreen.storyboard; sourceTree = "<group>"; }; /* End PBXVariantGroup section */ /* Begin XCBuildConfiguration section */ C4EC7F511DF4FCD3006E9820 /* 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; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 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_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; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Debug; }; C4EC7F521DF4FCD3006E9820 /* 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 = NO; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 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; TARGETED_DEVICE_FAMILY = "1,2"; VALIDATE_PRODUCT = YES; }; name = Release; }; C4EC7F541DF4FCD3006E9820 /* Debug */ = { isa = XCBuildConfiguration; baseConfigurationReference = AD4E1C1A77CA0A18F1DFB6AE /* Pods-PlayerDemo.debug.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES = NO; DEVELOPMENT_TEAM = 7D992WX2BB; ENABLE_BITCODE = NO; HEADER_SEARCH_PATHS = "$(PROJECT_DIR)/WMPlayer/WNPlayer/FFmpeg/include"; INFOPLIST_FILE = PlayerDemo/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 12.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; LIBRARY_SEARCH_PATHS = ( "$(inherited)", "$(PROJECT_DIR)/WMPlayer/WNPlayer/FFmpeg/lib", "$(PROJECT_DIR)/WMPlayer/WNPlayer/openssl/lib", ); PRODUCT_BUNDLE_IDENTIFIER = com.asiainfo.wenming; PRODUCT_NAME = "$(TARGET_NAME)"; TARGETED_DEVICE_FAMILY = 1; USER_HEADER_SEARCH_PATHS = "$(PODS_ROOT)/**"; }; name = Debug; }; C4EC7F551DF4FCD3006E9820 /* Release */ = { isa = XCBuildConfiguration; baseConfigurationReference = A41F0B6E980617F314AD7227 /* Pods-PlayerDemo.release.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES = NO; DEVELOPMENT_TEAM = 7D992WX2BB; ENABLE_BITCODE = NO; GCC_GENERATE_DEBUGGING_SYMBOLS = NO; HEADER_SEARCH_PATHS = "$(PROJECT_DIR)/WMPlayer/WNPlayer/FFmpeg/include"; INFOPLIST_FILE = PlayerDemo/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 12.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; LIBRARY_SEARCH_PATHS = ( "$(inherited)", "$(PROJECT_DIR)/WMPlayer/WNPlayer/FFmpeg/lib", "$(PROJECT_DIR)/WMPlayer/WNPlayer/openssl/lib", ); PRODUCT_BUNDLE_IDENTIFIER = com.asiainfo.wenming; PRODUCT_NAME = "$(TARGET_NAME)"; TARGETED_DEVICE_FAMILY = 1; USER_HEADER_SEARCH_PATHS = "$(PODS_ROOT)/**"; }; name = Release; }; /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ C4EC7F371DF4FCD2006E9820 /* Build configuration list for PBXProject "PlayerDemo" */ = { isa = XCConfigurationList; buildConfigurations = ( C4EC7F511DF4FCD3006E9820 /* Debug */, C4EC7F521DF4FCD3006E9820 /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; C4EC7F531DF4FCD3006E9820 /* Build configuration list for PBXNativeTarget "PlayerDemo" */ = { isa = XCConfigurationList; buildConfigurations = ( C4EC7F541DF4FCD3006E9820 /* Debug */, C4EC7F551DF4FCD3006E9820 /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; /* End XCConfigurationList section */ }; rootObject = C4EC7F341DF4FCD2006E9820 /* Project object */; } ```
/content/code_sandbox/PlayerDemo.xcodeproj/project.pbxproj
unknown
2016-02-02T02:51:55
2024-08-09T08:55:27
WMPlayer
zhengwenming/WMPlayer
3,272
11,904
```unknown <?xml version="1.0" encoding="UTF-8"?> <Workspace version = "1.0"> <FileRef location = "self:PlayerDemo.xcodeproj"> </FileRef> </Workspace> ```
/content/code_sandbox/PlayerDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata
unknown
2016-02-02T02:51:55
2024-08-09T08:55:27
WMPlayer
zhengwenming/WMPlayer
3,272
51
```objective-c // // EditVideoViewController.m // iShow // // Created by on 17/3/8. // // #import "EditVideoViewController.h" #import <AVFoundation/AVFoundation.h> #import "Masonry.h" #import "UIView+Tools.h" #import "MusicItemCollectionViewCell.h" #import "WMPlayer.h" #import "AFNetworking.h" #import "MBProgressHUD.h" #import "SDAVAssetExportSession.h" #import "GPUImage.h" #import "LFGPUImageEmptyFilter.h" #import "EditingPublishingDynamicViewController.h" #define SCREEN_WIDTH [UIScreen mainScreen].bounds.size.width #define SCREEN_HEIGHT [UIScreen mainScreen].bounds.size.height #define SCREEN_LayoutScaleBaseOnIPHEN6(x) (([UIScreen mainScreen].bounds.size.width)/375.00 * x) @interface MusicData : NSObject @property (nonatomic,strong) NSString* name; @property (nonatomic,strong) NSString* eid; @property (nonatomic,strong) NSString* musicPath; @property (nonatomic,strong) NSString* iconPath; @property (nonatomic,assign) BOOL isSelected; @end @implementation MusicData @end @interface FilterData : NSObject @property (nonatomic,strong) NSString* name; @property (nonatomic,strong) NSString* value; @property (nonatomic,strong) NSString* fillterName; @property (nonatomic,strong) NSString* iconPath; @property (nonatomic,assign) BOOL isSelected; @end @implementation FilterData @end @interface StickersData : NSObject @property (nonatomic,strong) NSString* name; @property (nonatomic,strong) NSString* StickersImgPaht; @property (nonatomic,assign) BOOL isSelected; @end @implementation StickersData @end typedef NS_ENUM(NSUInteger , choseType) { choseFilter = 1, // choseMusic = 2, choseStickers = 3,// }; @interface EditVideoViewController ()<UITextFieldDelegate,UICollectionViewDelegate,UICollectionViewDataSource> @property (nonatomic, strong) AVPlayer *audioPlayer; @property (nonatomic, strong) NSMutableArray* musicAry; @property (nonatomic, strong) NSMutableArray* filterAry; @property (nonatomic, strong) NSMutableArray* stickersAry; @property (nonatomic,strong) UIVisualEffectView *visualEffectView; @property (nonatomic,strong) UIView* musicBottomBar; @property (nonatomic,strong) NSString* audioPath; @property (nonatomic,strong) UIButton* musicBtn; @property (nonatomic ,strong) NSString* filtClassName; @property (nonatomic ,assign) BOOL isdoing; @property (nonatomic, assign) choseType choseEditType; @property (nonatomic ,strong) UICollectionView *musicCollectionView; @property (nonatomic ,strong) UICollectionView *collectionView; @property (nonatomic ,strong) UICollectionView *stickersCollectionView; @property (nonatomic ,strong) UIButton* cancleBtn; @property (nonatomic ,strong) UIButton* okBtn; @property (nonatomic ,strong) UIButton* stickersBtn; @property (nonatomic ,strong) UIButton* editTheOriginaBtn; @property (nonatomic ,strong) UISwitch* editTheOriginaSwitch; @property (nonatomic ,strong) GPUImageView *filterView; @property (nonatomic ,assign) float saturationValue; @property (nonatomic ,strong) NSIndexPath* lastMusicIndex; @property (nonatomic ,strong) NSIndexPath* nowMusicIndex; @property (nonatomic ,strong) NSIndexPath* lastFilterIndex; @property (nonatomic ,strong) NSIndexPath* nowFilterIndex; @property (nonatomic ,strong) NSIndexPath* lastStickersIndex; @property (nonatomic ,strong) NSIndexPath* nowStickersIndex; @property (nonatomic ,strong) UIImageView* bgImageView; @property (nonatomic ,strong) UIImageView* stickersImgView; @end @implementation EditVideoViewController { GPUImageMovie *movieFile; GPUImageMovie* endMovieFile; GPUImageOutput<GPUImageInput> *filter; AVPlayerItem *audioPlayerItem; UIImageView* playImg; MBProgressHUD*HUD; AVPlayer *mainPlayer; AVPlayerLayer *playerLayer; AVPlayerItem *playerItem; GPUImageMovieWriter *movieWriter; } @synthesize videoURL; - (void)viewDidUnload { [super viewDidUnload]; } - (void)viewDidLoad { [super viewDidLoad]; self.navigationController.navigationBarHidden = YES; _musicAry = [NSMutableArray arrayWithArray:[self creatMusicData]]; _filterAry = [NSMutableArray arrayWithArray:[self creatFilterData]]; _stickersAry = [NSMutableArray arrayWithArray:[self creatStickersData]]; _audioPlayer = [[AVPlayer alloc ]init]; _lastMusicIndex = [NSIndexPath indexPathForRow:0 inSection:0]; _lastFilterIndex = [NSIndexPath indexPathForRow:0 inSection:0]; _lastStickersIndex = [NSIndexPath indexPathForRow:0 inSection:0]; [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayAndRecord withOptions:AVAudioSessionCategoryOptionMixWithOthers error:nil]; // [self playMusic]; self.view.backgroundColor = [UIColor blackColor]; self.title = @""; float videoWidth = self.view.frame.size.width; mainPlayer = [[AVPlayer alloc] init]; playerItem = [[AVPlayerItem alloc] initWithURL:videoURL]; [mainPlayer replaceCurrentItemWithPlayerItem:playerItem]; playerLayer = [AVPlayerLayer playerLayerWithPlayer:mainPlayer]; movieFile = [[GPUImageMovie alloc] initWithPlayerItem:playerItem]; movieFile.runBenchmark = YES; movieFile.playAtActualSpeed = YES; filter = [[LFGPUImageEmptyFilter alloc] init]; _filtClassName = @"LFGPUImageEmptyFilter"; [movieFile addTarget:filter]; _filterView = [[GPUImageView alloc] initWithFrame:self.view.bounds]; [self.view addSubview:_filterView]; [filter addTarget:_filterView]; _bgImageView = [[UIImageView alloc] init]; // _bgImageView.image = [[AppDelegate appDelegate].cmImageSize getImage:[[videoURL absoluteString ] stringByReplacingOccurrencesOfString:@"file://" withString:@""]]; [self.view addSubview:_bgImageView]; [_bgImageView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.bottom.left.right.equalTo(self.view); }]; UIImageView* PlayImge = [[UIImageView alloc] init]; PlayImge.image = [UIImage imageNamed:@"-1"]; [_bgImageView addSubview:PlayImge]; [PlayImge mas_makeConstraints:^(MASConstraintMaker *make) { make.center.equalTo(_bgImageView); make.width.height.equalTo(@(SCREEN_LayoutScaleBaseOnIPHEN6(60))); }]; playImg = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 40, 40)]; playImg.center = CGPointMake(videoWidth/2, videoWidth/2); [playImg setImage:[UIImage imageNamed:@"videoPlay"]]; [playerLayer addSublayer:playImg.layer]; playImg.hidden = YES; //create ui UIView* superView = self.view; _stickersImgView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 150, 150)]; _stickersImgView.center = CGPointMake(SCREEN_WIDTH/2, SCREEN_HEIGHT/2); _stickersImgView.hidden = YES; [self.view addSubview:_stickersImgView]; [_stickersImgView setUserInteractionEnabled:YES]; [_stickersImgView setMultipleTouchEnabled:YES]; UIPanGestureRecognizer *panGestureRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(panView:)]; [_stickersImgView addGestureRecognizer:panGestureRecognizer]; UIView* headerBar = [[UIView alloc] init]; headerBar.backgroundColor = [UIColor redColor]; [self.view addSubview:headerBar]; headerBar.backgroundColor = [UIColor blackColor]; [headerBar mas_makeConstraints:^(MASConstraintMaker *make) { make.left.right.equalTo(self.view); make.top.equalTo(self.view).offset([WMPlayer IsiPhoneX]?44:0); make.height.equalTo(@(44)); }]; headerBar.alpha = .8; UILabel* titleLabel = [[UILabel alloc] init]; titleLabel.text = @""; titleLabel.textColor = [UIColor whiteColor]; [headerBar addSubview:titleLabel]; [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.centerX.centerY.equalTo(headerBar); }]; // UIButton* backBtn = [[UIButton alloc] init]; // backBtn setImage:<#(nullable UIImage *)#> forState:<#(UIControlState)#> UIButton* nextBtn = [[UIButton alloc] init]; [nextBtn setTitle:@"" forState:UIControlStateNormal]; [nextBtn.titleLabel setFont:[UIFont systemFontOfSize:15]]; [nextBtn addTarget:self action:@selector(clickNextBtn) forControlEvents:UIControlEventTouchUpInside]; [headerBar addSubview:nextBtn]; [nextBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.top.right.bottom.equalTo(headerBar); make.width.equalTo(@(80)); }]; UIButton* BackToVideoCammer = [[UIButton alloc] init]; [BackToVideoCammer setImage:[UIImage imageNamed:@"BackToVideoCammer"] forState:UIControlStateNormal]; [BackToVideoCammer addTarget:self action:@selector(clickBackToVideoCammer) forControlEvents:UIControlEventTouchUpInside]; [headerBar addSubview:BackToVideoCammer]; [BackToVideoCammer mas_makeConstraints:^(MASConstraintMaker *make) { make.top.left.bottom.equalTo(headerBar); make.width.equalTo(@(60)); }]; _musicBottomBar = [[UIView alloc] init]; [self.view addSubview:_musicBottomBar]; [_musicBottomBar mas_makeConstraints:^(MASConstraintMaker *make) { make.bottom.equalTo(superView)/*.offset(160)*/; make.left.right.equalTo(superView); make.height.equalTo(@(160)); }]; UIBlurEffect *blurEffrct =[UIBlurEffect effectWithStyle:UIBlurEffectStyleDark]; // _visualEffectView = [[UIVisualEffectView alloc]initWithEffect:blurEffrct]; // _visualEffectView.alpha = 1; [_musicBottomBar addSubview:_visualEffectView]; [_visualEffectView mas_makeConstraints:^(MASConstraintMaker *make) { make.right.left.top.bottom.equalTo(_musicBottomBar); }]; _cancleBtn = [[UIButton alloc] init]; [_cancleBtn setTitle:@"" forState:UIControlStateNormal]; [_cancleBtn.titleLabel setFont:[UIFont systemFontOfSize:15]]; [_cancleBtn setTitleColor:[UIColor colorWithRed:250/256.0 green:211/256.0 blue:75/256.0 alpha:1] forState:UIControlStateSelected]; [_cancleBtn setTitleColor:[UIColor grayColor] forState:UIControlStateNormal]; _cancleBtn.backgroundColor = [UIColor clearColor]; [_cancleBtn addTarget:self action:@selector(clickCancleBtn) forControlEvents:UIControlEventTouchUpInside]; [_musicBottomBar addSubview:_cancleBtn]; [_cancleBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.top.left.equalTo(_musicBottomBar); make.height.equalTo(@(45)); make.width.equalTo(@(SCREEN_LayoutScaleBaseOnIPHEN6(83))); }]; _cancleBtn.selected = YES; self.choseEditType = choseFilter; _okBtn = [[UIButton alloc] init]; [_okBtn setTitle:@"" forState:UIControlStateNormal]; [_okBtn.titleLabel setFont:[UIFont systemFontOfSize:15]]; [_okBtn setTitleColor:[UIColor colorWithRed:250/256.0 green:211/256.0 blue:75/256.0 alpha:1] forState:UIControlStateSelected]; [_okBtn setTitleColor:[UIColor grayColor] forState:UIControlStateNormal]; _okBtn.backgroundColor = [UIColor clearColor]; [_okBtn addTarget:self action:@selector(clickOKBtn) forControlEvents:UIControlEventTouchUpInside]; [_musicBottomBar addSubview:_okBtn]; [_okBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(_musicBottomBar); make.left.equalTo(_cancleBtn.mas_right).offset(0); make.height.equalTo(@(45)); make.width.equalTo(@(SCREEN_LayoutScaleBaseOnIPHEN6(83))); }]; _stickersBtn = [[UIButton alloc] init]; [_stickersBtn setTitle:@"" forState:UIControlStateNormal]; [_stickersBtn.titleLabel setFont:[UIFont systemFontOfSize:15]]; [_stickersBtn setTitleColor:[UIColor colorWithRed:250/256.0 green:211/256.0 blue:75/256.0 alpha:1] forState:UIControlStateSelected]; [_stickersBtn setTitleColor:[UIColor grayColor] forState:UIControlStateNormal]; _stickersBtn.backgroundColor = [UIColor clearColor]; [_stickersBtn addTarget:self action:@selector(clickStickersBtn) forControlEvents:UIControlEventTouchUpInside]; [_musicBottomBar addSubview:_stickersBtn]; [_stickersBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(_musicBottomBar); make.left.equalTo(_okBtn.mas_right).offset(0); make.height.equalTo(@(45)); make.width.equalTo(@(SCREEN_LayoutScaleBaseOnIPHEN6(83))); }]; _editTheOriginaSwitch = [[UISwitch alloc] init]; _editTheOriginaSwitch.onTintColor = [UIColor colorWithRed:253.0 / 255 green:215.0 / 255 blue:4.0 / 255 alpha:1.0]; [_editTheOriginaSwitch addTarget:self action:@selector(clickEditOriginalBtn) forControlEvents:UIControlEventTouchUpInside]; [_musicBottomBar addSubview:_editTheOriginaSwitch]; [_editTheOriginaSwitch mas_makeConstraints:^(MASConstraintMaker *make) { make.centerY.equalTo(_okBtn); make.right.equalTo(_musicBottomBar).offset(-8); make.height.equalTo(@(30)); make.width.equalTo(@(50)); }]; _editTheOriginaSwitch.hidden = YES; _editTheOriginaBtn = [[UIButton alloc] init]; [_editTheOriginaBtn setTitle:@"" forState:UIControlStateNormal]; [_editTheOriginaBtn.titleLabel setFont:[UIFont systemFontOfSize:15]]; [_editTheOriginaBtn setTitleColor:[UIColor colorWithRed:250/256.0 green:211/256.0 blue:75/256.0 alpha:1] forState:UIControlStateSelected]; [_editTheOriginaBtn setTitleColor:[UIColor grayColor] forState:UIControlStateNormal]; _editTheOriginaBtn.backgroundColor = [UIColor clearColor]; // [_editTheOriginaBtn addTarget:self action:@selector(clickEditOriginalBtn) forControlEvents:UIControlEventTouchUpInside]; [_musicBottomBar addSubview:_editTheOriginaBtn]; [_editTheOriginaBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(_musicBottomBar); make.right.equalTo(_editTheOriginaSwitch.mas_left).offset(0); make.height.equalTo(@(45)); make.width.equalTo(@(SCREEN_LayoutScaleBaseOnIPHEN6(83))); }]; _editTheOriginaBtn.hidden = YES; UIView* lineView = [[UIView alloc] init]; lineView.backgroundColor = [UIColor grayColor]; [_musicBottomBar addSubview:lineView]; [lineView mas_makeConstraints:^(MASConstraintMaker *make) { make.bottom.equalTo(_okBtn); make.left.right.equalTo(_musicBottomBar); make.height.equalTo(@(.5)); }]; //collectionView UICollectionViewFlowLayout* layout = [[UICollectionViewFlowLayout alloc] init]; layout.itemSize = CGSizeMake(83, 115); layout.estimatedItemSize = CGSizeMake(83, 115); // // layout.sectionFootersPinToVisibleBounds = YES; // layout.sectionHeadersPinToVisibleBounds = YES; // // layout.scrollDirection = UICollectionViewScrollDirectionHorizontal; // layout.sectionInset = UIEdgeInsetsMake(0, 0, 0, 0); // cell //, :() layout.minimumInteritemSpacing = 0; // layout.minimumLineSpacing = 0; _collectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 45, SCREEN_WIDTH, 115) collectionViewLayout:layout]; // _collectionView.backgroundColor = [UIColor clearColor]; // , _collectionView.dataSource = self; //, _collectionView.delegate = self; // cell [_collectionView registerClass:[MusicItemCollectionViewCell class] forCellWithReuseIdentifier:@"MyCollectionCell"]; /* UICollectionView */ // _collectionView.showsHorizontalScrollIndicator = NO; _collectionView.showsVerticalScrollIndicator = NO; // _collectionView.bounces = YES; [_musicBottomBar addSubview:_collectionView]; //collectionView UICollectionViewFlowLayout* layout2 = [[UICollectionViewFlowLayout alloc] init]; layout2.itemSize = CGSizeMake(83, 115); layout2.estimatedItemSize = CGSizeMake(83, 115); // // layout2.sectionFootersPinToVisibleBounds = YES; // layout2.sectionHeadersPinToVisibleBounds = YES; // // layout2.scrollDirection = UICollectionViewScrollDirectionHorizontal; // layout2.sectionInset = UIEdgeInsetsMake(0, 0, 0, 0); // cell //, :() layout2.minimumInteritemSpacing = 0; // layout2.minimumLineSpacing = 0; _musicCollectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 45, SCREEN_WIDTH, 115) collectionViewLayout:layout2]; // _musicCollectionView.backgroundColor = [UIColor clearColor]; // , _musicCollectionView.dataSource = self; //, _musicCollectionView.delegate = self; // cell [_musicCollectionView registerClass:[MusicItemCollectionViewCell class] forCellWithReuseIdentifier:@"MyCollectionCell2"]; /* UICollectionView */ // _musicCollectionView.showsHorizontalScrollIndicator = NO; _musicCollectionView.showsVerticalScrollIndicator = NO; // _musicCollectionView.bounces = YES; [_musicBottomBar addSubview:_musicCollectionView]; _musicCollectionView.hidden = YES; //collectionView UICollectionViewFlowLayout* layout3 = [[UICollectionViewFlowLayout alloc] init]; layout3.itemSize = CGSizeMake(83, 115); layout3.estimatedItemSize = CGSizeMake(83, 115); // // layout2.sectionFootersPinToVisibleBounds = YES; // layout2.sectionHeadersPinToVisibleBounds = YES; // // layout3.scrollDirection = UICollectionViewScrollDirectionHorizontal; // layout3.sectionInset = UIEdgeInsetsMake(0, 0, 0, 0); // cell //, :() layout3.minimumInteritemSpacing = 0; // layout3.minimumLineSpacing = 0; _stickersCollectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 45, SCREEN_WIDTH, 115) collectionViewLayout:layout3]; // _stickersCollectionView.backgroundColor = [UIColor clearColor]; // , _stickersCollectionView.dataSource = self; //, _stickersCollectionView.delegate = self; // cell [_stickersCollectionView registerClass:[MusicItemCollectionViewCell class] forCellWithReuseIdentifier:@"MyCollectionCell3"]; /* UICollectionView */ // _stickersCollectionView.showsHorizontalScrollIndicator = NO; _stickersCollectionView.showsVerticalScrollIndicator = NO; // _stickersCollectionView.bounces = YES; [_musicBottomBar addSubview:_stickersCollectionView]; _stickersCollectionView.hidden = YES; HUD = [MBProgressHUD showHUDAddedTo:self.view animated:YES]; HUD.hidden = YES; // } -(void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ [mainPlayer play]; [movieFile startProcessing]; }); dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ _bgImageView.hidden = YES; }); [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(playingEnd:) name:AVPlayerItemDidPlayToEndTimeNotification object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onApplicationWillResignActive) name:UIApplicationWillResignActiveNotification object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onApplicationDidBecomeActive) name:UIApplicationDidBecomeActiveNotification object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(notCloseCor) name:@"closeVideoCamerTwo" object:nil]; } - (void)compressVideoWithInputVideoUrl:(NSURL *) inputVideoUrl { /* Create Output File Url */ NSString *documentsDirectory = NSTemporaryDirectory(); NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; formatter.dateFormat = @"yyyyMMddHHmmss"; NSString *nowTimeStr = [formatter stringFromDate:[NSDate dateWithTimeIntervalSinceNow:0]]; NSString *finalVideoURLString = [documentsDirectory stringByAppendingPathComponent:[NSString stringWithFormat:@"compressedVideo%@.mp4",nowTimeStr]]; NSURL *outputVideoUrl = ([[NSURL URLWithString:finalVideoURLString] isFileURL] == 1)?([NSURL URLWithString:finalVideoURLString]):([NSURL fileURLWithPath:finalVideoURLString]); // Url Should be a file Url, so here we check and convert it into a file Url NSDictionary* options = @{AVURLAssetPreferPreciseDurationAndTimingKey:@YES}; AVAsset* asset = [AVURLAsset URLAssetWithURL:inputVideoUrl options:options]; NSArray* keys = @[@"tracks",@"duration",@"commonMetadata"]; [asset loadValuesAsynchronouslyForKeys:keys completionHandler:^{ SDAVAssetExportSession *compressionEncoder = [SDAVAssetExportSession.alloc initWithAsset:asset]; // provide inputVideo Url Here compressionEncoder.outputFileType = AVFileTypeMPEG4; compressionEncoder.outputURL = outputVideoUrl; //Provide output video Url here compressionEncoder.videoSettings = @ { AVVideoCodecKey: AVVideoCodecH264, AVVideoWidthKey: @720, //Set your resolution width here AVVideoHeightKey: @1280, //set your resolution height here AVVideoCompressionPropertiesKey: @ { //2000*1000 800*1000-5000*1000 //AVVideoAverageBitRateKey: @2500000, // Give your bitrate here for lower size give low values AVVideoAverageBitRateKey: _bit, AVVideoProfileLevelKey: AVVideoProfileLevelH264HighAutoLevel, AVVideoAverageNonDroppableFrameRateKey: _frameRate, }, }; compressionEncoder.audioSettings = @ { AVFormatIDKey: @(kAudioFormatMPEG4AAC), AVNumberOfChannelsKey: @2, AVSampleRateKey: @44100, AVEncoderBitRateKey: @128000, }; [compressionEncoder exportAsynchronouslyWithCompletionHandler:^ { dispatch_async(dispatch_get_main_queue(), ^{ //UI //..... if (compressionEncoder.status == AVAssetExportSessionStatusCompleted) { dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ HUD.hidden = YES; [[NSNotificationCenter defaultCenter] removeObserver:self]; EditingPublishingDynamicViewController* cor = [[EditingPublishingDynamicViewController alloc] init]; cor.videoURL = compressionEncoder.outputURL; // [[AppDelegate appDelegate] pushViewController:cor animated:YES]; [self.navigationController pushViewController:cor animated:YES]; }); } else if (compressionEncoder.status == AVAssetExportSessionStatusCancelled) { HUD.labelText = @"Compression Failed"; dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ [[NSNotificationCenter defaultCenter] removeObserver:self]; // [[NSNotificationCenter defaultCenter] postNotificationName:kTabBarHiddenNONotification object:self]; [self.navigationController popToRootViewControllerAnimated:YES]; }); } else { HUD.labelText = @"ompression Failed"; dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ [[NSNotificationCenter defaultCenter] removeObserver:self]; // [[NSNotificationCenter defaultCenter] postNotificationName:kTabBarHiddenNONotification object:self]; [self.navigationController popToRootViewControllerAnimated:YES]; }); } }); }]; }]; } -(void)clickBackToVideoCammer { [[NSNotificationCenter defaultCenter] removeObserver:self]; [self.navigationController popViewControllerAnimated:YES]; } -(void)clickNextBtn { HUD.hidden = NO; if ([_filtClassName isEqualToString:@"LFGPUImageEmptyFilter"]) { // if (_audioPath||!_stickersImgView.hidden) { // [self mixAudioAndVidoWithInputURL:videoURL]; }else { HUD.labelText = @"..."; [self compressVideoWithInputVideoUrl:videoURL]; } }else { // [self mixFiltWithVideoAndInputVideoURL:videoURL]; } } // -(void)mixFiltWithVideoAndInputVideoURL:(NSURL*)inputURL; { HUD.labelText = @"..."; _isdoing = YES; NSURL *sampleURL = inputURL; endMovieFile = [[GPUImageMovie alloc] initWithURL:sampleURL]; endMovieFile.runBenchmark = YES; endMovieFile.playAtActualSpeed = NO; GPUImageOutput<GPUImageInput> *endFilter; if ([_filtClassName isEqualToString:@"GPUImageSaturationFilter"]) { GPUImageSaturationFilter* xxxxfilter = [[NSClassFromString(_filtClassName) alloc] init]; xxxxfilter.saturation = _saturationValue; endFilter = xxxxfilter; }else{ endFilter = [[NSClassFromString(_filtClassName) alloc] init]; } [endMovieFile addTarget:endFilter]; NSString *pathToMovie = [NSHomeDirectory() stringByAppendingPathComponent:@"tmp/Movie.mp4"]; unlink([pathToMovie UTF8String]); // If a file already exists, AVAssetWriter won't let you record new frames, so delete the old movie NSURL *movieURL = [NSURL fileURLWithPath:pathToMovie]; movieWriter = [[GPUImageMovieWriter alloc] initWithMovieURL:movieURL size:CGSizeMake(720.0, 1280.0)]; [endFilter addTarget:movieWriter]; movieWriter.shouldPassthroughAudio = YES; endMovieFile.audioEncodingTarget = movieWriter; [endMovieFile enableSynchronizedEncodingUsingMovieWriter:movieWriter]; [movieWriter startRecording]; [endMovieFile startProcessing]; __block __weak GPUImageMovieWriter *weakmovieWriter = movieWriter; // __weak MBProgressHUD *weakHUD = HUD; typeof(self) __weak weakself = self; [movieWriter setCompletionBlock:^{ [endFilter removeTarget:weakmovieWriter]; [weakmovieWriter finishRecording]; weakmovieWriter = nil; if (weakself.audioPath||!weakself.stickersImgView.hidden) { [weakself mixAudioAndVidoWithInputURL:movieURL]; // }else { // [weakself compressVideoWithInputVideoUrl:movieURL]; } }]; } -(void)mixAudioAndVidoWithInputURL:(NSURL*)inputURL; { if (_audioPath) { [self mixAudioAndVidoWithInputURL2:inputURL]; }else { [self mixAudioAndVidoWithInputURL1:inputURL]; } // // audio529 // // // // HUD.labelText = @"..."; // NSString *documents = [NSHomeDirectory() stringByAppendingPathComponent:@"tmp"]; // // // // // // NSURL *audioInputUrl = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"audio529" ofType:@"mp3"]]; // // NSURL *audioInputUrl = [NSURL fileURLWithPath:_audioPath]; // // // // // NSURL *videoInputUrl = inputURL; // // // // //// NSString *outPutFilePath = [documents stringByAppendingPathComponent:@"videoandoudio.mov"]; // // // // // // // NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; // formatter.dateFormat = @"yyyyMMddHHmmss"; // NSString *nowTimeStr = [formatter stringFromDate:[NSDate dateWithTimeIntervalSinceNow:0]]; // NSString *fileName = [[documents stringByAppendingPathComponent:nowTimeStr] stringByAppendingString:@"merge.mp4"]; // // // // // NSURL *outputFileUrl = [NSURL fileURLWithPath:outPutFilePath]; // NSURL *outputFileUrl = [NSURL fileURLWithPath:fileName]; // // // // // CMTime nextClistartTime = kCMTimeZero; // // // // // AVMutableComposition *comosition = [AVMutableComposition composition]; // // // // NSDictionary* options = @{AVURLAssetPreferPreciseDurationAndTimingKey:@YES}; // AVURLAsset *videoAsset = [[AVURLAsset alloc] initWithURL:videoInputUrl options:options]; // // // // // CMTimeRange videoTimeRange = CMTimeRangeMake(kCMTimeZero, videoAsset.duration); // // // kCMPersistentTrackID_Invalid = 0 // // AVMutableCompositionTrack *videoTrack = [comosition addMutableTrackWithMediaType:AVMediaTypeVideo preferredTrackID:kCMPersistentTrackID_Invalid]; // // // // // AVAssetTrack *videoAssetTrack = [[videoAsset tracksWithMediaType:AVMediaTypeVideo] firstObject]; // // // // // [videoTrack insertTimeRange:videoTimeRange ofTrack:videoAssetTrack atTime:nextClistartTime error:nil]; // // // // // AVURLAsset *audioAsset = [[AVURLAsset alloc] initWithURL:audioInputUrl options:options]; // // // , // // CMTimeRange audioTimeRange = videoTimeRange; // // // // // AVMutableCompositionTrack *audioTrack = [comosition addMutableTrackWithMediaType:AVMediaTypeAudio preferredTrackID:kCMPersistentTrackID_Invalid]; // // // // // AVAssetTrack *audioAssetTrack = [[audioAsset tracksWithMediaType:AVMediaTypeAudio] firstObject]; // // // // // [audioTrack insertTimeRange:audioTimeRange ofTrack:audioAssetTrack atTime:nextClistartTime error:nil]; // // // ///* // // // AVMutableAudioMix *mutableAudioMix = [AVMutableAudioMix audioMix]; // // Create the audio mix input parameters object. // AVMutableAudioMixInputParameters *mixParameters = [AVMutableAudioMixInputParameters audioMixInputParametersWithTrack:audioTrack]; // // Set the volume ramp to slowly fade the audio out over the duration of the composition. //// [mixParameters setVolumeRampFromStartVolume:1.f toEndVolume:0.f timeRange:CMTimeRangeMake(kCMTimeZero, mutableComposition.duration)]; // [mixParameters setVolume:.05f atTime:kCMTimeZero]; // // Attach the input parameters to the audio mix. // mutableAudioMix.inputParameters = @[mixParameters]; // */ // // // // //// AVMutableCompositionTrack *audioTrack2 = [comosition addMutableTrackWithMediaType:AVMediaTypeAudio preferredTrackID:kCMPersistentTrackID_Invalid]; //// AVAssetTrack *audioAssetTrack2 = [[videoAsset tracksWithMediaType:AVMediaTypeAudio] firstObject]; //// [audioTrack2 insertTimeRange:audioTimeRange ofTrack:audioAssetTrack2 atTime:nextClistartTime error:nil]; // // // if (!_editTheOriginaBtn.selected) { // AVMutableAudioMix *mutableAudioMix = [AVMutableAudioMix audioMix]; // // Create the audio mix input parameters object. // AVMutableAudioMixInputParameters *mixParameters = [AVMutableAudioMixInputParameters audioMixInputParametersWithTrack:audioTrack]; // // Set the volume ramp to slowly fade the audio out over the duration of the composition. // // [mixParameters setVolumeRampFromStartVolume:1.f toEndVolume:0.f timeRange:CMTimeRangeMake(kCMTimeZero, mutableComposition.duration)]; // [mixParameters setVolume:.5f atTime:kCMTimeZero]; // // Attach the input parameters to the audio mix. // mutableAudioMix.inputParameters = @[mixParameters]; // // AVMutableCompositionTrack *audioTrack2 = [comosition addMutableTrackWithMediaType:AVMediaTypeAudio preferredTrackID:kCMPersistentTrackID_Invalid]; // AVAssetTrack *audioAssetTrack2 = [[videoAsset tracksWithMediaType:AVMediaTypeAudio] firstObject]; // [audioTrack2 insertTimeRange:audioTimeRange ofTrack:audioAssetTrack2 atTime:nextClistartTime error:nil]; // // // // // CGSize videoSize = [videoTrack naturalSize]; // CALayer* aLayer = [CALayer layer]; // UIImage* waterImg = _stickersImgView.image; // aLayer.contents = (id)waterImg.CGImage; // // float bili = 720/ScreenWidth; // // // aLayer.frame = CGRectMake(_stickersImgView.frame.origin.x * bili,1280 - _stickersImgView.frame.origin.y *bili - 150*bili, 150*bili, 150*bili); // aLayer.opacity = 1; // // CALayer *parentLayer = [CALayer layer]; // CALayer *videoLayer = [CALayer layer]; // parentLayer.frame = CGRectMake(0, 0, videoSize.width, videoSize.height); // videoLayer.frame = CGRectMake(0, 0, videoSize.width, videoSize.height); // [parentLayer addSublayer:videoLayer]; // [parentLayer addSublayer:aLayer]; // AVMutableVideoComposition* videoComp = [AVMutableVideoComposition videoComposition]; // videoComp.renderSize = videoSize; // // // videoComp.frameDuration = CMTimeMake(1, 30); // videoComp.animationTool = [AVVideoCompositionCoreAnimationTool videoCompositionCoreAnimationToolWithPostProcessingAsVideoLayer:videoLayer inLayer:parentLayer]; // AVMutableVideoCompositionInstruction* instruction = [AVMutableVideoCompositionInstruction videoCompositionInstruction]; // // instruction.timeRange = CMTimeRangeMake(kCMTimeZero, [comosition duration]); // AVAssetTrack* mixVideoTrack = [[comosition tracksWithMediaType:AVMediaTypeVideo] objectAtIndex:0]; // AVMutableVideoCompositionLayerInstruction* layerInstruction = [AVMutableVideoCompositionLayerInstruction videoCompositionLayerInstructionWithAssetTrack:mixVideoTrack]; // instruction.layerInstructions = [NSArray arrayWithObject:layerInstruction]; // videoComp.instructions = [NSArray arrayWithObject: instruction]; // // AVAssetExportSession *assetExport = [[AVAssetExportSession alloc] initWithAsset:comosition presetName:AVAssetExportPreset1280x720]; // // assetExport.audioMix = mutableAudioMix; // // assetExport.videoComposition = videoComp; // // // // assetExport.outputFileType = AVFileTypeMPEG4; // // // // // assetExport.outputURL = outputFileUrl; // // // // // assetExport.shouldOptimizeForNetworkUse = YES; // // // // // [assetExport exportAsynchronouslyWithCompletionHandler:^{ // // // // // dispatch_async(dispatch_get_main_queue(), ^{ // // [self compressVideoWithInputVideoUrl:outputFileUrl]; // // }); // }]; // }else // { // // // // CGSize videoSize = [videoTrack naturalSize]; // CALayer* aLayer = [CALayer layer]; // UIImage* waterImg = _stickersImgView.image; // aLayer.contents = (id)waterImg.CGImage; // float bili = 720/ScreenWidth; // aLayer.frame = CGRectMake(_stickersImgView.frame.origin.x * bili,1280 - _stickersImgView.frame.origin.y *bili - 150*bili, 150*bili, 150*bili); // aLayer.opacity = 1; // // CALayer *parentLayer = [CALayer layer]; // CALayer *videoLayer = [CALayer layer]; // parentLayer.frame = CGRectMake(0, 0, videoSize.width, videoSize.height); // videoLayer.frame = CGRectMake(0, 0, videoSize.width, videoSize.height); // [parentLayer addSublayer:videoLayer]; // [parentLayer addSublayer:aLayer]; // AVMutableVideoComposition* videoComp = [AVMutableVideoComposition videoComposition]; // videoComp.renderSize = videoSize; // // // videoComp.frameDuration = CMTimeMake(1, 30); // videoComp.animationTool = [AVVideoCompositionCoreAnimationTool videoCompositionCoreAnimationToolWithPostProcessingAsVideoLayer:videoLayer inLayer:parentLayer]; // AVMutableVideoCompositionInstruction* instruction = [AVMutableVideoCompositionInstruction videoCompositionInstruction]; // // instruction.timeRange = CMTimeRangeMake(kCMTimeZero, [comosition duration]); // AVAssetTrack* mixVideoTrack = [[comosition tracksWithMediaType:AVMediaTypeVideo] objectAtIndex:0]; // AVMutableVideoCompositionLayerInstruction* layerInstruction = [AVMutableVideoCompositionLayerInstruction videoCompositionLayerInstructionWithAssetTrack:mixVideoTrack]; // instruction.layerInstructions = [NSArray arrayWithObject:layerInstruction]; // videoComp.instructions = [NSArray arrayWithObject: instruction]; // // // // // AVAssetExportSession *assetExport = [[AVAssetExportSession alloc] initWithAsset:comosition presetName:AVAssetExportPreset1280x720]; // // assetExport.videoComposition = videoComp; // // assetExport.audioMix = mutableAudioMix; // // // // assetExport.outputFileType = AVFileTypeMPEG4; // // // // // assetExport.outputURL = outputFileUrl; // // // // // assetExport.shouldOptimizeForNetworkUse = YES; // // // // // [assetExport exportAsynchronouslyWithCompletionHandler:^{ // // // // // dispatch_async(dispatch_get_main_queue(), ^{ // // [self compressVideoWithInputVideoUrl:outputFileUrl]; // // }); // }]; // // } } // -(void)mixAudioAndVidoWithInputURL1:(NSURL*)inputURL; { // HUD.labelText = @"..."; NSString *documents = [NSHomeDirectory() stringByAppendingPathComponent:@"tmp"]; // NSURL *videoInputUrl = inputURL; NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; formatter.dateFormat = @"yyyyMMddHHmmss"; NSString *nowTimeStr = [formatter stringFromDate:[NSDate dateWithTimeIntervalSinceNow:0]]; NSString *fileName = [[documents stringByAppendingPathComponent:nowTimeStr] stringByAppendingString:@"merge.mp4"]; // NSURL *outputFileUrl = [NSURL fileURLWithPath:outPutFilePath]; NSURL *outputFileUrl = [NSURL fileURLWithPath:fileName]; // CMTime nextClistartTime = kCMTimeZero; // AVMutableComposition *comosition = [AVMutableComposition composition]; // NSDictionary* options = @{AVURLAssetPreferPreciseDurationAndTimingKey:@YES}; AVURLAsset *videoAsset = [[AVURLAsset alloc] initWithURL:videoInputUrl options:options]; // CMTimeRange videoTimeRange = CMTimeRangeMake(kCMTimeZero, videoAsset.duration); // kCMPersistentTrackID_Invalid = 0 AVMutableCompositionTrack *videoTrack = [comosition addMutableTrackWithMediaType:AVMediaTypeVideo preferredTrackID:kCMPersistentTrackID_Invalid]; // AVAssetTrack *videoAssetTrack = [[videoAsset tracksWithMediaType:AVMediaTypeVideo] firstObject]; // [videoTrack insertTimeRange:videoTimeRange ofTrack:videoAssetTrack atTime:nextClistartTime error:nil]; // , CMTimeRange audioTimeRange = videoTimeRange; AVMutableCompositionTrack *audioTrack2 = [comosition addMutableTrackWithMediaType:AVMediaTypeAudio preferredTrackID:kCMPersistentTrackID_Invalid]; AVAssetTrack *audioAssetTrack2 = [[videoAsset tracksWithMediaType:AVMediaTypeAudio] firstObject]; [audioTrack2 insertTimeRange:audioTimeRange ofTrack:audioAssetTrack2 atTime:nextClistartTime error:nil]; // CGSize videoSize = [videoTrack naturalSize]; CALayer* aLayer = [CALayer layer]; UIImage* waterImg = _stickersImgView.image; aLayer.contents = (id)waterImg.CGImage; float bili = 720/SCREEN_WIDTH; aLayer.frame = CGRectMake(_stickersImgView.frame.origin.x * bili,1280 - _stickersImgView.frame.origin.y *bili - 150*bili, 150*bili, 150*bili); aLayer.opacity = 1; CALayer *parentLayer = [CALayer layer]; CALayer *videoLayer = [CALayer layer]; parentLayer.frame = CGRectMake(0, 0, videoSize.width, videoSize.height); videoLayer.frame = CGRectMake(0, 0, videoSize.width, videoSize.height); [parentLayer addSublayer:videoLayer]; [parentLayer addSublayer:aLayer]; AVMutableVideoComposition* videoComp = [AVMutableVideoComposition videoComposition]; videoComp.renderSize = videoSize; videoComp.frameDuration = CMTimeMake(1, 30); videoComp.animationTool = [AVVideoCompositionCoreAnimationTool videoCompositionCoreAnimationToolWithPostProcessingAsVideoLayer:videoLayer inLayer:parentLayer]; AVMutableVideoCompositionInstruction* instruction = [AVMutableVideoCompositionInstruction videoCompositionInstruction]; instruction.timeRange = CMTimeRangeMake(kCMTimeZero, [comosition duration]); AVAssetTrack* mixVideoTrack = [[comosition tracksWithMediaType:AVMediaTypeVideo] objectAtIndex:0]; AVMutableVideoCompositionLayerInstruction* layerInstruction = [AVMutableVideoCompositionLayerInstruction videoCompositionLayerInstructionWithAssetTrack:mixVideoTrack]; instruction.layerInstructions = [NSArray arrayWithObject:layerInstruction]; videoComp.instructions = [NSArray arrayWithObject: instruction]; // AVAssetExportSession *assetExport = [[AVAssetExportSession alloc] initWithAsset:comosition presetName:AVAssetExportPreset1280x720]; assetExport.videoComposition = videoComp; // assetExport.audioMix = mutableAudioMix; // assetExport.outputFileType = AVFileTypeMPEG4; // assetExport.outputURL = outputFileUrl; // assetExport.shouldOptimizeForNetworkUse = YES; // [assetExport exportAsynchronouslyWithCompletionHandler:^{ // dispatch_async(dispatch_get_main_queue(), ^{ [self compressVideoWithInputVideoUrl:outputFileUrl]; }); }]; } // -(void)mixAudioAndVidoWithInputURL2:(NSURL*)inputURL; { // audio529 // HUD.labelText = @"..."; NSString *documents = [NSHomeDirectory() stringByAppendingPathComponent:@"tmp"]; // // NSURL *audioInputUrl = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"audio529" ofType:@"mp3"]]; NSURL *audioInputUrl = [NSURL fileURLWithPath:_audioPath]; // NSURL *videoInputUrl = inputURL; // // NSString *outPutFilePath = [documents stringByAppendingPathComponent:@"videoandoudio.mov"]; // NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; formatter.dateFormat = @"yyyyMMddHHmmss"; NSString *nowTimeStr = [formatter stringFromDate:[NSDate dateWithTimeIntervalSinceNow:0]]; NSString *fileName = [[documents stringByAppendingPathComponent:nowTimeStr] stringByAppendingString:@"merge.mp4"]; // NSURL *outputFileUrl = [NSURL fileURLWithPath:outPutFilePath]; NSURL *outputFileUrl = [NSURL fileURLWithPath:fileName]; // CMTime nextClistartTime = kCMTimeZero; // AVMutableComposition *comosition = [AVMutableComposition composition]; // NSDictionary* options = @{AVURLAssetPreferPreciseDurationAndTimingKey:@YES}; AVURLAsset *videoAsset = [[AVURLAsset alloc] initWithURL:videoInputUrl options:options]; // CMTimeRange videoTimeRange = CMTimeRangeMake(kCMTimeZero, videoAsset.duration); // kCMPersistentTrackID_Invalid = 0 AVMutableCompositionTrack *videoTrack = [comosition addMutableTrackWithMediaType:AVMediaTypeVideo preferredTrackID:kCMPersistentTrackID_Invalid]; // AVAssetTrack *videoAssetTrack = [[videoAsset tracksWithMediaType:AVMediaTypeVideo] firstObject]; // [videoTrack insertTimeRange:videoTimeRange ofTrack:videoAssetTrack atTime:nextClistartTime error:nil]; // AVURLAsset *audioAsset = [[AVURLAsset alloc] initWithURL:audioInputUrl options:options]; // , CMTimeRange audioTimeRange = videoTimeRange; // AVMutableCompositionTrack *audioTrack = [comosition addMutableTrackWithMediaType:AVMediaTypeAudio preferredTrackID:kCMPersistentTrackID_Invalid]; // AVAssetTrack *audioAssetTrack = [[audioAsset tracksWithMediaType:AVMediaTypeAudio] firstObject]; // [audioTrack insertTimeRange:audioTimeRange ofTrack:audioAssetTrack atTime:nextClistartTime error:nil]; /* // AVMutableAudioMix *mutableAudioMix = [AVMutableAudioMix audioMix]; // Create the audio mix input parameters object. AVMutableAudioMixInputParameters *mixParameters = [AVMutableAudioMixInputParameters audioMixInputParametersWithTrack:audioTrack]; // Set the volume ramp to slowly fade the audio out over the duration of the composition. // [mixParameters setVolumeRampFromStartVolume:1.f toEndVolume:0.f timeRange:CMTimeRangeMake(kCMTimeZero, mutableComposition.duration)]; [mixParameters setVolume:.05f atTime:kCMTimeZero]; // Attach the input parameters to the audio mix. mutableAudioMix.inputParameters = @[mixParameters]; */ // // AVMutableCompositionTrack *audioTrack2 = [comosition addMutableTrackWithMediaType:AVMediaTypeAudio preferredTrackID:kCMPersistentTrackID_Invalid]; // AVAssetTrack *audioAssetTrack2 = [[videoAsset tracksWithMediaType:AVMediaTypeAudio] firstObject]; // [audioTrack2 insertTimeRange:audioTimeRange ofTrack:audioAssetTrack2 atTime:nextClistartTime error:nil]; if (!_editTheOriginaBtn.selected) { AVMutableAudioMix *mutableAudioMix = [AVMutableAudioMix audioMix]; // Create the audio mix input parameters object. AVMutableAudioMixInputParameters *mixParameters = [AVMutableAudioMixInputParameters audioMixInputParametersWithTrack:audioTrack]; // Set the volume ramp to slowly fade the audio out over the duration of the composition. // [mixParameters setVolumeRampFromStartVolume:1.f toEndVolume:0.f timeRange:CMTimeRangeMake(kCMTimeZero, mutableComposition.duration)]; [mixParameters setVolume:.5f atTime:kCMTimeZero]; // Attach the input parameters to the audio mix. mutableAudioMix.inputParameters = @[mixParameters]; AVMutableCompositionTrack *audioTrack2 = [comosition addMutableTrackWithMediaType:AVMediaTypeAudio preferredTrackID:kCMPersistentTrackID_Invalid]; AVAssetTrack *audioAssetTrack2 = [[videoAsset tracksWithMediaType:AVMediaTypeAudio] firstObject]; [audioTrack2 insertTimeRange:audioTimeRange ofTrack:audioAssetTrack2 atTime:nextClistartTime error:nil]; // CGSize videoSize = [videoTrack naturalSize]; CALayer* aLayer = [CALayer layer]; UIImage* waterImg = _stickersImgView.image; aLayer.contents = (id)waterImg.CGImage; float bili = 720/SCREEN_WIDTH; aLayer.frame = CGRectMake(_stickersImgView.frame.origin.x * bili,1280 - _stickersImgView.frame.origin.y *bili - 150*bili, 150*bili, 150*bili); aLayer.opacity = 1; CALayer *parentLayer = [CALayer layer]; CALayer *videoLayer = [CALayer layer]; parentLayer.frame = CGRectMake(0, 0, videoSize.width, videoSize.height); videoLayer.frame = CGRectMake(0, 0, videoSize.width, videoSize.height); [parentLayer addSublayer:videoLayer]; [parentLayer addSublayer:aLayer]; AVMutableVideoComposition* videoComp = [AVMutableVideoComposition videoComposition]; videoComp.renderSize = videoSize; videoComp.frameDuration = CMTimeMake(1, 30); videoComp.animationTool = [AVVideoCompositionCoreAnimationTool videoCompositionCoreAnimationToolWithPostProcessingAsVideoLayer:videoLayer inLayer:parentLayer]; AVMutableVideoCompositionInstruction* instruction = [AVMutableVideoCompositionInstruction videoCompositionInstruction]; instruction.timeRange = CMTimeRangeMake(kCMTimeZero, [comosition duration]); AVAssetTrack* mixVideoTrack = [[comosition tracksWithMediaType:AVMediaTypeVideo] objectAtIndex:0]; AVMutableVideoCompositionLayerInstruction* layerInstruction = [AVMutableVideoCompositionLayerInstruction videoCompositionLayerInstructionWithAssetTrack:mixVideoTrack]; instruction.layerInstructions = [NSArray arrayWithObject:layerInstruction]; videoComp.instructions = [NSArray arrayWithObject: instruction]; AVAssetExportSession *assetExport = [[AVAssetExportSession alloc] initWithAsset:comosition presetName:AVAssetExportPreset1280x720]; assetExport.audioMix = mutableAudioMix; assetExport.videoComposition = videoComp; // assetExport.outputFileType = AVFileTypeMPEG4; // assetExport.outputURL = outputFileUrl; // assetExport.shouldOptimizeForNetworkUse = YES; // [assetExport exportAsynchronouslyWithCompletionHandler:^{ // dispatch_async(dispatch_get_main_queue(), ^{ [self compressVideoWithInputVideoUrl:outputFileUrl]; }); }]; }else { // CGSize videoSize = [videoTrack naturalSize]; CALayer* aLayer = [CALayer layer]; UIImage* waterImg = _stickersImgView.image; aLayer.contents = (id)waterImg.CGImage; float bili = 720/SCREEN_WIDTH; aLayer.frame = CGRectMake(_stickersImgView.frame.origin.x * bili,1280 - _stickersImgView.frame.origin.y *bili - 150*bili, 150*bili, 150*bili); aLayer.opacity = 1; CALayer *parentLayer = [CALayer layer]; CALayer *videoLayer = [CALayer layer]; parentLayer.frame = CGRectMake(0, 0, videoSize.width, videoSize.height); videoLayer.frame = CGRectMake(0, 0, videoSize.width, videoSize.height); [parentLayer addSublayer:videoLayer]; [parentLayer addSublayer:aLayer]; AVMutableVideoComposition* videoComp = [AVMutableVideoComposition videoComposition]; videoComp.renderSize = videoSize; videoComp.frameDuration = CMTimeMake(1, 30); videoComp.animationTool = [AVVideoCompositionCoreAnimationTool videoCompositionCoreAnimationToolWithPostProcessingAsVideoLayer:videoLayer inLayer:parentLayer]; AVMutableVideoCompositionInstruction* instruction = [AVMutableVideoCompositionInstruction videoCompositionInstruction]; instruction.timeRange = CMTimeRangeMake(kCMTimeZero, [comosition duration]); AVAssetTrack* mixVideoTrack = [[comosition tracksWithMediaType:AVMediaTypeVideo] objectAtIndex:0]; AVMutableVideoCompositionLayerInstruction* layerInstruction = [AVMutableVideoCompositionLayerInstruction videoCompositionLayerInstructionWithAssetTrack:mixVideoTrack]; instruction.layerInstructions = [NSArray arrayWithObject:layerInstruction]; videoComp.instructions = [NSArray arrayWithObject: instruction]; // AVAssetExportSession *assetExport = [[AVAssetExportSession alloc] initWithAsset:comosition presetName:AVAssetExportPreset1280x720]; assetExport.videoComposition = videoComp; // assetExport.audioMix = mutableAudioMix; // assetExport.outputFileType = AVFileTypeMPEG4; // assetExport.outputURL = outputFileUrl; // assetExport.shouldOptimizeForNetworkUse = YES; // [assetExport exportAsynchronouslyWithCompletionHandler:^{ // dispatch_async(dispatch_get_main_queue(), ^{ [self compressVideoWithInputVideoUrl:outputFileUrl]; }); }]; } } -(void)clickEditOriginalBtn { if (!_editTheOriginaBtn.selected) { _editTheOriginaBtn.selected = YES; [mainPlayer setVolume:0]; }else { [mainPlayer setVolume:1]; _editTheOriginaBtn.selected = NO; } } // -(void)clickOKBtn { // [self showEditMusicBar:_musicBtn]; if (self.choseEditType == choseMusic) { }else { self.choseEditType = choseMusic; _okBtn.selected = YES; _cancleBtn.selected = NO; _stickersBtn.selected = NO; _collectionView.hidden = YES; _musicCollectionView.hidden = NO; _stickersCollectionView.hidden = YES; } if (_audioPath) { _editTheOriginaBtn.hidden = NO; _editTheOriginaSwitch.hidden = NO; } } -(void)clickStickersBtn { _editTheOriginaBtn.hidden = YES; _editTheOriginaSwitch.hidden = YES; if (self.choseEditType == choseStickers) { }else { self.choseEditType = choseStickers; _okBtn.selected = NO; _cancleBtn.selected = NO; _stickersBtn.selected = YES; _collectionView.hidden = YES; _musicCollectionView.hidden = YES; _stickersCollectionView.hidden = NO; } } // -(void)clickCancleBtn { // [self showEditMusicBar:_musicBtn]; // _audioPath = nil; // [_audioPlayer pause]; _editTheOriginaBtn.hidden = YES; _editTheOriginaSwitch.hidden = YES; if (self.choseEditType == choseFilter) { }else { self.choseEditType = choseFilter; _okBtn.selected = NO; _cancleBtn.selected = YES; _stickersBtn.selected = NO; _collectionView.hidden = NO; _musicCollectionView.hidden = YES; _stickersCollectionView.hidden = YES; } } -(void)showEditMusicBar:(UIButton*)sendr { if (!sendr.selected) { sendr.selected = YES; [_musicBottomBar mas_updateConstraints:^(MASConstraintMaker *make) { make.bottom.equalTo(self.view); }]; // [UIView animateWithDuration:.3 animations:^{ [self.view layoutIfNeeded]; }]; }else { [_musicBottomBar mas_updateConstraints:^(MASConstraintMaker *make) { make.bottom.equalTo(self.view).offset(160); }]; // [UIView animateWithDuration:.3 animations:^{ [self.view layoutIfNeeded]; }]; sendr.selected = NO; } } -(NSArray*)creatMusicData { NSString *configPath = [[NSBundle mainBundle] pathForResource:@"music2" ofType:@"json"]; NSData *configData = [NSData dataWithContentsOfFile:configPath]; NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:configData options:NSJSONReadingAllowFragments error:nil]; NSArray *items = dic[@"music"]; int i = 529 ; NSMutableArray *array = [NSMutableArray array]; MusicData *effect = [[MusicData alloc] init]; effect.name = @""; effect.iconPath = [[NSBundle mainBundle] pathForResource:@"nilMusic" ofType:@"png"]; effect.isSelected = YES; [array addObject:effect]; for (NSDictionary *item in items) { // NSString *path = [baseDir stringByAppendingPathComponent:item[@"resourceUrl"]]; MusicData *effect = [[MusicData alloc] init]; effect.name = item[@"name"]; effect.eid = item[@"id"]; effect.musicPath = [[NSBundle mainBundle] pathForResource:[NSString stringWithFormat:@"audio%d",i] ofType:@"mp3"]; effect.iconPath = [[NSBundle mainBundle] pathForResource:[NSString stringWithFormat:@"icon%d",i] ofType:@"png"]; [array addObject:effect]; i++; } return array; } -(NSArray*)creatStickersData { NSString *configPath = [[NSBundle mainBundle] pathForResource:@"stickers" ofType:@"json"]; NSData *configData = [NSData dataWithContentsOfFile:configPath]; NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:configData options:NSJSONReadingAllowFragments error:nil]; NSArray *items = dic[@"stickers"]; int i = 529 ; NSMutableArray *array = [NSMutableArray array]; for (NSDictionary *item in items) { // NSString *path = [baseDir stringByAppendingPathComponent:item[@"resourceUrl"]]; StickersData* stickersItem = [[StickersData alloc] init]; stickersItem.name = item[@"name"]; stickersItem.StickersImgPaht = [[NSBundle mainBundle] pathForResource:[NSString stringWithFormat:@"stickers%d",i] ofType:@"jpg"]; [array addObject:stickersItem]; i++; } return array; } -(NSArray*)creatFilterData { FilterData* filter1 = [self createWithName:@"Empty" andFlieName:@"LFGPUImageEmptyFilter" andValue:nil]; filter1.isSelected = YES; FilterData* filter2 = [self createWithName:@"Amatorka" andFlieName:@"GPUImageAmatorkaFilter" andValue:nil]; FilterData* filter3 = [self createWithName:@"MissEtikate" andFlieName:@"GPUImageMissEtikateFilter" andValue:nil]; FilterData* filter4 = [self createWithName:@"Sepia" andFlieName:@"GPUImageSepiaFilter" andValue:nil]; FilterData* filter5 = [self createWithName:@"Sketch" andFlieName:@"GPUImageSketchFilter" andValue:nil]; FilterData* filter6 = [self createWithName:@"SoftElegance" andFlieName:@"GPUImageSoftEleganceFilter" andValue:nil]; FilterData* filter7 = [self createWithName:@"Toon" andFlieName:@"GPUImageToonFilter" andValue:nil]; FilterData* filter8 = [[FilterData alloc] init]; filter8.name = @"Saturation0"; filter8.iconPath = [[NSBundle mainBundle] pathForResource:@"GPUImageSaturationFilter0" ofType:@"png"]; filter8.fillterName = @"GPUImageSaturationFilter"; filter8.value = @"0"; FilterData* filter9 = [[FilterData alloc] init]; filter9.name = @"Saturation2"; filter9.iconPath = [[NSBundle mainBundle] pathForResource:@"GPUImageSaturationFilter2" ofType:@"png"]; filter9.fillterName = @"GPUImageSaturationFilter"; filter9.value = @"2"; return [NSArray arrayWithObjects:filter1,filter2,filter3,filter4,filter5,filter6,filter7,filter8,filter9, nil]; } -(FilterData*)createWithName:(NSString* )name andFlieName:(NSString*)fileName andValue:(NSString*)value { FilterData* filter1 = [[FilterData alloc] init]; filter1.name = name; filter1.iconPath = [[NSBundle mainBundle] pathForResource:fileName ofType:@"png"]; filter1.fillterName = fileName; if (value) { filter1.value = value; } return filter1; } -(void)playMusic { // NSURL *audioInputUrl = [NSURL fileURLWithPath:_audioPath]; // // NSURL *audioInputUrl = [NSURL URLWithString:_audioPath]; audioPlayerItem =[AVPlayerItem playerItemWithURL:audioInputUrl]; [_audioPlayer replaceCurrentItemWithPlayerItem:audioPlayerItem]; [_audioPlayer play]; } -(void)playOrPause{ if (playImg.isHidden) { playImg.hidden = NO; [mainPlayer pause]; }else{ playImg.hidden = YES; [mainPlayer play]; } } - (void)pressPlayButton { [playerItem seekToTime:kCMTimeZero]; [mainPlayer play]; if (_audioPath) { [audioPlayerItem seekToTime:kCMTimeZero]; [_audioPlayer play]; } } - (void)playingEnd:(NSNotification *)notification { [self pressPlayButton]; // if (playImg.isHidden) { // [self pressPlayButton]; // } // [[NSNotificationCenter defaultCenter] removeObserver:self]; // [self dismissViewControllerAnimated:YES completion:nil]; } -(void)viewWillDisappear:(BOOL)animated { [super viewWillDisappear:animated]; [_audioPlayer pause]; [mainPlayer pause]; [movieFile endProcessing]; } - (void)onApplicationWillResignActive { [mainPlayer pause]; [movieFile endProcessing]; if (_isdoing) { [movieWriter cancelRecording]; [endMovieFile endProcessing]; HUD.hidden = YES; } } - (void)onApplicationDidBecomeActive { [playerItem seekToTime:kCMTimeZero]; [mainPlayer play]; [movieFile startProcessing]; if (_isdoing) { } } - (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView { return 1; } // - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section { if (collectionView == _collectionView) { return _filterAry.count; }else if (collectionView == _stickersCollectionView) { return _stickersAry.count; } else { return _musicAry.count; } } // Cell - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { // 1. if (collectionView == _collectionView) { static NSString *cellID = @"MyCollectionCell"; MusicItemCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:cellID forIndexPath:indexPath]; FilterData* data = [_filterAry objectAtIndex:indexPath.row]; cell.iconImgView.image = [UIImage imageWithContentsOfFile:data.iconPath]; cell.nameLabel.text = data.name; cell.CheckMarkImgView.hidden = !data.isSelected; return cell; }else if (collectionView == _stickersCollectionView) { static NSString *cellID = @"MyCollectionCell3"; MusicItemCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:cellID forIndexPath:indexPath]; StickersData* data = [_stickersAry objectAtIndex:indexPath.row]; cell.iconImgView.image = [UIImage imageWithContentsOfFile:data.StickersImgPaht]; cell.nameLabel.text = data.name; cell.CheckMarkImgView.hidden = !data.isSelected; return cell; }else{ static NSString *cellID2 = @"MyCollectionCell2"; MusicItemCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:cellID2 forIndexPath:indexPath]; MusicData* data = [_musicAry objectAtIndex:indexPath.row]; UIImage* image = [UIImage imageWithContentsOfFile:data.iconPath]; cell.iconImgView.image = image; cell.nameLabel.text = data.name; cell.CheckMarkImgView.hidden = !data.isSelected; return cell; } } - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath { if (collectionView == _collectionView) { _nowFilterIndex = indexPath; if (_lastFilterIndex.row != _nowFilterIndex.row) { //1. FilterData* dataNow = [_filterAry objectAtIndex:indexPath.row]; dataNow.isSelected = YES; [_filterAry replaceObjectAtIndex:indexPath.row withObject:dataNow]; FilterData* dataLast = [_filterAry objectAtIndex:_lastFilterIndex.row]; dataLast.isSelected = NO; [_filterAry replaceObjectAtIndex:_lastFilterIndex.row withObject:dataLast]; //2.collectionView [_collectionView reloadData]; _lastFilterIndex = indexPath; } if (indexPath.row == 0) { [movieFile removeAllTargets]; FilterData* data = [_filterAry objectAtIndex:indexPath.row]; _filtClassName = data.fillterName; filter = [[NSClassFromString(_filtClassName) alloc] init]; [movieFile addTarget:filter]; [filter addTarget:_filterView]; }else { [movieFile removeAllTargets]; FilterData* data = [_filterAry objectAtIndex:indexPath.row]; _filtClassName = data.fillterName; if ([data.fillterName isEqualToString:@"GPUImageSaturationFilter"]) { GPUImageSaturationFilter* xxxxfilter = [[NSClassFromString(_filtClassName) alloc] init]; xxxxfilter.saturation = [data.value floatValue]; _saturationValue = [data.value floatValue]; filter = xxxxfilter; }else{ filter = [[NSClassFromString(_filtClassName) alloc] init]; } [movieFile addTarget:filter]; // Only rotate the video for display, leave orientation the same for recording // GPUImageView *filterView = (GPUImageView *)self.view; [filter addTarget:_filterView]; } }else if (collectionView == _stickersCollectionView){ _nowStickersIndex = indexPath; if (_lastStickersIndex.row != _nowStickersIndex.row) { //1. // FilterData* dataNow = [_filterAry objectAtIndex:indexPath.row]; StickersData* dataNow = [_stickersAry objectAtIndex:indexPath.row]; dataNow.isSelected = YES; [_stickersAry replaceObjectAtIndex:indexPath.row withObject:dataNow]; StickersData* dataLast = [_stickersAry objectAtIndex:_lastStickersIndex.row]; dataLast.isSelected = NO; [_stickersAry replaceObjectAtIndex:_lastStickersIndex.row withObject:dataLast]; //2.collectionView [_stickersCollectionView reloadData]; _lastStickersIndex = indexPath; }else { _stickersImgView.center = CGPointMake(SCREEN_WIDTH/2, SCREEN_HEIGHT/2); } StickersData* data = [_stickersAry objectAtIndex:indexPath.row]; _stickersImgView.image = [UIImage imageWithContentsOfFile:data.StickersImgPaht]; _stickersImgView.hidden = NO; }else{ _nowMusicIndex = indexPath; if (_lastMusicIndex.row != _nowMusicIndex.row) { //1. FilterData* dataNow = [_musicAry objectAtIndex:indexPath.row]; dataNow.isSelected = YES; [_musicAry replaceObjectAtIndex:indexPath.row withObject:dataNow]; FilterData* dataLast = [_musicAry objectAtIndex:_lastMusicIndex.row]; dataLast.isSelected = NO; [_musicAry replaceObjectAtIndex:_lastMusicIndex.row withObject:dataLast]; //collectionView [_musicCollectionView reloadData]; _lastMusicIndex = indexPath; } if (indexPath.row == 0) { _audioPath = nil; [_audioPlayer pause]; _editTheOriginaBtn.hidden = YES; _editTheOriginaSwitch.hidden = YES; [mainPlayer setVolume:1]; _editTheOriginaBtn.selected = NO; _editTheOriginaSwitch.on = NO; }else { MusicData* data = [_musicAry objectAtIndex:indexPath.row]; _audioPath = data.musicPath; [self playMusic]; _editTheOriginaBtn.hidden = NO; _editTheOriginaSwitch.hidden = NO; } } } -(void)notCloseCor { [[NSNotificationCenter defaultCenter] removeObserver:self]; // [[NSNotificationCenter defaultCenter] postNotificationName:kTabBarHiddenNONotification object:self]; [self.navigationController popToRootViewControllerAnimated:NO]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; } - (void) panView:(UIPanGestureRecognizer *)panGestureRecognizer { UIView *view = panGestureRecognizer.view; if (panGestureRecognizer.state == UIGestureRecognizerStateBegan) { _musicBottomBar.hidden = YES; } if ( panGestureRecognizer.state == UIGestureRecognizerStateChanged) { CGPoint translation = [panGestureRecognizer translationInView:view.superview]; [view setCenter:(CGPoint){view.center.x + translation.x, view.center.y + translation.y}]; [panGestureRecognizer setTranslation:CGPointZero inView:view.superview]; } if (panGestureRecognizer.state == UIGestureRecognizerStateEnded) { _musicBottomBar.hidden = NO; } } -(void)dealloc{ NSLog(@"EditVideoViewController "); } @end ```
/content/code_sandbox/PlayerDemo/CustomVideoCamera/EditVideoViewController.m
objective-c
2016-02-02T02:51:55
2024-08-09T08:55:27
WMPlayer
zhengwenming/WMPlayer
3,272
15,128
```xml <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "path_to_url"> <plist version="1.0"> <dict> <key>IDEDidComputeMac32BitWarning</key> <true/> </dict> </plist> ```
/content/code_sandbox/PlayerDemo.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
xml
2016-02-02T02:51:55
2024-08-09T08:55:27
WMPlayer
zhengwenming/WMPlayer
3,272
72
```xml <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "path_to_url"> <plist version="1.0"> <dict> <key>SchemeUserState</key> <dict> <key>PlayerDemo.xcscheme_^#shared#^_</key> <dict> <key>orderHint</key> <integer>0</integer> </dict> </dict> <key>SuppressBuildableAutocreation</key> <dict> <key>C4EC7F3B1DF4FCD2006E9820</key> <dict> <key>primary</key> <true/> </dict> </dict> </dict> </plist> ```
/content/code_sandbox/PlayerDemo.xcodeproj/xcuserdata/kefu.xcuserdatad/xcschemes/xcschememanagement.plist
xml
2016-02-02T02:51:55
2024-08-09T08:55:27
WMPlayer
zhengwenming/WMPlayer
3,272
189
```unknown <?xml version="1.0" encoding="UTF-8"?> <Scheme LastUpgradeVersion = "1420" version = "1.3"> <BuildAction parallelizeBuildables = "YES" buildImplicitDependencies = "YES"> <BuildActionEntries> <BuildActionEntry buildForTesting = "YES" buildForRunning = "YES" buildForProfiling = "YES" buildForArchiving = "YES" buildForAnalyzing = "YES"> <BuildableReference BuildableIdentifier = "primary" BlueprintIdentifier = "C4EC7F3B1DF4FCD2006E9820" BuildableName = "PlayerDemo.app" BlueprintName = "PlayerDemo" ReferencedContainer = "container:PlayerDemo.xcodeproj"> </BuildableReference> </BuildActionEntry> </BuildActionEntries> </BuildAction> <TestAction buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" shouldUseLaunchSchemeArgsEnv = "YES"> <Testables> </Testables> </TestAction> <LaunchAction buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" launchStyle = "0" useCustomWorkingDirectory = "NO" ignoresPersistentStateOnLaunch = "NO" debugDocumentVersioning = "YES" debugServiceExtension = "internal" allowLocationSimulation = "YES"> <BuildableProductRunnable runnableDebuggingMode = "0"> <BuildableReference BuildableIdentifier = "primary" BlueprintIdentifier = "C4EC7F3B1DF4FCD2006E9820" BuildableName = "PlayerDemo.app" BlueprintName = "PlayerDemo" ReferencedContainer = "container:PlayerDemo.xcodeproj"> </BuildableReference> </BuildableProductRunnable> </LaunchAction> <ProfileAction buildConfiguration = "Release" shouldUseLaunchSchemeArgsEnv = "YES" savedToolIdentifier = "" useCustomWorkingDirectory = "NO" debugDocumentVersioning = "YES"> <BuildableProductRunnable runnableDebuggingMode = "0"> <BuildableReference BuildableIdentifier = "primary" BlueprintIdentifier = "C4EC7F3B1DF4FCD2006E9820" BuildableName = "PlayerDemo.app" BlueprintName = "PlayerDemo" ReferencedContainer = "container:PlayerDemo.xcodeproj"> </BuildableReference> </BuildableProductRunnable> </ProfileAction> <AnalyzeAction buildConfiguration = "Debug"> </AnalyzeAction> <ArchiveAction buildConfiguration = "Release" revealArchiveInOrganizer = "YES"> </ArchiveAction> </Scheme> ```
/content/code_sandbox/PlayerDemo.xcodeproj/xcshareddata/xcschemes/PlayerDemo.xcscheme
unknown
2016-02-02T02:51:55
2024-08-09T08:55:27
WMPlayer
zhengwenming/WMPlayer
3,272
671
```xml <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "path_to_url"> <plist version="1.0"> <dict> <key>SchemeUserState</key> <dict> <key>PlayerDemo.xcscheme_^#shared#^_</key> <dict> <key>orderHint</key> <integer>7</integer> </dict> </dict> </dict> </plist> ```
/content/code_sandbox/PlayerDemo.xcodeproj/xcuserdata/apple.xcuserdatad/xcschemes/xcschememanagement.plist
xml
2016-02-02T02:51:55
2024-08-09T08:55:27
WMPlayer
zhengwenming/WMPlayer
3,272
120
```xml <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "path_to_url"> <plist version="1.0"> <dict> <key>SchemeUserState</key> <dict> <key>PlayerDemo.xcscheme_^#shared#^_</key> <dict> <key>orderHint</key> <integer>7</integer> </dict> </dict> </dict> </plist> ```
/content/code_sandbox/PlayerDemo.xcodeproj/xcuserdata/zhengwenming.xcuserdatad/xcschemes/xcschememanagement.plist
xml
2016-02-02T02:51:55
2024-08-09T08:55:27
WMPlayer
zhengwenming/WMPlayer
3,272
120
```json PODS: - AFNetworking (3.2.1): - AFNetworking/NSURLSession (= 3.2.1) - AFNetworking/Reachability (= 3.2.1) - AFNetworking/Security (= 3.2.1) - AFNetworking/Serialization (= 3.2.1) - AFNetworking/UIKit (= 3.2.1) - AFNetworking/NSURLSession (3.2.1): - AFNetworking/Reachability - AFNetworking/Security - AFNetworking/Serialization - AFNetworking/Reachability (3.2.1) - AFNetworking/Security (3.2.1) - AFNetworking/Serialization (3.2.1) - AFNetworking/UIKit (3.2.1): - AFNetworking/NSURLSession - GPUImage (0.1.7) - Masonry (1.1.0) - MJRefresh (3.4.3) - SDWebImage (5.8.0): - SDWebImage/Core (= 5.8.0) - SDWebImage/Core (5.8.0) - TZImagePickerController (2.1.9) DEPENDENCIES: - AFNetworking - GPUImage - Masonry - MJRefresh - SDWebImage - TZImagePickerController (~> 2.1.6) SPEC REPOS: path_to_url - AFNetworking - GPUImage - Masonry - MJRefresh - SDWebImage - TZImagePickerController SPEC CHECKSUMS: AFNetworking: b6f891fdfaed196b46c7a83cf209e09697b94057 GPUImage: 733a5f0fab92df9de1c37ba9df520a833ccb406d Masonry: 678fab65091a9290e40e2832a55e7ab731aad201 MJRefresh: 53e3e3219f204425ee6d3e62e8733d3295944cd6 SDWebImage: 84000f962cbfa70c07f19d2234cbfcf5d779b5dc TZImagePickerController: 6c9721783063edafc9ad42cd95acc82f1b648485 PODFILE CHECKSUM: 230106280bbf77204dfab38c4d8f4b65d9851ac5 COCOAPODS: 1.8.4 ```
/content/code_sandbox/Pods/Manifest.lock
json
2016-02-02T02:51:55
2024-08-09T08:55:27
WMPlayer
zhengwenming/WMPlayer
3,272
563
```objective-c // : path_to_url // : path_to_url #import <UIKit/UIKit.h> #import <objc/message.h> // #define MJWeakSelf __weak typeof(self) weakSelf = self; // #ifdef DEBUG #define MJRefreshLog(...) NSLog(__VA_ARGS__) #else #define MJRefreshLog(...) #endif // #define MJRefreshDeprecated(DESCRIPTION) __attribute__((deprecated(DESCRIPTION))) // objc_msgSend #define MJRefreshMsgSend(...) ((void (*)(void *, SEL, UIView *))objc_msgSend)(__VA_ARGS__) #define MJRefreshMsgTarget(target) (__bridge void *)(target) // RGB #define MJRefreshColor(r, g, b) [UIColor colorWithRed:(r)/255.0 green:(g)/255.0 blue:(b)/255.0 alpha:1.0] // #define MJRefreshLabelTextColor MJRefreshColor(90, 90, 90) // #define MJRefreshLabelFont [UIFont boldSystemFontOfSize:14] // UIKIT_EXTERN const CGFloat MJRefreshLabelLeftInset; UIKIT_EXTERN const CGFloat MJRefreshHeaderHeight; UIKIT_EXTERN const CGFloat MJRefreshFooterHeight; UIKIT_EXTERN const CGFloat MJRefreshFastAnimationDuration; UIKIT_EXTERN const CGFloat MJRefreshSlowAnimationDuration; UIKIT_EXTERN NSString *const MJRefreshKeyPathContentOffset; UIKIT_EXTERN NSString *const MJRefreshKeyPathContentSize; UIKIT_EXTERN NSString *const MJRefreshKeyPathContentInset; UIKIT_EXTERN NSString *const MJRefreshKeyPathPanState; UIKIT_EXTERN NSString *const MJRefreshHeaderLastUpdatedTimeKey; UIKIT_EXTERN NSString *const MJRefreshHeaderIdleText; UIKIT_EXTERN NSString *const MJRefreshHeaderPullingText; UIKIT_EXTERN NSString *const MJRefreshHeaderRefreshingText; UIKIT_EXTERN NSString *const MJRefreshAutoFooterIdleText; UIKIT_EXTERN NSString *const MJRefreshAutoFooterRefreshingText; UIKIT_EXTERN NSString *const MJRefreshAutoFooterNoMoreDataText; UIKIT_EXTERN NSString *const MJRefreshBackFooterIdleText; UIKIT_EXTERN NSString *const MJRefreshBackFooterPullingText; UIKIT_EXTERN NSString *const MJRefreshBackFooterRefreshingText; UIKIT_EXTERN NSString *const MJRefreshBackFooterNoMoreDataText; UIKIT_EXTERN NSString *const MJRefreshHeaderLastTimeText; UIKIT_EXTERN NSString *const MJRefreshHeaderDateTodayText; UIKIT_EXTERN NSString *const MJRefreshHeaderNoneLastDateText; // #define MJRefreshCheckState \ MJRefreshState oldState = self.state; \ if (state == oldState) return; \ [super setState:state]; // Self #define MJRefreshDispatchAsyncOnMainQueue(x) \ __weak typeof(self) weakSelf = self; \ dispatch_async(dispatch_get_main_queue(), ^{ \ typeof(weakSelf) self = weakSelf; \ {x} \ }); ```
/content/code_sandbox/Pods/MJRefresh/MJRefresh/MJRefreshConst.h
objective-c
2016-02-02T02:51:55
2024-08-09T08:55:27
WMPlayer
zhengwenming/WMPlayer
3,272
571
```objective-c // : path_to_url // : path_to_url #import <UIKit/UIKit.h> const CGFloat MJRefreshLabelLeftInset = 25; const CGFloat MJRefreshHeaderHeight = 54.0; const CGFloat MJRefreshFooterHeight = 44.0; const CGFloat MJRefreshFastAnimationDuration = 0.25; const CGFloat MJRefreshSlowAnimationDuration = 0.4; NSString *const MJRefreshKeyPathContentOffset = @"contentOffset"; NSString *const MJRefreshKeyPathContentInset = @"contentInset"; NSString *const MJRefreshKeyPathContentSize = @"contentSize"; NSString *const MJRefreshKeyPathPanState = @"state"; NSString *const MJRefreshHeaderLastUpdatedTimeKey = @"MJRefreshHeaderLastUpdatedTimeKey"; NSString *const MJRefreshHeaderIdleText = @"MJRefreshHeaderIdleText"; NSString *const MJRefreshHeaderPullingText = @"MJRefreshHeaderPullingText"; NSString *const MJRefreshHeaderRefreshingText = @"MJRefreshHeaderRefreshingText"; NSString *const MJRefreshAutoFooterIdleText = @"MJRefreshAutoFooterIdleText"; NSString *const MJRefreshAutoFooterRefreshingText = @"MJRefreshAutoFooterRefreshingText"; NSString *const MJRefreshAutoFooterNoMoreDataText = @"MJRefreshAutoFooterNoMoreDataText"; NSString *const MJRefreshBackFooterIdleText = @"MJRefreshBackFooterIdleText"; NSString *const MJRefreshBackFooterPullingText = @"MJRefreshBackFooterPullingText"; NSString *const MJRefreshBackFooterRefreshingText = @"MJRefreshBackFooterRefreshingText"; NSString *const MJRefreshBackFooterNoMoreDataText = @"MJRefreshBackFooterNoMoreDataText"; NSString *const MJRefreshHeaderLastTimeText = @"MJRefreshHeaderLastTimeText"; NSString *const MJRefreshHeaderDateTodayText = @"MJRefreshHeaderDateTodayText"; NSString *const MJRefreshHeaderNoneLastDateText = @"MJRefreshHeaderNoneLastDateText"; ```
/content/code_sandbox/Pods/MJRefresh/MJRefresh/MJRefreshConst.m
objective-c
2016-02-02T02:51:55
2024-08-09T08:55:27
WMPlayer
zhengwenming/WMPlayer
3,272
398
```objective-c // : path_to_url // : path_to_url // UIView+Extension.m // MJRefreshExample // // Created by MJ Lee on 14-5-28. // #import "UIView+MJExtension.h" @implementation UIView (MJExtension) - (void)setMj_x:(CGFloat)mj_x { CGRect frame = self.frame; frame.origin.x = mj_x; self.frame = frame; } - (CGFloat)mj_x { return self.frame.origin.x; } - (void)setMj_y:(CGFloat)mj_y { CGRect frame = self.frame; frame.origin.y = mj_y; self.frame = frame; } - (CGFloat)mj_y { return self.frame.origin.y; } - (void)setMj_w:(CGFloat)mj_w { CGRect frame = self.frame; frame.size.width = mj_w; self.frame = frame; } - (CGFloat)mj_w { return self.frame.size.width; } - (void)setMj_h:(CGFloat)mj_h { CGRect frame = self.frame; frame.size.height = mj_h; self.frame = frame; } - (CGFloat)mj_h { return self.frame.size.height; } - (void)setMj_size:(CGSize)mj_size { CGRect frame = self.frame; frame.size = mj_size; self.frame = frame; } - (CGSize)mj_size { return self.frame.size; } - (void)setMj_origin:(CGPoint)mj_origin { CGRect frame = self.frame; frame.origin = mj_origin; self.frame = frame; } - (CGPoint)mj_origin { return self.frame.origin; } @end ```
/content/code_sandbox/Pods/MJRefresh/MJRefresh/UIView+MJExtension.m
objective-c
2016-02-02T02:51:55
2024-08-09T08:55:27
WMPlayer
zhengwenming/WMPlayer
3,272
368
```objective-c // // NSBundle+MJRefresh.h // MJRefreshExample // // Created by MJ Lee on 16/6/13. // #import <UIKit/UIKit.h> NS_ASSUME_NONNULL_BEGIN @interface NSBundle (MJRefresh) + (instancetype)mj_refreshBundle; + (UIImage *)mj_arrowImage; + (NSString *)mj_localizedStringForKey:(NSString *)key value:(nullable NSString *)value; + (NSString *)mj_localizedStringForKey:(NSString *)key; @end NS_ASSUME_NONNULL_END ```
/content/code_sandbox/Pods/MJRefresh/MJRefresh/NSBundle+MJRefresh.h
objective-c
2016-02-02T02:51:55
2024-08-09T08:55:27
WMPlayer
zhengwenming/WMPlayer
3,272
108
```objective-c // : path_to_url // : path_to_url // UIView+Extension.h // MJRefreshExample // // Created by MJ Lee on 14-5-28. // #import <UIKit/UIKit.h> NS_ASSUME_NONNULL_BEGIN @interface UIView (MJExtension) @property (assign, nonatomic) CGFloat mj_x; @property (assign, nonatomic) CGFloat mj_y; @property (assign, nonatomic) CGFloat mj_w; @property (assign, nonatomic) CGFloat mj_h; @property (assign, nonatomic) CGSize mj_size; @property (assign, nonatomic) CGPoint mj_origin; @end NS_ASSUME_NONNULL_END ```
/content/code_sandbox/Pods/MJRefresh/MJRefresh/UIView+MJExtension.h
objective-c
2016-02-02T02:51:55
2024-08-09T08:55:27
WMPlayer
zhengwenming/WMPlayer
3,272
126
```objective-c // // MJRefreshConfig.m // // Created by Frank on 2018/11/27. // #import "MJRefreshConfig.h" @implementation MJRefreshConfig static MJRefreshConfig *mj_RefreshConfig = nil; + (instancetype)defaultConfig { static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ mj_RefreshConfig = [[self alloc] init]; }); return mj_RefreshConfig; } @end ```
/content/code_sandbox/Pods/MJRefresh/MJRefresh/MJRefreshConfig.m
objective-c
2016-02-02T02:51:55
2024-08-09T08:55:27
WMPlayer
zhengwenming/WMPlayer
3,272
96
```objective-c // // NSBundle+MJRefresh.m // MJRefreshExample // // Created by MJ Lee on 16/6/13. // #import "NSBundle+MJRefresh.h" #import "MJRefreshComponent.h" #import "MJRefreshConfig.h" @implementation NSBundle (MJRefresh) + (instancetype)mj_refreshBundle { static NSBundle *refreshBundle = nil; if (refreshBundle == nil) { // mainBundlepod 1.x0.x refreshBundle = [NSBundle bundleWithPath:[[NSBundle bundleForClass:[MJRefreshComponent class]] pathForResource:@"MJRefresh" ofType:@"bundle"]]; } return refreshBundle; } + (UIImage *)mj_arrowImage { static UIImage *arrowImage = nil; if (arrowImage == nil) { arrowImage = [[UIImage imageWithContentsOfFile:[[self mj_refreshBundle] pathForResource:@"arrow@2x" ofType:@"png"]] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]; } return arrowImage; } + (NSString *)mj_localizedStringForKey:(NSString *)key { return [self mj_localizedStringForKey:key value:nil]; } + (NSString *)mj_localizedStringForKey:(NSString *)key value:(NSString *)value { static NSBundle *bundle = nil; if (bundle == nil) { NSString *language = MJRefreshConfig.defaultConfig.languageCode; // if (!language) { // iOSenzh-Hanszh-Hant language = [NSLocale preferredLanguages].firstObject; } if ([language hasPrefix:@"en"]) { language = @"en"; } else if ([language hasPrefix:@"zh"]) { if ([language rangeOfString:@"Hans"].location != NSNotFound) { language = @"zh-Hans"; // } else { // zh-Hant\zh-HK\zh-TW language = @"zh-Hant"; // } } else if ([language hasPrefix:@"ko"]) { language = @"ko"; } else if ([language hasPrefix:@"ru"]) { language = @"ru"; } else if ([language hasPrefix:@"uk"]) { language = @"uk"; } else { language = @"en"; } // MJRefresh.bundle bundle = [NSBundle bundleWithPath:[[NSBundle mj_refreshBundle] pathForResource:language ofType:@"lproj"]]; } value = [bundle localizedStringForKey:key value:value table:nil]; return [[NSBundle mainBundle] localizedStringForKey:key value:value table:nil]; } @end ```
/content/code_sandbox/Pods/MJRefresh/MJRefresh/NSBundle+MJRefresh.m
objective-c
2016-02-02T02:51:55
2024-08-09T08:55:27
WMPlayer
zhengwenming/WMPlayer
3,272
537
```objective-c // : path_to_url // : path_to_url // UIScrollView+MJRefresh.h // MJRefreshExample // // Created by MJ Lee on 15/3/4. // ScrollView #import <UIKit/UIKit.h> #import "MJRefreshConst.h" @class MJRefreshHeader, MJRefreshFooter; NS_ASSUME_NONNULL_BEGIN @interface UIScrollView (MJRefresh) /** */ @property (strong, nonatomic, nullable) MJRefreshHeader *mj_header; @property (strong, nonatomic, nullable) MJRefreshHeader *header MJRefreshDeprecated("mj_header"); /** */ @property (strong, nonatomic, nullable) MJRefreshFooter *mj_footer; @property (strong, nonatomic, nullable) MJRefreshFooter *footer MJRefreshDeprecated("mj_footer"); #pragma mark - other - (NSInteger)mj_totalDataCount; @end NS_ASSUME_NONNULL_END ```
/content/code_sandbox/Pods/MJRefresh/MJRefresh/UIScrollView+MJRefresh.h
objective-c
2016-02-02T02:51:55
2024-08-09T08:55:27
WMPlayer
zhengwenming/WMPlayer
3,272
178
```objective-c // : path_to_url // : path_to_url // UIScrollView+Extension.h // MJRefreshExample // // Created by MJ Lee on 14-5-28. // #import <UIKit/UIKit.h> NS_ASSUME_NONNULL_BEGIN @interface UIScrollView (MJExtension) @property (readonly, nonatomic) UIEdgeInsets mj_inset; @property (assign, nonatomic) CGFloat mj_insetT; @property (assign, nonatomic) CGFloat mj_insetB; @property (assign, nonatomic) CGFloat mj_insetL; @property (assign, nonatomic) CGFloat mj_insetR; @property (assign, nonatomic) CGFloat mj_offsetX; @property (assign, nonatomic) CGFloat mj_offsetY; @property (assign, nonatomic) CGFloat mj_contentW; @property (assign, nonatomic) CGFloat mj_contentH; @end NS_ASSUME_NONNULL_END ```
/content/code_sandbox/Pods/MJRefresh/MJRefresh/UIScrollView+MJExtension.h
objective-c
2016-02-02T02:51:55
2024-08-09T08:55:27
WMPlayer
zhengwenming/WMPlayer
3,272
171
```objective-c // : path_to_url // : path_to_url // UIScrollView+MJRefresh.m // MJRefreshExample // // Created by MJ Lee on 15/3/4. // #import "UIScrollView+MJRefresh.h" #import "MJRefreshHeader.h" #import "MJRefreshFooter.h" #import <objc/runtime.h> @implementation UIScrollView (MJRefresh) #pragma mark - header static const char MJRefreshHeaderKey = '\0'; - (void)setMj_header:(MJRefreshHeader *)mj_header { if (mj_header != self.mj_header) { // [self.mj_header removeFromSuperview]; [self insertSubview:mj_header atIndex:0]; // objc_setAssociatedObject(self, &MJRefreshHeaderKey, mj_header, OBJC_ASSOCIATION_RETAIN); } } - (MJRefreshHeader *)mj_header { return objc_getAssociatedObject(self, &MJRefreshHeaderKey); } #pragma mark - footer static const char MJRefreshFooterKey = '\0'; - (void)setMj_footer:(MJRefreshFooter *)mj_footer { if (mj_footer != self.mj_footer) { // [self.mj_footer removeFromSuperview]; [self insertSubview:mj_footer atIndex:0]; // objc_setAssociatedObject(self, &MJRefreshFooterKey, mj_footer, OBJC_ASSOCIATION_RETAIN); } } - (MJRefreshFooter *)mj_footer { return objc_getAssociatedObject(self, &MJRefreshFooterKey); } #pragma mark - - (void)setFooter:(MJRefreshFooter *)footer { self.mj_footer = footer; } - (MJRefreshFooter *)footer { return self.mj_footer; } - (void)setHeader:(MJRefreshHeader *)header { self.mj_header = header; } - (MJRefreshHeader *)header { return self.mj_header; } #pragma mark - other - (NSInteger)mj_totalDataCount { NSInteger totalCount = 0; if ([self isKindOfClass:[UITableView class]]) { UITableView *tableView = (UITableView *)self; for (NSInteger section = 0; section < tableView.numberOfSections; section++) { totalCount += [tableView numberOfRowsInSection:section]; } } else if ([self isKindOfClass:[UICollectionView class]]) { UICollectionView *collectionView = (UICollectionView *)self; for (NSInteger section = 0; section < collectionView.numberOfSections; section++) { totalCount += [collectionView numberOfItemsInSection:section]; } } return totalCount; } @end ```
/content/code_sandbox/Pods/MJRefresh/MJRefresh/UIScrollView+MJRefresh.m
objective-c
2016-02-02T02:51:55
2024-08-09T08:55:27
WMPlayer
zhengwenming/WMPlayer
3,272
534
```objective-c // : path_to_url // : path_to_url #import "UIScrollView+MJRefresh.h" #import "UIScrollView+MJExtension.h" #import "UIView+MJExtension.h" #import "MJRefreshNormalHeader.h" #import "MJRefreshGifHeader.h" #import "MJRefreshBackNormalFooter.h" #import "MJRefreshBackGifFooter.h" #import "MJRefreshAutoNormalFooter.h" #import "MJRefreshAutoGifFooter.h" ```
/content/code_sandbox/Pods/MJRefresh/MJRefresh/MJRefresh.h
objective-c
2016-02-02T02:51:55
2024-08-09T08:55:27
WMPlayer
zhengwenming/WMPlayer
3,272
94
```objective-c // : path_to_url // : path_to_url // UIScrollView+Extension.m // MJRefreshExample // // Created by MJ Lee on 14-5-28. // #import "UIScrollView+MJExtension.h" #import <objc/runtime.h> #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wunguarded-availability-new" @implementation UIScrollView (MJExtension) static BOOL respondsToAdjustedContentInset_; + (void)initialize { static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ respondsToAdjustedContentInset_ = [self instancesRespondToSelector:@selector(adjustedContentInset)]; }); } - (UIEdgeInsets)mj_inset { #ifdef __IPHONE_11_0 if (respondsToAdjustedContentInset_) { return self.adjustedContentInset; } #endif return self.contentInset; } - (void)setMj_insetT:(CGFloat)mj_insetT { UIEdgeInsets inset = self.contentInset; inset.top = mj_insetT; #ifdef __IPHONE_11_0 if (respondsToAdjustedContentInset_) { inset.top -= (self.adjustedContentInset.top - self.contentInset.top); } #endif self.contentInset = inset; } - (CGFloat)mj_insetT { return self.mj_inset.top; } - (void)setMj_insetB:(CGFloat)mj_insetB { UIEdgeInsets inset = self.contentInset; inset.bottom = mj_insetB; #ifdef __IPHONE_11_0 if (respondsToAdjustedContentInset_) { inset.bottom -= (self.adjustedContentInset.bottom - self.contentInset.bottom); } #endif self.contentInset = inset; } - (CGFloat)mj_insetB { return self.mj_inset.bottom; } - (void)setMj_insetL:(CGFloat)mj_insetL { UIEdgeInsets inset = self.contentInset; inset.left = mj_insetL; #ifdef __IPHONE_11_0 if (respondsToAdjustedContentInset_) { inset.left -= (self.adjustedContentInset.left - self.contentInset.left); } #endif self.contentInset = inset; } - (CGFloat)mj_insetL { return self.mj_inset.left; } - (void)setMj_insetR:(CGFloat)mj_insetR { UIEdgeInsets inset = self.contentInset; inset.right = mj_insetR; #ifdef __IPHONE_11_0 if (respondsToAdjustedContentInset_) { inset.right -= (self.adjustedContentInset.right - self.contentInset.right); } #endif self.contentInset = inset; } - (CGFloat)mj_insetR { return self.mj_inset.right; } - (void)setMj_offsetX:(CGFloat)mj_offsetX { CGPoint offset = self.contentOffset; offset.x = mj_offsetX; self.contentOffset = offset; } - (CGFloat)mj_offsetX { return self.contentOffset.x; } - (void)setMj_offsetY:(CGFloat)mj_offsetY { CGPoint offset = self.contentOffset; offset.y = mj_offsetY; self.contentOffset = offset; } - (CGFloat)mj_offsetY { return self.contentOffset.y; } - (void)setMj_contentW:(CGFloat)mj_contentW { CGSize size = self.contentSize; size.width = mj_contentW; self.contentSize = size; } - (CGFloat)mj_contentW { return self.contentSize.width; } - (void)setMj_contentH:(CGFloat)mj_contentH { CGSize size = self.contentSize; size.height = mj_contentH; self.contentSize = size; } - (CGFloat)mj_contentH { return self.contentSize.height; } @end #pragma clang diagnostic pop ```
/content/code_sandbox/Pods/MJRefresh/MJRefresh/UIScrollView+MJExtension.m
objective-c
2016-02-02T02:51:55
2024-08-09T08:55:27
WMPlayer
zhengwenming/WMPlayer
3,272
820
```objective-c // : path_to_url // : path_to_url // MJRefreshFooter.h // MJRefreshExample // // Created by MJ Lee on 15/3/5. // #import "MJRefreshComponent.h" NS_ASSUME_NONNULL_BEGIN @interface MJRefreshFooter : MJRefreshComponent /** footer */ + (instancetype)footerWithRefreshingBlock:(MJRefreshComponentAction)refreshingBlock; /** footer */ + (instancetype)footerWithRefreshingTarget:(id)target refreshingAction:(SEL)action; /** */ - (void)endRefreshingWithNoMoreData; - (void)noticeNoMoreData MJRefreshDeprecated("endRefreshingWithNoMoreData"); /** */ - (void)resetNoMoreData; /** scrollViewcontentInsetbottom */ @property (assign, nonatomic) CGFloat ignoredScrollViewContentInsetBottom; /** NO */ @property (assign, nonatomic, getter=isAutomaticallyHidden) BOOL automaticallyHidden MJRefreshDeprecated("footer"); @end NS_ASSUME_NONNULL_END ```
/content/code_sandbox/Pods/MJRefresh/MJRefresh/Base/MJRefreshFooter.h
objective-c
2016-02-02T02:51:55
2024-08-09T08:55:27
WMPlayer
zhengwenming/WMPlayer
3,272
204
```objective-c // // MJRefreshConfig.h // // Created by Frank on 2018/11/27. // #import <Foundation/Foundation.h> NS_ASSUME_NONNULL_BEGIN @interface MJRefreshConfig : NSObject /** , nil. */ @property (copy, nonatomic, nullable) NSString *languageCode; /** @return Singleton Config instance */ + (instancetype)defaultConfig; - (instancetype)init NS_UNAVAILABLE; + (instancetype)new NS_UNAVAILABLE; @end NS_ASSUME_NONNULL_END ```
/content/code_sandbox/Pods/MJRefresh/MJRefresh/MJRefreshConfig.h
objective-c
2016-02-02T02:51:55
2024-08-09T08:55:27
WMPlayer
zhengwenming/WMPlayer
3,272
100
```objective-c // // MJRefreshBackFooter.h // MJRefreshExample // // Created by MJ Lee on 15/4/24. // #import "MJRefreshFooter.h" NS_ASSUME_NONNULL_BEGIN @interface MJRefreshBackFooter : MJRefreshFooter @end NS_ASSUME_NONNULL_END ```
/content/code_sandbox/Pods/MJRefresh/MJRefresh/Base/MJRefreshBackFooter.h
objective-c
2016-02-02T02:51:55
2024-08-09T08:55:27
WMPlayer
zhengwenming/WMPlayer
3,272
61
```objective-c // : path_to_url // : path_to_url // MJRefreshHeader.h // MJRefreshExample // // Created by MJ Lee on 15/3/4. // : #import "MJRefreshComponent.h" NS_ASSUME_NONNULL_BEGIN @interface MJRefreshHeader : MJRefreshComponent /** header */ + (instancetype)headerWithRefreshingBlock:(MJRefreshComponentAction)refreshingBlock; /** header */ + (instancetype)headerWithRefreshingTarget:(id)target refreshingAction:(SEL)action; /** key */ @property (copy, nonatomic) NSString *lastUpdatedTimeKey; /** */ @property (strong, nonatomic, readonly, nullable) NSDate *lastUpdatedTime; /** scrollViewcontentInsettop */ @property (assign, nonatomic) CGFloat ignoredScrollViewContentInsetTop; /** , CollectionView */ @property (nonatomic) BOOL isCollectionViewAnimationBug; @end NS_ASSUME_NONNULL_END ```
/content/code_sandbox/Pods/MJRefresh/MJRefresh/Base/MJRefreshHeader.h
objective-c
2016-02-02T02:51:55
2024-08-09T08:55:27
WMPlayer
zhengwenming/WMPlayer
3,272
188
```objective-c // // MJRefreshAutoFooter.m // MJRefreshExample // // Created by MJ Lee on 15/4/24. // #import "MJRefreshAutoFooter.h" @interface MJRefreshAutoFooter() /** */ @property (nonatomic) BOOL triggerByDrag; @property (nonatomic) NSInteger leftTriggerTimes; @end @implementation MJRefreshAutoFooter #pragma mark - - (void)willMoveToSuperview:(UIView *)newSuperview { [super willMoveToSuperview:newSuperview]; if (newSuperview) { // if (self.hidden == NO) { self.scrollView.mj_insetB += self.mj_h; } // self.mj_y = _scrollView.mj_contentH; } else { // if (self.hidden == NO) { self.scrollView.mj_insetB -= self.mj_h; } } } #pragma mark - - (void)setAppearencePercentTriggerAutoRefresh:(CGFloat)appearencePercentTriggerAutoRefresh { self.triggerAutomaticallyRefreshPercent = appearencePercentTriggerAutoRefresh; } - (CGFloat)appearencePercentTriggerAutoRefresh { return self.triggerAutomaticallyRefreshPercent; } #pragma mark - - (void)prepare { [super prepare]; // 100% self.triggerAutomaticallyRefreshPercent = 1.0; // self.automaticallyRefresh = YES; self.autoTriggerTimes = 1; } - (void)scrollViewContentSizeDidChange:(NSDictionary *)change { [super scrollViewContentSizeDidChange:change]; // self.mj_y = self.scrollView.mj_contentH + self.ignoredScrollViewContentInsetBottom; } - (void)scrollViewContentOffsetDidChange:(NSDictionary *)change { [super scrollViewContentOffsetDidChange:change]; if (self.state != MJRefreshStateIdle || !self.automaticallyRefresh || self.mj_y == 0) return; if (_scrollView.mj_insetT + _scrollView.mj_contentH > _scrollView.mj_h) { // // _scrollView.mj_contentHself.mj_y if (_scrollView.mj_offsetY >= _scrollView.mj_contentH - _scrollView.mj_h + self.mj_h * self.triggerAutomaticallyRefreshPercent + _scrollView.mj_insetB - self.mj_h) { // CGPoint old = [change[@"old"] CGPointValue]; CGPoint new = [change[@"new"] CGPointValue]; if (new.y <= old.y) return; if (_scrollView.isDragging) { self.triggerByDrag = YES; } // [self beginRefreshing]; } } } - (void)scrollViewPanStateDidChange:(NSDictionary *)change { [super scrollViewPanStateDidChange:change]; if (self.state != MJRefreshStateIdle) return; UIGestureRecognizerState panState = _scrollView.panGestureRecognizer.state; switch (panState) { // case UIGestureRecognizerStateEnded: { if (_scrollView.mj_insetT + _scrollView.mj_contentH <= _scrollView.mj_h) { // if (_scrollView.mj_offsetY >= - _scrollView.mj_insetT) { // self.triggerByDrag = YES; [self beginRefreshing]; } } else { // if (_scrollView.mj_offsetY >= _scrollView.mj_contentH + _scrollView.mj_insetB - _scrollView.mj_h) { self.triggerByDrag = YES; [self beginRefreshing]; } } } break; case UIGestureRecognizerStateBegan: { [self resetTriggerTimes]; } break; default: break; } } - (BOOL)unlimitedTrigger { return self.leftTriggerTimes == -1; } - (void)beginRefreshing { if (self.triggerByDrag && self.leftTriggerTimes <= 0 && !self.unlimitedTrigger) { return; } [super beginRefreshing]; } - (void)setState:(MJRefreshState)state { MJRefreshCheckState if (state == MJRefreshStateRefreshing) { [self executeRefreshingCallback]; } else if (state == MJRefreshStateNoMoreData || state == MJRefreshStateIdle) { if (self.triggerByDrag) { if (!self.unlimitedTrigger) { self.leftTriggerTimes -= 1; } self.triggerByDrag = NO; } if (MJRefreshStateRefreshing == oldState) { if (self.scrollView.pagingEnabled) { CGPoint offset = self.scrollView.contentOffset; offset.y -= self.scrollView.mj_insetB; [UIView animateWithDuration:MJRefreshSlowAnimationDuration animations:^{ self.scrollView.contentOffset = offset; if (self.endRefreshingAnimationBeginAction) { self.endRefreshingAnimationBeginAction(); } } completion:^(BOOL finished) { if (self.endRefreshingCompletionBlock) { self.endRefreshingCompletionBlock(); } }]; return; } if (self.endRefreshingCompletionBlock) { self.endRefreshingCompletionBlock(); } } } } - (void)resetTriggerTimes { self.leftTriggerTimes = self.autoTriggerTimes; } - (void)setHidden:(BOOL)hidden { BOOL lastHidden = self.isHidden; [super setHidden:hidden]; if (!lastHidden && hidden) { self.state = MJRefreshStateIdle; self.scrollView.mj_insetB -= self.mj_h; } else if (lastHidden && !hidden) { self.scrollView.mj_insetB += self.mj_h; // self.mj_y = _scrollView.mj_contentH; } } - (void)setAutoTriggerTimes:(NSInteger)autoTriggerTimes { _autoTriggerTimes = autoTriggerTimes; self.leftTriggerTimes = autoTriggerTimes; } @end ```
/content/code_sandbox/Pods/MJRefresh/MJRefresh/Base/MJRefreshAutoFooter.m
objective-c
2016-02-02T02:51:55
2024-08-09T08:55:27
WMPlayer
zhengwenming/WMPlayer
3,272
1,227
```objective-c // : path_to_url // : path_to_url // MJRefreshComponent.h // MJRefreshExample // // Created by MJ Lee on 15/3/4. // #import <UIKit/UIKit.h> #import "MJRefreshConst.h" #import "UIView+MJExtension.h" #import "UIScrollView+MJExtension.h" #import "UIScrollView+MJRefresh.h" #import "NSBundle+MJRefresh.h" NS_ASSUME_NONNULL_BEGIN /** */ typedef NS_ENUM(NSInteger, MJRefreshState) { /** */ MJRefreshStateIdle = 1, /** */ MJRefreshStatePulling, /** */ MJRefreshStateRefreshing, /** */ MJRefreshStateWillRefresh, /** */ MJRefreshStateNoMoreData }; /** */ typedef void (^MJRefreshComponentRefreshingBlock)(void) MJRefreshDeprecated("first deprecated in 3.3.0 - Use `MJRefreshComponentAction` instead"); /** () */ typedef void (^MJRefreshComponentBeginRefreshingCompletionBlock)(void) MJRefreshDeprecated("first deprecated in 3.3.0 - Use `MJRefreshComponentAction` instead"); /** */ typedef void (^MJRefreshComponentEndRefreshingCompletionBlock)(void) MJRefreshDeprecated("first deprecated in 3.3.0 - Use `MJRefreshComponentAction` instead"); /** */ typedef void (^MJRefreshComponentAction)(void); /** */ @interface MJRefreshComponent : UIView { /** scrollViewinset */ UIEdgeInsets _scrollViewOriginalInset; /** */ __weak UIScrollView *_scrollView; } #pragma mark - /** */ @property (copy, nonatomic, nullable) MJRefreshComponentAction refreshingBlock; /** */ - (void)setRefreshingTarget:(id)target refreshingAction:(SEL)action; /** */ @property (weak, nonatomic) id refreshingTarget; /** */ @property (assign, nonatomic) SEL refreshingAction; /** */ - (void)executeRefreshingCallback; #pragma mark - /** */ - (void)beginRefreshing; - (void)beginRefreshingWithCompletionBlock:(void (^)(void))completionBlock; /** () */ @property (copy, nonatomic, nullable) MJRefreshComponentAction beginRefreshingCompletionBlock; /** */ @property (copy, nonatomic, nullable) MJRefreshComponentAction endRefreshingAnimateCompletionBlock MJRefreshDeprecated("first deprecated in 3.3.0 - Use `endRefreshingAnimationBeginAction` instead"); @property (copy, nonatomic, nullable) MJRefreshComponentAction endRefreshingAnimationBeginAction; /** */ @property (copy, nonatomic, nullable) MJRefreshComponentAction endRefreshingCompletionBlock; /** */ - (void)endRefreshing; - (void)endRefreshingWithCompletionBlock:(void (^)(void))completionBlock; /** */ @property (assign, nonatomic, readonly, getter=isRefreshing) BOOL refreshing; /** */ @property (assign, nonatomic) MJRefreshState state; #pragma mark - /** scrollViewinset */ @property (assign, nonatomic, readonly) UIEdgeInsets scrollViewOriginalInset; /** */ @property (weak, nonatomic, readonly) UIScrollView *scrollView; #pragma mark - /** */ - (void)prepare NS_REQUIRES_SUPER; /** frame */ - (void)placeSubviews NS_REQUIRES_SUPER; /** scrollViewcontentOffset */ - (void)scrollViewContentOffsetDidChange:(nullable NSDictionary *)change NS_REQUIRES_SUPER; /** scrollViewcontentSize */ - (void)scrollViewContentSizeDidChange:(nullable NSDictionary *)change NS_REQUIRES_SUPER; /** scrollView */ - (void)scrollViewPanStateDidChange:(nullable NSDictionary *)change NS_REQUIRES_SUPER; #pragma mark - /** () */ @property (assign, nonatomic) CGFloat pullingPercent; /** */ @property (assign, nonatomic, getter=isAutoChangeAlpha) BOOL autoChangeAlpha MJRefreshDeprecated("automaticallyChangeAlpha"); /** */ @property (assign, nonatomic, getter=isAutomaticallyChangeAlpha) BOOL automaticallyChangeAlpha; @end @interface UILabel(MJRefresh) + (instancetype)mj_label; - (CGFloat)mj_textWidth; @end NS_ASSUME_NONNULL_END ```
/content/code_sandbox/Pods/MJRefresh/MJRefresh/Base/MJRefreshComponent.h
objective-c
2016-02-02T02:51:55
2024-08-09T08:55:27
WMPlayer
zhengwenming/WMPlayer
3,272
831
```objective-c // : path_to_url // : path_to_url // MJRefreshHeader.m // MJRefreshExample // // Created by MJ Lee on 15/3/4. // #import "MJRefreshHeader.h" NSString * const MJRefreshHeaderRefreshing2IdleBoundsKey = @"MJRefreshHeaderRefreshing2IdleBounds"; NSString * const MJRefreshHeaderRefreshingBoundsKey = @"MJRefreshHeaderRefreshingBounds"; @interface MJRefreshHeader() <CAAnimationDelegate> @property (assign, nonatomic) CGFloat insetTDelta; @end @implementation MJRefreshHeader #pragma mark - + (instancetype)headerWithRefreshingBlock:(MJRefreshComponentAction)refreshingBlock { MJRefreshHeader *cmp = [[self alloc] init]; cmp.refreshingBlock = refreshingBlock; return cmp; } + (instancetype)headerWithRefreshingTarget:(id)target refreshingAction:(SEL)action { MJRefreshHeader *cmp = [[self alloc] init]; [cmp setRefreshingTarget:target refreshingAction:action]; return cmp; } #pragma mark - - (void)prepare { [super prepare]; // key self.lastUpdatedTimeKey = MJRefreshHeaderLastUpdatedTimeKey; // self.mj_h = MJRefreshHeaderHeight; } - (void)placeSubviews { [super placeSubviews]; // y(YplaceSubviewsy) self.mj_y = - self.mj_h - self.ignoredScrollViewContentInsetTop; } - (void)resetInset { if (@available(iOS 11.0, *)) { } else { // iOS 10 , push VC, , Insets.top , resetInset, if (!self.window) { return; } } // sectionheader CGFloat insetT = - self.scrollView.mj_offsetY > _scrollViewOriginalInset.top ? - self.scrollView.mj_offsetY : _scrollViewOriginalInset.top; insetT = insetT > self.mj_h + _scrollViewOriginalInset.top ? self.mj_h + _scrollViewOriginalInset.top : insetT; self.insetTDelta = _scrollViewOriginalInset.top - insetT; // CollectionView Autolayout Cell, Layout if (self.scrollView.mj_insetT != insetT) { self.scrollView.mj_insetT = insetT; } } - (void)scrollViewContentOffsetDidChange:(NSDictionary *)change { [super scrollViewContentOffsetDidChange:change]; // refreshing if (self.state == MJRefreshStateRefreshing) { [self resetInset]; return; } // contentInset _scrollViewOriginalInset = self.scrollView.mj_inset; // contentOffset CGFloat offsetY = self.scrollView.mj_offsetY; // offsetY CGFloat happenOffsetY = - self.scrollViewOriginalInset.top; // // >= -> > if (offsetY > happenOffsetY) return; // CGFloat normal2pullingOffsetY = happenOffsetY - self.mj_h; CGFloat pullingPercent = (happenOffsetY - offsetY) / self.mj_h; if (self.scrollView.isDragging) { // self.pullingPercent = pullingPercent; if (self.state == MJRefreshStateIdle && offsetY < normal2pullingOffsetY) { // self.state = MJRefreshStatePulling; } else if (self.state == MJRefreshStatePulling && offsetY >= normal2pullingOffsetY) { // self.state = MJRefreshStateIdle; } } else if (self.state == MJRefreshStatePulling) {// && // [self beginRefreshing]; } else if (pullingPercent < 1) { self.pullingPercent = pullingPercent; } } - (void)setState:(MJRefreshState)state { MJRefreshCheckState // if (state == MJRefreshStateIdle) { if (oldState != MJRefreshStateRefreshing) return; [self headerEndingAction]; } else if (state == MJRefreshStateRefreshing) { [self headerRefreshingAction]; } } - (void)headerEndingAction { // [[NSUserDefaults standardUserDefaults] setObject:[NSDate date] forKey:self.lastUpdatedTimeKey]; [[NSUserDefaults standardUserDefaults] synchronize]; // UIViewAnimation if (!self.isCollectionViewAnimationBug) { // insetoffset [UIView animateWithDuration:MJRefreshSlowAnimationDuration animations:^{ self.scrollView.mj_insetT += self.insetTDelta; if (self.endRefreshingAnimationBeginAction) { self.endRefreshingAnimationBeginAction(); } // if (self.isAutomaticallyChangeAlpha) self.alpha = 0.0; } completion:^(BOOL finished) { self.pullingPercent = 0.0; if (self.endRefreshingCompletionBlock) { self.endRefreshingCompletionBlock(); } }]; return; } /** path_to_url + [UIView animateWithDuration: animations:]contentInset fix issue#225 path_to_url pull#737 path_to_url , Refreshing . */ // Inset self.pullingPercent self.alpha, alpha , alpha CGFloat viewAlpha = self.alpha; self.scrollView.mj_insetT += self.insetTDelta; // , . self.scrollView.userInteractionEnabled = NO; //CAAnimation keyPath contentInset Bounds CABasicAnimation *boundsAnimation = [CABasicAnimation animationWithKeyPath:@"bounds"]; boundsAnimation.fromValue = [NSValue valueWithCGRect:CGRectOffset(self.scrollView.bounds, 0, self.insetTDelta)]; boundsAnimation.duration = MJRefreshSlowAnimationDuration; //delegate boundsAnimation.removedOnCompletion = NO; boundsAnimation.fillMode = kCAFillModeBoth; boundsAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; boundsAnimation.delegate = self; [boundsAnimation setValue:MJRefreshHeaderRefreshing2IdleBoundsKey forKey:@"identity"]; [self.scrollView.layer addAnimation:boundsAnimation forKey:MJRefreshHeaderRefreshing2IdleBoundsKey]; if (self.endRefreshingAnimationBeginAction) { self.endRefreshingAnimationBeginAction(); } // if (self.isAutomaticallyChangeAlpha) { CABasicAnimation *opacityAnimation = [CABasicAnimation animationWithKeyPath:@"opacity"]; opacityAnimation.fromValue = @(viewAlpha); opacityAnimation.toValue = @(0.0); opacityAnimation.duration = MJRefreshSlowAnimationDuration; opacityAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; [self.layer addAnimation:opacityAnimation forKey:@"MJRefreshHeaderRefreshing2IdleOpacity"]; // inset , pullingPercent , alpha 0 . 0, , , 0. self.alpha = 0; } } - (void)headerRefreshingAction { // UIViewAnimation if (!self.isCollectionViewAnimationBug) { MJRefreshDispatchAsyncOnMainQueue({ [UIView animateWithDuration:MJRefreshFastAnimationDuration animations:^{ if (self.scrollView.panGestureRecognizer.state != UIGestureRecognizerStateCancelled) { CGFloat top = self.scrollViewOriginalInset.top + self.mj_h; // top self.scrollView.mj_insetT = top; // CGPoint offset = self.scrollView.contentOffset; offset.y = -top; [self.scrollView setContentOffset:offset animated:NO]; } } completion:^(BOOL finished) { [self executeRefreshingCallback]; }]; }) return; } if (self.scrollView.panGestureRecognizer.state != UIGestureRecognizerStateCancelled) { CGFloat top = self.scrollViewOriginalInset.top + self.mj_h; // , . self.scrollView.userInteractionEnabled = NO; // CAAnimation keyPath contentOffset Bounds CABasicAnimation *boundsAnimation = [CABasicAnimation animationWithKeyPath:@"bounds"]; CGRect bounds = self.scrollView.bounds; bounds.origin.y = -top; boundsAnimation.fromValue = [NSValue valueWithCGRect:self.scrollView.bounds]; boundsAnimation.toValue = [NSValue valueWithCGRect:bounds]; boundsAnimation.duration = MJRefreshFastAnimationDuration; //delegate boundsAnimation.removedOnCompletion = NO; boundsAnimation.fillMode = kCAFillModeBoth; boundsAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; boundsAnimation.delegate = self; [boundsAnimation setValue:MJRefreshHeaderRefreshingBoundsKey forKey:@"identity"]; [self.scrollView.layer addAnimation:boundsAnimation forKey:MJRefreshHeaderRefreshingBoundsKey]; } else { [self executeRefreshingCallback]; } } #pragma mark - CAAnimationDelegate - (void)animationDidStop:(CAAnimation *)anim finished:(BOOL)flag { NSString *identity = [anim valueForKey:@"identity"]; if ([identity isEqualToString:MJRefreshHeaderRefreshing2IdleBoundsKey]) { self.pullingPercent = 0.0; self.scrollView.userInteractionEnabled = YES; if (self.endRefreshingCompletionBlock) { self.endRefreshingCompletionBlock(); } } else if ([identity isEqualToString:MJRefreshHeaderRefreshingBoundsKey]) { // end Refreshing if (self.state != MJRefreshStateIdle) { CGFloat top = self.scrollViewOriginalInset.top + self.mj_h; self.scrollView.mj_insetT = top; // CGPoint offset = self.scrollView.contentOffset; offset.y = -top; [self.scrollView setContentOffset:offset animated:NO]; } self.scrollView.userInteractionEnabled = YES; [self executeRefreshingCallback]; } if ([self.scrollView.layer animationForKey:MJRefreshHeaderRefreshing2IdleBoundsKey]) { [self.scrollView.layer removeAnimationForKey:MJRefreshHeaderRefreshing2IdleBoundsKey]; } if ([self.scrollView.layer animationForKey:MJRefreshHeaderRefreshingBoundsKey]) { [self.scrollView.layer removeAnimationForKey:MJRefreshHeaderRefreshingBoundsKey]; } } #pragma mark - - (NSDate *)lastUpdatedTime { return [[NSUserDefaults standardUserDefaults] objectForKey:self.lastUpdatedTimeKey]; } - (void)setIgnoredScrollViewContentInsetTop:(CGFloat)ignoredScrollViewContentInsetTop { _ignoredScrollViewContentInsetTop = ignoredScrollViewContentInsetTop; self.mj_y = - self.mj_h - _ignoredScrollViewContentInsetTop; } @end ```
/content/code_sandbox/Pods/MJRefresh/MJRefresh/Base/MJRefreshHeader.m
objective-c
2016-02-02T02:51:55
2024-08-09T08:55:27
WMPlayer
zhengwenming/WMPlayer
3,272
2,207
```objective-c // // MJRefreshBackFooter.m // MJRefreshExample // // Created by MJ Lee on 15/4/24. // #import "MJRefreshBackFooter.h" @interface MJRefreshBackFooter() @property (assign, nonatomic) NSInteger lastRefreshCount; @property (assign, nonatomic) CGFloat lastBottomDelta; @end @implementation MJRefreshBackFooter #pragma mark - - (void)willMoveToSuperview:(UIView *)newSuperview { [super willMoveToSuperview:newSuperview]; [self scrollViewContentSizeDidChange:nil]; } #pragma mark - - (void)scrollViewContentOffsetDidChange:(NSDictionary *)change { [super scrollViewContentOffsetDidChange:change]; // if (self.state == MJRefreshStateRefreshing) return; _scrollViewOriginalInset = self.scrollView.mj_inset; // contentOffset CGFloat currentOffsetY = self.scrollView.mj_offsetY; // offsetY CGFloat happenOffsetY = [self happenOffsetY]; // if (currentOffsetY <= happenOffsetY) return; CGFloat pullingPercent = (currentOffsetY - happenOffsetY) / self.mj_h; // pullingPercent if (self.state == MJRefreshStateNoMoreData) { self.pullingPercent = pullingPercent; return; } if (self.scrollView.isDragging) { self.pullingPercent = pullingPercent; // CGFloat normal2pullingOffsetY = happenOffsetY + self.mj_h; if (self.state == MJRefreshStateIdle && currentOffsetY > normal2pullingOffsetY) { // self.state = MJRefreshStatePulling; } else if (self.state == MJRefreshStatePulling && currentOffsetY <= normal2pullingOffsetY) { // self.state = MJRefreshStateIdle; } } else if (self.state == MJRefreshStatePulling) {// && // [self beginRefreshing]; } else if (pullingPercent < 1) { self.pullingPercent = pullingPercent; } } - (void)scrollViewContentSizeDidChange:(NSDictionary *)change { [super scrollViewContentSizeDidChange:change]; // CGFloat contentHeight = self.scrollView.mj_contentH + self.ignoredScrollViewContentInsetBottom; // CGFloat scrollHeight = self.scrollView.mj_h - self.scrollViewOriginalInset.top - self.scrollViewOriginalInset.bottom + self.ignoredScrollViewContentInsetBottom; // self.mj_y = MAX(contentHeight, scrollHeight); } - (void)setState:(MJRefreshState)state { MJRefreshCheckState // if (state == MJRefreshStateNoMoreData || state == MJRefreshStateIdle) { // if (MJRefreshStateRefreshing == oldState) { [UIView animateWithDuration:MJRefreshSlowAnimationDuration animations:^{ if (self.endRefreshingAnimationBeginAction) { self.endRefreshingAnimationBeginAction(); } self.scrollView.mj_insetB -= self.lastBottomDelta; // if (self.isAutomaticallyChangeAlpha) self.alpha = 0.0; } completion:^(BOOL finished) { self.pullingPercent = 0.0; if (self.endRefreshingCompletionBlock) { self.endRefreshingCompletionBlock(); } }]; } CGFloat deltaH = [self heightForContentBreakView]; // if (MJRefreshStateRefreshing == oldState && deltaH > 0 && self.scrollView.mj_totalDataCount != self.lastRefreshCount) { self.scrollView.mj_offsetY = self.scrollView.mj_offsetY; } } else if (state == MJRefreshStateRefreshing) { // self.lastRefreshCount = self.scrollView.mj_totalDataCount; [UIView animateWithDuration:MJRefreshFastAnimationDuration animations:^{ CGFloat bottom = self.mj_h + self.scrollViewOriginalInset.bottom; CGFloat deltaH = [self heightForContentBreakView]; if (deltaH < 0) { // view bottom -= deltaH; } self.lastBottomDelta = bottom - self.scrollView.mj_insetB; self.scrollView.mj_insetB = bottom; self.scrollView.mj_offsetY = [self happenOffsetY] + self.mj_h; } completion:^(BOOL finished) { [self executeRefreshingCallback]; }]; } } #pragma mark - #pragma mark scrollView view - (CGFloat)heightForContentBreakView { CGFloat h = self.scrollView.frame.size.height - self.scrollViewOriginalInset.bottom - self.scrollViewOriginalInset.top; return self.scrollView.contentSize.height - h; } #pragma mark contentOffset.y - (CGFloat)happenOffsetY { CGFloat deltaH = [self heightForContentBreakView]; if (deltaH > 0) { return deltaH - self.scrollViewOriginalInset.top; } else { return - self.scrollViewOriginalInset.top; } } @end ```
/content/code_sandbox/Pods/MJRefresh/MJRefresh/Base/MJRefreshBackFooter.m
objective-c
2016-02-02T02:51:55
2024-08-09T08:55:27
WMPlayer
zhengwenming/WMPlayer
3,272
1,040
```objective-c // : path_to_url // : path_to_url // MJRefreshComponent.m // MJRefreshExample // // Created by MJ Lee on 15/3/4. // #import "MJRefreshComponent.h" #import "MJRefreshConst.h" @interface MJRefreshComponent() @property (strong, nonatomic) UIPanGestureRecognizer *pan; @end @implementation MJRefreshComponent #pragma mark - - (instancetype)initWithFrame:(CGRect)frame { if (self = [super initWithFrame:frame]) { // [self prepare]; // self.state = MJRefreshStateIdle; } return self; } - (void)prepare { // self.autoresizingMask = UIViewAutoresizingFlexibleWidth; self.backgroundColor = [UIColor clearColor]; } - (void)layoutSubviews { [self placeSubviews]; [super layoutSubviews]; } - (void)placeSubviews{} - (void)willMoveToSuperview:(UIView *)newSuperview { [super willMoveToSuperview:newSuperview]; // UIScrollView if (newSuperview && ![newSuperview isKindOfClass:[UIScrollView class]]) return; // [self removeObservers]; if (newSuperview) { // // UIScrollView _scrollView = (UIScrollView *)newSuperview; // self.mj_w = _scrollView.mj_w; // self.mj_x = -_scrollView.mj_insetL; // _scrollView.alwaysBounceVertical = YES; // UIScrollViewcontentInset _scrollViewOriginalInset = _scrollView.mj_inset; // [self addObservers]; } } - (void)drawRect:(CGRect)rect { [super drawRect:rect]; if (self.state == MJRefreshStateWillRefresh) { // viewbeginRefreshing self.state = MJRefreshStateRefreshing; } } #pragma mark - KVO - (void)addObservers { NSKeyValueObservingOptions options = NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld; [self.scrollView addObserver:self forKeyPath:MJRefreshKeyPathContentOffset options:options context:nil]; [self.scrollView addObserver:self forKeyPath:MJRefreshKeyPathContentSize options:options context:nil]; self.pan = self.scrollView.panGestureRecognizer; [self.pan addObserver:self forKeyPath:MJRefreshKeyPathPanState options:options context:nil]; } - (void)removeObservers { [self.superview removeObserver:self forKeyPath:MJRefreshKeyPathContentOffset]; [self.superview removeObserver:self forKeyPath:MJRefreshKeyPathContentSize]; [self.pan removeObserver:self forKeyPath:MJRefreshKeyPathPanState]; self.pan = nil; } - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { // if (!self.userInteractionEnabled) return; // if ([keyPath isEqualToString:MJRefreshKeyPathContentSize]) { [self scrollViewContentSizeDidChange:change]; } // if (self.hidden) return; if ([keyPath isEqualToString:MJRefreshKeyPathContentOffset]) { [self scrollViewContentOffsetDidChange:change]; } else if ([keyPath isEqualToString:MJRefreshKeyPathPanState]) { [self scrollViewPanStateDidChange:change]; } } - (void)scrollViewContentOffsetDidChange:(NSDictionary *)change{} - (void)scrollViewContentSizeDidChange:(NSDictionary *)change{} - (void)scrollViewPanStateDidChange:(NSDictionary *)change{} #pragma mark - #pragma mark - (void)setRefreshingTarget:(id)target refreshingAction:(SEL)action { self.refreshingTarget = target; self.refreshingAction = action; } - (void)setState:(MJRefreshState)state { _state = state; // setState: MJRefreshDispatchAsyncOnMainQueue([self setNeedsLayout];) } #pragma mark - (void)beginRefreshing { [UIView animateWithDuration:MJRefreshFastAnimationDuration animations:^{ self.alpha = 1.0; }]; self.pullingPercent = 1.0; // if (self.window) { self.state = MJRefreshStateRefreshing; } else { // header inset if (self.state != MJRefreshStateRefreshing) { self.state = MJRefreshStateWillRefresh; // () [self setNeedsDisplay]; } } } - (void)beginRefreshingWithCompletionBlock:(void (^)(void))completionBlock { self.beginRefreshingCompletionBlock = completionBlock; [self beginRefreshing]; } #pragma mark - (void)endRefreshing { MJRefreshDispatchAsyncOnMainQueue(self.state = MJRefreshStateIdle;) } - (void)endRefreshingWithCompletionBlock:(void (^)(void))completionBlock { self.endRefreshingCompletionBlock = completionBlock; [self endRefreshing]; } #pragma mark - (BOOL)isRefreshing { return self.state == MJRefreshStateRefreshing || self.state == MJRefreshStateWillRefresh; } #pragma mark - (void)setAutoChangeAlpha:(BOOL)autoChangeAlpha { self.automaticallyChangeAlpha = autoChangeAlpha; } - (BOOL)isAutoChangeAlpha { return self.isAutomaticallyChangeAlpha; } - (void)setAutomaticallyChangeAlpha:(BOOL)automaticallyChangeAlpha { _automaticallyChangeAlpha = automaticallyChangeAlpha; if (self.isRefreshing) return; if (automaticallyChangeAlpha) { self.alpha = self.pullingPercent; } else { self.alpha = 1.0; } } #pragma mark - (void)setPullingPercent:(CGFloat)pullingPercent { _pullingPercent = pullingPercent; if (self.isRefreshing) return; if (self.isAutomaticallyChangeAlpha) { self.alpha = pullingPercent; } } #pragma mark - - (void)executeRefreshingCallback { MJRefreshDispatchAsyncOnMainQueue({ if (self.refreshingBlock) { self.refreshingBlock(); } if ([self.refreshingTarget respondsToSelector:self.refreshingAction]) { MJRefreshMsgSend(MJRefreshMsgTarget(self.refreshingTarget), self.refreshingAction, self); } if (self.beginRefreshingCompletionBlock) { self.beginRefreshingCompletionBlock(); } }) } #pragma mark - <<< Deprecation compatible function >>> - - (void)setEndRefreshingAnimateCompletionBlock:(MJRefreshComponentEndRefreshingCompletionBlock)endRefreshingAnimateCompletionBlock { _endRefreshingAnimationBeginAction = endRefreshingAnimateCompletionBlock; } @end @implementation UILabel(MJRefresh) + (instancetype)mj_label { UILabel *label = [[self alloc] init]; label.font = MJRefreshLabelFont; label.textColor = MJRefreshLabelTextColor; label.autoresizingMask = UIViewAutoresizingFlexibleWidth; label.textAlignment = NSTextAlignmentCenter; label.backgroundColor = [UIColor clearColor]; return label; } - (CGFloat)mj_textWidth { CGFloat stringWidth = 0; CGSize size = CGSizeMake(MAXFLOAT, MAXFLOAT); if (self.attributedText) { if (self.attributedText.length == 0) { return 0; } stringWidth = [self.attributedText boundingRectWithSize:size options:NSStringDrawingUsesLineFragmentOrigin context:nil].size.width; } else { if (self.text.length == 0) { return 0; } NSAssert(self.font != nil, @" mj_label's `font` "); stringWidth = [self.text boundingRectWithSize:size options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:self.font} context:nil].size.width; } return stringWidth; } @end ```
/content/code_sandbox/Pods/MJRefresh/MJRefresh/Base/MJRefreshComponent.m
objective-c
2016-02-02T02:51:55
2024-08-09T08:55:27
WMPlayer
zhengwenming/WMPlayer
3,272
1,654
```objective-c // : path_to_url // : path_to_url // MJRefreshFooter.m // MJRefreshExample // // Created by MJ Lee on 15/3/5. // #import "MJRefreshFooter.h" #include "UIScrollView+MJRefresh.h" @interface MJRefreshFooter() @end @implementation MJRefreshFooter #pragma mark - + (instancetype)footerWithRefreshingBlock:(MJRefreshComponentAction)refreshingBlock { MJRefreshFooter *cmp = [[self alloc] init]; cmp.refreshingBlock = refreshingBlock; return cmp; } + (instancetype)footerWithRefreshingTarget:(id)target refreshingAction:(SEL)action { MJRefreshFooter *cmp = [[self alloc] init]; [cmp setRefreshingTarget:target refreshingAction:action]; return cmp; } #pragma mark - - (void)prepare { [super prepare]; // self.mj_h = MJRefreshFooterHeight; // // self.automaticallyHidden = NO; } #pragma mark - - (void)endRefreshingWithNoMoreData { MJRefreshDispatchAsyncOnMainQueue(self.state = MJRefreshStateNoMoreData;) } - (void)noticeNoMoreData { [self endRefreshingWithNoMoreData]; } - (void)resetNoMoreData { MJRefreshDispatchAsyncOnMainQueue(self.state = MJRefreshStateIdle;) } - (void)setAutomaticallyHidden:(BOOL)automaticallyHidden { _automaticallyHidden = automaticallyHidden; } @end ```
/content/code_sandbox/Pods/MJRefresh/MJRefresh/Base/MJRefreshFooter.m
objective-c
2016-02-02T02:51:55
2024-08-09T08:55:27
WMPlayer
zhengwenming/WMPlayer
3,272
328
```objective-c // // MJRefreshAutoFooter.h // MJRefreshExample // // Created by MJ Lee on 15/4/24. // #import "MJRefreshFooter.h" NS_ASSUME_NONNULL_BEGIN @interface MJRefreshAutoFooter : MJRefreshFooter /** (YES) */ @property (assign, nonatomic, getter=isAutomaticallyRefresh) BOOL automaticallyRefresh; /** (1.0) */ @property (assign, nonatomic) CGFloat appearencePercentTriggerAutoRefresh MJRefreshDeprecated("triggerAutomaticallyRefreshPercent"); /** (1.0) */ @property (assign, nonatomic) CGFloat triggerAutomaticallyRefreshPercent; /** , 1, ScrollView , -1, */ @property (nonatomic) NSInteger autoTriggerTimes; @end NS_ASSUME_NONNULL_END ```
/content/code_sandbox/Pods/MJRefresh/MJRefresh/Base/MJRefreshAutoFooter.h
objective-c
2016-02-02T02:51:55
2024-08-09T08:55:27
WMPlayer
zhengwenming/WMPlayer
3,272
157
```objective-c // // MJRefreshBackGifFooter.h // MJRefreshExample // // Created by MJ Lee on 15/4/24. // #import "MJRefreshBackStateFooter.h" NS_ASSUME_NONNULL_BEGIN @interface MJRefreshBackGifFooter : MJRefreshBackStateFooter @property (weak, nonatomic, readonly) UIImageView *gifView; /** stateimages duration*/ - (void)setImages:(NSArray *)images duration:(NSTimeInterval)duration forState:(MJRefreshState)state; - (void)setImages:(NSArray *)images forState:(MJRefreshState)state; @end NS_ASSUME_NONNULL_END ```
/content/code_sandbox/Pods/MJRefresh/MJRefresh/Custom/Footer/Back/MJRefreshBackGifFooter.h
objective-c
2016-02-02T02:51:55
2024-08-09T08:55:27
WMPlayer
zhengwenming/WMPlayer
3,272
127
```objective-c // // MJRefreshBackStateFooter.m // MJRefreshExample // // Created by MJ Lee on 15/6/13. // #import "MJRefreshBackStateFooter.h" @interface MJRefreshBackStateFooter() { /** label */ __unsafe_unretained UILabel *_stateLabel; } /** */ @property (strong, nonatomic) NSMutableDictionary *stateTitles; @end @implementation MJRefreshBackStateFooter #pragma mark - - (NSMutableDictionary *)stateTitles { if (!_stateTitles) { self.stateTitles = [NSMutableDictionary dictionary]; } return _stateTitles; } - (UILabel *)stateLabel { if (!_stateLabel) { [self addSubview:_stateLabel = [UILabel mj_label]]; } return _stateLabel; } #pragma mark - - (void)setTitle:(NSString *)title forState:(MJRefreshState)state { if (title == nil) return; self.stateTitles[@(state)] = title; self.stateLabel.text = self.stateTitles[@(self.state)]; } - (NSString *)titleForState:(MJRefreshState)state { return self.stateTitles[@(state)]; } #pragma mark - - (void)prepare { [super prepare]; // self.labelLeftInset = MJRefreshLabelLeftInset; // [self setTitle:[NSBundle mj_localizedStringForKey:MJRefreshBackFooterIdleText] forState:MJRefreshStateIdle]; [self setTitle:[NSBundle mj_localizedStringForKey:MJRefreshBackFooterPullingText] forState:MJRefreshStatePulling]; [self setTitle:[NSBundle mj_localizedStringForKey:MJRefreshBackFooterRefreshingText] forState:MJRefreshStateRefreshing]; [self setTitle:[NSBundle mj_localizedStringForKey:MJRefreshBackFooterNoMoreDataText] forState:MJRefreshStateNoMoreData]; } - (void)placeSubviews { [super placeSubviews]; if (self.stateLabel.constraints.count) return; // self.stateLabel.frame = self.bounds; } - (void)setState:(MJRefreshState)state { MJRefreshCheckState // self.stateLabel.text = self.stateTitles[@(state)]; } @end ```
/content/code_sandbox/Pods/MJRefresh/MJRefresh/Custom/Footer/Back/MJRefreshBackStateFooter.m
objective-c
2016-02-02T02:51:55
2024-08-09T08:55:27
WMPlayer
zhengwenming/WMPlayer
3,272
468
```objective-c // // MJRefreshBackNormalFooter.h // MJRefreshExample // // Created by MJ Lee on 15/4/24. // #import "MJRefreshBackStateFooter.h" NS_ASSUME_NONNULL_BEGIN @interface MJRefreshBackNormalFooter : MJRefreshBackStateFooter @property (weak, nonatomic, readonly) UIImageView *arrowView; @property (weak, nonatomic, readonly) UIActivityIndicatorView *loadingView; /** */ @property (assign, nonatomic) UIActivityIndicatorViewStyle activityIndicatorViewStyle MJRefreshDeprecated("first deprecated in 3.2.2 - Use `loadingView` property"); @end NS_ASSUME_NONNULL_END ```
/content/code_sandbox/Pods/MJRefresh/MJRefresh/Custom/Footer/Back/MJRefreshBackNormalFooter.h
objective-c
2016-02-02T02:51:55
2024-08-09T08:55:27
WMPlayer
zhengwenming/WMPlayer
3,272
131
```objective-c // // MJRefreshBackGifFooter.m // MJRefreshExample // // Created by MJ Lee on 15/4/24. // #import "MJRefreshBackGifFooter.h" @interface MJRefreshBackGifFooter() { __unsafe_unretained UIImageView *_gifView; } /** */ @property (strong, nonatomic) NSMutableDictionary *stateImages; /** */ @property (strong, nonatomic) NSMutableDictionary *stateDurations; @end @implementation MJRefreshBackGifFooter #pragma mark - - (UIImageView *)gifView { if (!_gifView) { UIImageView *gifView = [[UIImageView alloc] init]; [self addSubview:_gifView = gifView]; } return _gifView; } - (NSMutableDictionary *)stateImages { if (!_stateImages) { self.stateImages = [NSMutableDictionary dictionary]; } return _stateImages; } - (NSMutableDictionary *)stateDurations { if (!_stateDurations) { self.stateDurations = [NSMutableDictionary dictionary]; } return _stateDurations; } #pragma mark - - (void)setImages:(NSArray *)images duration:(NSTimeInterval)duration forState:(MJRefreshState)state { if (images == nil) return; self.stateImages[@(state)] = images; self.stateDurations[@(state)] = @(duration); /* */ UIImage *image = [images firstObject]; if (image.size.height > self.mj_h) { self.mj_h = image.size.height; } } - (void)setImages:(NSArray *)images forState:(MJRefreshState)state { [self setImages:images duration:images.count * 0.1 forState:state]; } #pragma mark - - (void)prepare { [super prepare]; // self.labelLeftInset = 20; } - (void)setPullingPercent:(CGFloat)pullingPercent { [super setPullingPercent:pullingPercent]; NSArray *images = self.stateImages[@(MJRefreshStateIdle)]; if (self.state != MJRefreshStateIdle || images.count == 0) return; [self.gifView stopAnimating]; NSUInteger index = images.count * pullingPercent; if (index >= images.count) index = images.count - 1; self.gifView.image = images[index]; } - (void)placeSubviews { [super placeSubviews]; if (self.gifView.constraints.count) return; self.gifView.frame = self.bounds; if (self.stateLabel.hidden) { self.gifView.contentMode = UIViewContentModeCenter; } else { self.gifView.contentMode = UIViewContentModeRight; self.gifView.mj_w = self.mj_w * 0.5 - self.labelLeftInset - self.stateLabel.mj_textWidth * 0.5; } } - (void)setState:(MJRefreshState)state { MJRefreshCheckState // if (state == MJRefreshStatePulling || state == MJRefreshStateRefreshing) { NSArray *images = self.stateImages[@(state)]; if (images.count == 0) return; self.gifView.hidden = NO; [self.gifView stopAnimating]; if (images.count == 1) { // self.gifView.image = [images lastObject]; } else { // self.gifView.animationImages = images; self.gifView.animationDuration = [self.stateDurations[@(state)] doubleValue]; [self.gifView startAnimating]; } } else if (state == MJRefreshStateIdle) { self.gifView.hidden = NO; } else if (state == MJRefreshStateNoMoreData) { self.gifView.hidden = YES; } } @end ```
/content/code_sandbox/Pods/MJRefresh/MJRefresh/Custom/Footer/Back/MJRefreshBackGifFooter.m
objective-c
2016-02-02T02:51:55
2024-08-09T08:55:27
WMPlayer
zhengwenming/WMPlayer
3,272
804
```objective-c // // MJRefreshBackStateFooter.h // MJRefreshExample // // Created by MJ Lee on 15/6/13. // #import "MJRefreshBackFooter.h" NS_ASSUME_NONNULL_BEGIN @interface MJRefreshBackStateFooter : MJRefreshBackFooter /** */ @property (assign, nonatomic) CGFloat labelLeftInset; /** label */ @property (weak, nonatomic, readonly) UILabel *stateLabel; /** state */ - (void)setTitle:(NSString *)title forState:(MJRefreshState)state; /** statetitle */ - (NSString *)titleForState:(MJRefreshState)state; @end NS_ASSUME_NONNULL_END ```
/content/code_sandbox/Pods/MJRefresh/MJRefresh/Custom/Footer/Back/MJRefreshBackStateFooter.h
objective-c
2016-02-02T02:51:55
2024-08-09T08:55:27
WMPlayer
zhengwenming/WMPlayer
3,272
134
```objective-c // // MJRefreshAutoGifFooter.m // MJRefreshExample // // Created by MJ Lee on 15/4/24. // #import "MJRefreshAutoGifFooter.h" @interface MJRefreshAutoGifFooter() { __unsafe_unretained UIImageView *_gifView; } /** */ @property (strong, nonatomic) NSMutableDictionary *stateImages; /** */ @property (strong, nonatomic) NSMutableDictionary *stateDurations; @end @implementation MJRefreshAutoGifFooter #pragma mark - - (UIImageView *)gifView { if (!_gifView) { UIImageView *gifView = [[UIImageView alloc] init]; [self addSubview:_gifView = gifView]; } return _gifView; } - (NSMutableDictionary *)stateImages { if (!_stateImages) { self.stateImages = [NSMutableDictionary dictionary]; } return _stateImages; } - (NSMutableDictionary *)stateDurations { if (!_stateDurations) { self.stateDurations = [NSMutableDictionary dictionary]; } return _stateDurations; } #pragma mark - - (void)setImages:(NSArray *)images duration:(NSTimeInterval)duration forState:(MJRefreshState)state { if (images == nil) return; self.stateImages[@(state)] = images; self.stateDurations[@(state)] = @(duration); /* */ UIImage *image = [images firstObject]; if (image.size.height > self.mj_h) { self.mj_h = image.size.height; } } - (void)setImages:(NSArray *)images forState:(MJRefreshState)state { [self setImages:images duration:images.count * 0.1 forState:state]; } #pragma mark - - (void)prepare { [super prepare]; // self.labelLeftInset = 20; } - (void)placeSubviews { [super placeSubviews]; if (self.gifView.constraints.count) return; self.gifView.frame = self.bounds; if (self.isRefreshingTitleHidden) { self.gifView.contentMode = UIViewContentModeCenter; } else { self.gifView.contentMode = UIViewContentModeRight; self.gifView.mj_w = self.mj_w * 0.5 - self.labelLeftInset - self.stateLabel.mj_textWidth * 0.5; } } - (void)setState:(MJRefreshState)state { MJRefreshCheckState // if (state == MJRefreshStateRefreshing) { NSArray *images = self.stateImages[@(state)]; if (images.count == 0) return; [self.gifView stopAnimating]; self.gifView.hidden = NO; if (images.count == 1) { // self.gifView.image = [images lastObject]; } else { // self.gifView.animationImages = images; self.gifView.animationDuration = [self.stateDurations[@(state)] doubleValue]; [self.gifView startAnimating]; } } else if (state == MJRefreshStateNoMoreData || state == MJRefreshStateIdle) { [self.gifView stopAnimating]; self.gifView.hidden = YES; } } @end ```
/content/code_sandbox/Pods/MJRefresh/MJRefresh/Custom/Footer/Auto/MJRefreshAutoGifFooter.m
objective-c
2016-02-02T02:51:55
2024-08-09T08:55:27
WMPlayer
zhengwenming/WMPlayer
3,272
685
```objective-c // // MJRefreshBackNormalFooter.m // MJRefreshExample // // Created by MJ Lee on 15/4/24. // #import "MJRefreshBackNormalFooter.h" #import "NSBundle+MJRefresh.h" @interface MJRefreshBackNormalFooter() { __unsafe_unretained UIImageView *_arrowView; } @property (weak, nonatomic) UIActivityIndicatorView *loadingView; @end @implementation MJRefreshBackNormalFooter #pragma mark - - (UIImageView *)arrowView { if (!_arrowView) { UIImageView *arrowView = [[UIImageView alloc] initWithImage:[NSBundle mj_arrowImage]]; [self addSubview:_arrowView = arrowView]; } return _arrowView; } - (UIActivityIndicatorView *)loadingView { if (!_loadingView) { UIActivityIndicatorView *loadingView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:_activityIndicatorViewStyle]; loadingView.hidesWhenStopped = YES; [self addSubview:_loadingView = loadingView]; } return _loadingView; } - (void)setActivityIndicatorViewStyle:(UIActivityIndicatorViewStyle)activityIndicatorViewStyle { _activityIndicatorViewStyle = activityIndicatorViewStyle; [self.loadingView removeFromSuperview]; self.loadingView = nil; [self setNeedsLayout]; } #pragma mark - - (void)prepare { [super prepare]; #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000 if (@available(iOS 13.0, *)) { _activityIndicatorViewStyle = UIActivityIndicatorViewStyleMedium; return; } #endif _activityIndicatorViewStyle = UIActivityIndicatorViewStyleGray; } - (void)placeSubviews { [super placeSubviews]; // CGFloat arrowCenterX = self.mj_w * 0.5; if (!self.stateLabel.hidden) { arrowCenterX -= self.labelLeftInset + self.stateLabel.mj_textWidth * 0.5; } CGFloat arrowCenterY = self.mj_h * 0.5; CGPoint arrowCenter = CGPointMake(arrowCenterX, arrowCenterY); // if (self.arrowView.constraints.count == 0) { self.arrowView.mj_size = self.arrowView.image.size; self.arrowView.center = arrowCenter; } // if (self.loadingView.constraints.count == 0) { self.loadingView.center = arrowCenter; } self.arrowView.tintColor = self.stateLabel.textColor; } - (void)setState:(MJRefreshState)state { MJRefreshCheckState // if (state == MJRefreshStateIdle) { if (oldState == MJRefreshStateRefreshing) { self.arrowView.transform = CGAffineTransformMakeRotation(0.000001 - M_PI); [UIView animateWithDuration:MJRefreshSlowAnimationDuration animations:^{ self.loadingView.alpha = 0.0; } completion:^(BOOL finished) { // MJRefreshStateIdle if (self.state != MJRefreshStateIdle) return; self.loadingView.alpha = 1.0; [self.loadingView stopAnimating]; self.arrowView.hidden = NO; }]; } else { self.arrowView.hidden = NO; [self.loadingView stopAnimating]; [UIView animateWithDuration:MJRefreshFastAnimationDuration animations:^{ self.arrowView.transform = CGAffineTransformMakeRotation(0.000001 - M_PI); }]; } } else if (state == MJRefreshStatePulling) { self.arrowView.hidden = NO; [self.loadingView stopAnimating]; [UIView animateWithDuration:MJRefreshFastAnimationDuration animations:^{ self.arrowView.transform = CGAffineTransformIdentity; }]; } else if (state == MJRefreshStateRefreshing) { self.arrowView.hidden = YES; [self.loadingView startAnimating]; } else if (state == MJRefreshStateNoMoreData) { self.arrowView.hidden = YES; [self.loadingView stopAnimating]; } } @end ```
/content/code_sandbox/Pods/MJRefresh/MJRefresh/Custom/Footer/Back/MJRefreshBackNormalFooter.m
objective-c
2016-02-02T02:51:55
2024-08-09T08:55:27
WMPlayer
zhengwenming/WMPlayer
3,272
835
```objective-c // // MJRefreshAutoGifFooter.h // MJRefreshExample // // Created by MJ Lee on 15/4/24. // #import "MJRefreshAutoStateFooter.h" NS_ASSUME_NONNULL_BEGIN @interface MJRefreshAutoGifFooter : MJRefreshAutoStateFooter @property (weak, nonatomic, readonly) UIImageView *gifView; /** stateimages duration*/ - (void)setImages:(NSArray *)images duration:(NSTimeInterval)duration forState:(MJRefreshState)state; - (void)setImages:(NSArray *)images forState:(MJRefreshState)state; @end NS_ASSUME_NONNULL_END ```
/content/code_sandbox/Pods/MJRefresh/MJRefresh/Custom/Footer/Auto/MJRefreshAutoGifFooter.h
objective-c
2016-02-02T02:51:55
2024-08-09T08:55:27
WMPlayer
zhengwenming/WMPlayer
3,272
127
```objective-c // // MJRefreshAutoNormalFooter.h // MJRefreshExample // // Created by MJ Lee on 15/4/24. // #import "MJRefreshAutoStateFooter.h" NS_ASSUME_NONNULL_BEGIN @interface MJRefreshAutoNormalFooter : MJRefreshAutoStateFooter @property (weak, nonatomic, readonly) UIActivityIndicatorView *loadingView; /** */ @property (assign, nonatomic) UIActivityIndicatorViewStyle activityIndicatorViewStyle MJRefreshDeprecated("first deprecated in 3.2.2 - Use `loadingView` property"); @end NS_ASSUME_NONNULL_END ```
/content/code_sandbox/Pods/MJRefresh/MJRefresh/Custom/Footer/Auto/MJRefreshAutoNormalFooter.h
objective-c
2016-02-02T02:51:55
2024-08-09T08:55:27
WMPlayer
zhengwenming/WMPlayer
3,272
118
```objective-c // // MJRefreshAutoStateFooter.m // MJRefreshExample // // Created by MJ Lee on 15/6/13. // #import "MJRefreshAutoStateFooter.h" @interface MJRefreshAutoStateFooter() { /** label */ __unsafe_unretained UILabel *_stateLabel; } /** */ @property (strong, nonatomic) NSMutableDictionary *stateTitles; @end @implementation MJRefreshAutoStateFooter #pragma mark - - (NSMutableDictionary *)stateTitles { if (!_stateTitles) { self.stateTitles = [NSMutableDictionary dictionary]; } return _stateTitles; } - (UILabel *)stateLabel { if (!_stateLabel) { [self addSubview:_stateLabel = [UILabel mj_label]]; } return _stateLabel; } #pragma mark - - (void)setTitle:(NSString *)title forState:(MJRefreshState)state { if (title == nil) return; self.stateTitles[@(state)] = title; self.stateLabel.text = self.stateTitles[@(self.state)]; } #pragma mark - - (void)stateLabelClick { if (self.state == MJRefreshStateIdle) { [self beginRefreshing]; } } #pragma mark - - (void)prepare { [super prepare]; // self.labelLeftInset = MJRefreshLabelLeftInset; // [self setTitle:[NSBundle mj_localizedStringForKey:MJRefreshAutoFooterIdleText] forState:MJRefreshStateIdle]; [self setTitle:[NSBundle mj_localizedStringForKey:MJRefreshAutoFooterRefreshingText] forState:MJRefreshStateRefreshing]; [self setTitle:[NSBundle mj_localizedStringForKey:MJRefreshAutoFooterNoMoreDataText] forState:MJRefreshStateNoMoreData]; // label self.stateLabel.userInteractionEnabled = YES; [self.stateLabel addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(stateLabelClick)]]; } - (void)placeSubviews { [super placeSubviews]; if (self.stateLabel.constraints.count) return; // self.stateLabel.frame = self.bounds; } - (void)setState:(MJRefreshState)state { MJRefreshCheckState if (self.isRefreshingTitleHidden && state == MJRefreshStateRefreshing) { self.stateLabel.text = nil; } else { self.stateLabel.text = self.stateTitles[@(state)]; } } @end ```
/content/code_sandbox/Pods/MJRefresh/MJRefresh/Custom/Footer/Auto/MJRefreshAutoStateFooter.m
objective-c
2016-02-02T02:51:55
2024-08-09T08:55:27
WMPlayer
zhengwenming/WMPlayer
3,272
514
```objective-c // // MJRefreshAutoStateFooter.h // MJRefreshExample // // Created by MJ Lee on 15/6/13. // #import "MJRefreshAutoFooter.h" NS_ASSUME_NONNULL_BEGIN @interface MJRefreshAutoStateFooter : MJRefreshAutoFooter /** */ @property (assign, nonatomic) CGFloat labelLeftInset; /** label */ @property (weak, nonatomic, readonly) UILabel *stateLabel; /** state */ - (void)setTitle:(NSString *)title forState:(MJRefreshState)state; /** */ @property (assign, nonatomic, getter=isRefreshingTitleHidden) BOOL refreshingTitleHidden; @end NS_ASSUME_NONNULL_END ```
/content/code_sandbox/Pods/MJRefresh/MJRefresh/Custom/Footer/Auto/MJRefreshAutoStateFooter.h
objective-c
2016-02-02T02:51:55
2024-08-09T08:55:27
WMPlayer
zhengwenming/WMPlayer
3,272
135
```objective-c // // MJRefreshAutoNormalFooter.m // MJRefreshExample // // Created by MJ Lee on 15/4/24. // #import "MJRefreshAutoNormalFooter.h" @interface MJRefreshAutoNormalFooter() @property (weak, nonatomic) UIActivityIndicatorView *loadingView; @end @implementation MJRefreshAutoNormalFooter #pragma mark - - (UIActivityIndicatorView *)loadingView { if (!_loadingView) { UIActivityIndicatorView *loadingView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:_activityIndicatorViewStyle]; loadingView.hidesWhenStopped = YES; [self addSubview:_loadingView = loadingView]; } return _loadingView; } - (void)setActivityIndicatorViewStyle:(UIActivityIndicatorViewStyle)activityIndicatorViewStyle { _activityIndicatorViewStyle = activityIndicatorViewStyle; [self.loadingView removeFromSuperview]; self.loadingView = nil; [self setNeedsLayout]; } #pragma mark - - (void)prepare { [super prepare]; #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000 if (@available(iOS 13.0, *)) { _activityIndicatorViewStyle = UIActivityIndicatorViewStyleMedium; return; } #endif _activityIndicatorViewStyle = UIActivityIndicatorViewStyleGray; } - (void)placeSubviews { [super placeSubviews]; if (self.loadingView.constraints.count) return; // CGFloat loadingCenterX = self.mj_w * 0.5; if (!self.isRefreshingTitleHidden) { loadingCenterX -= self.stateLabel.mj_textWidth * 0.5 + self.labelLeftInset; } CGFloat loadingCenterY = self.mj_h * 0.5; self.loadingView.center = CGPointMake(loadingCenterX, loadingCenterY); } - (void)setState:(MJRefreshState)state { MJRefreshCheckState // if (state == MJRefreshStateNoMoreData || state == MJRefreshStateIdle) { [self.loadingView stopAnimating]; } else if (state == MJRefreshStateRefreshing) { [self.loadingView startAnimating]; } } @end ```
/content/code_sandbox/Pods/MJRefresh/MJRefresh/Custom/Footer/Auto/MJRefreshAutoNormalFooter.m
objective-c
2016-02-02T02:51:55
2024-08-09T08:55:27
WMPlayer
zhengwenming/WMPlayer
3,272
453
```objective-c // // MJRefreshGifHeader.h // MJRefreshExample // // Created by MJ Lee on 15/4/24. // #import "MJRefreshStateHeader.h" NS_ASSUME_NONNULL_BEGIN @interface MJRefreshGifHeader : MJRefreshStateHeader @property (weak, nonatomic, readonly) UIImageView *gifView; /** stateimages duration*/ - (void)setImages:(NSArray *)images duration:(NSTimeInterval)duration forState:(MJRefreshState)state; - (void)setImages:(NSArray *)images forState:(MJRefreshState)state; @end NS_ASSUME_NONNULL_END ```
/content/code_sandbox/Pods/MJRefresh/MJRefresh/Custom/Header/MJRefreshGifHeader.h
objective-c
2016-02-02T02:51:55
2024-08-09T08:55:27
WMPlayer
zhengwenming/WMPlayer
3,272
123
```objective-c // // MJRefreshStateHeader.h // MJRefreshExample // // Created by MJ Lee on 15/4/24. // #import "MJRefreshHeader.h" NS_ASSUME_NONNULL_BEGIN @interface MJRefreshStateHeader : MJRefreshHeader #pragma mark - /** block */ @property (copy, nonatomic, nullable) NSString *(^lastUpdatedTimeText)(NSDate * _Nullable lastUpdatedTime); /** label */ @property (weak, nonatomic, readonly) UILabel *lastUpdatedTimeLabel; #pragma mark - /** */ @property (assign, nonatomic) CGFloat labelLeftInset; /** label */ @property (weak, nonatomic, readonly) UILabel *stateLabel; /** state */ - (void)setTitle:(NSString *)title forState:(MJRefreshState)state; @end NS_ASSUME_NONNULL_END ```
/content/code_sandbox/Pods/MJRefresh/MJRefresh/Custom/Header/MJRefreshStateHeader.h
objective-c
2016-02-02T02:51:55
2024-08-09T08:55:27
WMPlayer
zhengwenming/WMPlayer
3,272
164
```objective-c // // MJRefreshNormalHeader.m // MJRefreshExample // // Created by MJ Lee on 15/4/24. // #import "MJRefreshNormalHeader.h" #import "NSBundle+MJRefresh.h" @interface MJRefreshNormalHeader() { __unsafe_unretained UIImageView *_arrowView; } @property (weak, nonatomic) UIActivityIndicatorView *loadingView; @end @implementation MJRefreshNormalHeader #pragma mark - - (UIImageView *)arrowView { if (!_arrowView) { UIImageView *arrowView = [[UIImageView alloc] initWithImage:[NSBundle mj_arrowImage]]; [self addSubview:_arrowView = arrowView]; } return _arrowView; } - (UIActivityIndicatorView *)loadingView { if (!_loadingView) { UIActivityIndicatorView *loadingView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:_activityIndicatorViewStyle]; loadingView.hidesWhenStopped = YES; [self addSubview:_loadingView = loadingView]; } return _loadingView; } #pragma mark - - (void)setActivityIndicatorViewStyle:(UIActivityIndicatorViewStyle)activityIndicatorViewStyle { _activityIndicatorViewStyle = activityIndicatorViewStyle; [self.loadingView removeFromSuperview]; self.loadingView = nil; [self setNeedsLayout]; } #pragma mark - - (void)prepare { [super prepare]; #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000 if (@available(iOS 13.0, *)) { _activityIndicatorViewStyle = UIActivityIndicatorViewStyleMedium; return; } #endif _activityIndicatorViewStyle = UIActivityIndicatorViewStyleGray; } - (void)placeSubviews { [super placeSubviews]; // CGFloat arrowCenterX = self.mj_w * 0.5; if (!self.stateLabel.hidden) { CGFloat stateWidth = self.stateLabel.mj_textWidth; CGFloat timeWidth = 0.0; if (!self.lastUpdatedTimeLabel.hidden) { timeWidth = self.lastUpdatedTimeLabel.mj_textWidth; } CGFloat textWidth = MAX(stateWidth, timeWidth); arrowCenterX -= textWidth / 2 + self.labelLeftInset; } CGFloat arrowCenterY = self.mj_h * 0.5; CGPoint arrowCenter = CGPointMake(arrowCenterX, arrowCenterY); // if (self.arrowView.constraints.count == 0) { self.arrowView.mj_size = self.arrowView.image.size; self.arrowView.center = arrowCenter; } // if (self.loadingView.constraints.count == 0) { self.loadingView.center = arrowCenter; } self.arrowView.tintColor = self.stateLabel.textColor; } - (void)setState:(MJRefreshState)state { MJRefreshCheckState // if (state == MJRefreshStateIdle) { if (oldState == MJRefreshStateRefreshing) { self.arrowView.transform = CGAffineTransformIdentity; [UIView animateWithDuration:MJRefreshSlowAnimationDuration animations:^{ self.loadingView.alpha = 0.0; } completion:^(BOOL finished) { // idle if (self.state != MJRefreshStateIdle) return; self.loadingView.alpha = 1.0; [self.loadingView stopAnimating]; self.arrowView.hidden = NO; }]; } else { [self.loadingView stopAnimating]; self.arrowView.hidden = NO; [UIView animateWithDuration:MJRefreshFastAnimationDuration animations:^{ self.arrowView.transform = CGAffineTransformIdentity; }]; } } else if (state == MJRefreshStatePulling) { [self.loadingView stopAnimating]; self.arrowView.hidden = NO; [UIView animateWithDuration:MJRefreshFastAnimationDuration animations:^{ self.arrowView.transform = CGAffineTransformMakeRotation(0.000001 - M_PI); }]; } else if (state == MJRefreshStateRefreshing) { self.loadingView.alpha = 1.0; // refreshing -> idle [self.loadingView startAnimating]; self.arrowView.hidden = YES; } } @end ```
/content/code_sandbox/Pods/MJRefresh/MJRefresh/Custom/Header/MJRefreshNormalHeader.m
objective-c
2016-02-02T02:51:55
2024-08-09T08:55:27
WMPlayer
zhengwenming/WMPlayer
3,272
862
```objective-c // // MJRefreshStateHeader.m // MJRefreshExample // // Created by MJ Lee on 15/4/24. // #import "MJRefreshStateHeader.h" @interface MJRefreshStateHeader() { /** label */ __unsafe_unretained UILabel *_lastUpdatedTimeLabel; /** label */ __unsafe_unretained UILabel *_stateLabel; } /** */ @property (strong, nonatomic) NSMutableDictionary *stateTitles; @end @implementation MJRefreshStateHeader #pragma mark - - (NSMutableDictionary *)stateTitles { if (!_stateTitles) { self.stateTitles = [NSMutableDictionary dictionary]; } return _stateTitles; } - (UILabel *)stateLabel { if (!_stateLabel) { [self addSubview:_stateLabel = [UILabel mj_label]]; } return _stateLabel; } - (UILabel *)lastUpdatedTimeLabel { if (!_lastUpdatedTimeLabel) { [self addSubview:_lastUpdatedTimeLabel = [UILabel mj_label]]; } return _lastUpdatedTimeLabel; } #pragma mark - - (void)setTitle:(NSString *)title forState:(MJRefreshState)state { if (title == nil) return; self.stateTitles[@(state)] = title; self.stateLabel.text = self.stateTitles[@(self.state)]; } #pragma mark key - (void)setLastUpdatedTimeKey:(NSString *)lastUpdatedTimeKey { [super setLastUpdatedTimeKey:lastUpdatedTimeKey]; // label if (self.lastUpdatedTimeLabel.hidden) return; NSDate *lastUpdatedTime = [[NSUserDefaults standardUserDefaults] objectForKey:lastUpdatedTimeKey]; // block if (self.lastUpdatedTimeText) { self.lastUpdatedTimeLabel.text = self.lastUpdatedTimeText(lastUpdatedTime); return; } if (lastUpdatedTime) { // 1. NSCalendar *calendar = [NSCalendar calendarWithIdentifier:NSCalendarIdentifierGregorian]; NSUInteger unitFlags = NSCalendarUnitYear| NSCalendarUnitMonth | NSCalendarUnitDay | NSCalendarUnitHour | NSCalendarUnitMinute; NSDateComponents *cmp1 = [calendar components:unitFlags fromDate:lastUpdatedTime]; NSDateComponents *cmp2 = [calendar components:unitFlags fromDate:[NSDate date]]; // 2. NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; BOOL isToday = NO; if ([cmp1 day] == [cmp2 day]) { // formatter.dateFormat = @" HH:mm"; isToday = YES; } else if ([cmp1 year] == [cmp2 year]) { // formatter.dateFormat = @"MM-dd HH:mm"; } else { formatter.dateFormat = @"yyyy-MM-dd HH:mm"; } NSString *time = [formatter stringFromDate:lastUpdatedTime]; // 3. self.lastUpdatedTimeLabel.text = [NSString stringWithFormat:@"%@%@%@", [NSBundle mj_localizedStringForKey:MJRefreshHeaderLastTimeText], isToday ? [NSBundle mj_localizedStringForKey:MJRefreshHeaderDateTodayText] : @"", time]; } else { self.lastUpdatedTimeLabel.text = [NSString stringWithFormat:@"%@%@", [NSBundle mj_localizedStringForKey:MJRefreshHeaderLastTimeText], [NSBundle mj_localizedStringForKey:MJRefreshHeaderNoneLastDateText]]; } } #pragma mark - - (void)prepare { [super prepare]; // self.labelLeftInset = MJRefreshLabelLeftInset; // [self setTitle:[NSBundle mj_localizedStringForKey:MJRefreshHeaderIdleText] forState:MJRefreshStateIdle]; [self setTitle:[NSBundle mj_localizedStringForKey:MJRefreshHeaderPullingText] forState:MJRefreshStatePulling]; [self setTitle:[NSBundle mj_localizedStringForKey:MJRefreshHeaderRefreshingText] forState:MJRefreshStateRefreshing]; } - (void)placeSubviews { [super placeSubviews]; if (self.stateLabel.hidden) return; BOOL noConstrainsOnStatusLabel = self.stateLabel.constraints.count == 0; if (self.lastUpdatedTimeLabel.hidden) { // if (noConstrainsOnStatusLabel) self.stateLabel.frame = self.bounds; } else { CGFloat stateLabelH = self.mj_h * 0.5; // if (noConstrainsOnStatusLabel) { self.stateLabel.mj_x = 0; self.stateLabel.mj_y = 0; self.stateLabel.mj_w = self.mj_w; self.stateLabel.mj_h = stateLabelH; } // if (self.lastUpdatedTimeLabel.constraints.count == 0) { self.lastUpdatedTimeLabel.mj_x = 0; self.lastUpdatedTimeLabel.mj_y = stateLabelH; self.lastUpdatedTimeLabel.mj_w = self.mj_w; self.lastUpdatedTimeLabel.mj_h = self.mj_h - self.lastUpdatedTimeLabel.mj_y; } } } - (void)setState:(MJRefreshState)state { MJRefreshCheckState // self.stateLabel.text = self.stateTitles[@(state)]; // key self.lastUpdatedTimeKey = self.lastUpdatedTimeKey; } @end ```
/content/code_sandbox/Pods/MJRefresh/MJRefresh/Custom/Header/MJRefreshStateHeader.m
objective-c
2016-02-02T02:51:55
2024-08-09T08:55:27
WMPlayer
zhengwenming/WMPlayer
3,272
1,117
```objective-c // // MJRefreshNormalHeader.h // MJRefreshExample // // Created by MJ Lee on 15/4/24. // #import "MJRefreshStateHeader.h" NS_ASSUME_NONNULL_BEGIN @interface MJRefreshNormalHeader : MJRefreshStateHeader @property (weak, nonatomic, readonly) UIImageView *arrowView; @property (weak, nonatomic, readonly) UIActivityIndicatorView *loadingView; /** */ @property (assign, nonatomic) UIActivityIndicatorViewStyle activityIndicatorViewStyle MJRefreshDeprecated("first deprecated in 3.2.2 - Use `loadingView` property"); @end NS_ASSUME_NONNULL_END ```
/content/code_sandbox/Pods/MJRefresh/MJRefresh/Custom/Header/MJRefreshNormalHeader.h
objective-c
2016-02-02T02:51:55
2024-08-09T08:55:27
WMPlayer
zhengwenming/WMPlayer
3,272
127
```unknown "MJRefreshHeaderIdleText" = ""; "MJRefreshHeaderPullingText" = ""; "MJRefreshHeaderRefreshingText" = "..."; "MJRefreshAutoFooterIdleText" = ""; "MJRefreshAutoFooterRefreshingText" = "..."; "MJRefreshAutoFooterNoMoreDataText" = ""; "MJRefreshBackFooterIdleText" = ""; "MJRefreshBackFooterPullingText" = ""; "MJRefreshBackFooterRefreshingText" = "..."; "MJRefreshBackFooterNoMoreDataText" = ""; "MJRefreshHeaderLastTimeText" = ""; "MJRefreshHeaderDateTodayText" = ""; "MJRefreshHeaderNoneLastDateText" = ""; ```
/content/code_sandbox/Pods/MJRefresh/MJRefresh/MJRefresh.bundle/zh-Hant.lproj/Localizable.strings
unknown
2016-02-02T02:51:55
2024-08-09T08:55:27
WMPlayer
zhengwenming/WMPlayer
3,272
138
```unknown "MJRefreshHeaderIdleText" = " "; "MJRefreshHeaderPullingText" = " "; "MJRefreshHeaderRefreshingText" = "..."; "MJRefreshAutoFooterIdleText" = " "; "MJRefreshAutoFooterRefreshingText" = "..."; "MJRefreshAutoFooterNoMoreDataText" = " "; "MJRefreshBackFooterIdleText" = " "; "MJRefreshBackFooterPullingText" = " ."; "MJRefreshBackFooterRefreshingText" = "..."; "MJRefreshBackFooterNoMoreDataText" = " "; "MJRefreshHeaderLastTimeText" = " : "; "MJRefreshHeaderDateTodayText" = ""; "MJRefreshHeaderNoneLastDateText" = " "; ```
/content/code_sandbox/Pods/MJRefresh/MJRefresh/MJRefresh.bundle/ko.lproj/Localizable.strings
unknown
2016-02-02T02:51:55
2024-08-09T08:55:27
WMPlayer
zhengwenming/WMPlayer
3,272
155
```objective-c // // MJRefreshGifHeader.m // MJRefreshExample // // Created by MJ Lee on 15/4/24. // #import "MJRefreshGifHeader.h" @interface MJRefreshGifHeader() { __unsafe_unretained UIImageView *_gifView; } /** */ @property (strong, nonatomic) NSMutableDictionary *stateImages; /** */ @property (strong, nonatomic) NSMutableDictionary *stateDurations; @end @implementation MJRefreshGifHeader #pragma mark - - (UIImageView *)gifView { if (!_gifView) { UIImageView *gifView = [[UIImageView alloc] init]; [self addSubview:_gifView = gifView]; } return _gifView; } - (NSMutableDictionary *)stateImages { if (!_stateImages) { self.stateImages = [NSMutableDictionary dictionary]; } return _stateImages; } - (NSMutableDictionary *)stateDurations { if (!_stateDurations) { self.stateDurations = [NSMutableDictionary dictionary]; } return _stateDurations; } #pragma mark - - (void)setImages:(NSArray *)images duration:(NSTimeInterval)duration forState:(MJRefreshState)state { if (images == nil) return; self.stateImages[@(state)] = images; self.stateDurations[@(state)] = @(duration); /* */ UIImage *image = [images firstObject]; if (image.size.height > self.mj_h) { self.mj_h = image.size.height; } } - (void)setImages:(NSArray *)images forState:(MJRefreshState)state { [self setImages:images duration:images.count * 0.1 forState:state]; } #pragma mark - - (void)prepare { [super prepare]; // self.labelLeftInset = 20; } - (void)setPullingPercent:(CGFloat)pullingPercent { [super setPullingPercent:pullingPercent]; NSArray *images = self.stateImages[@(MJRefreshStateIdle)]; if (self.state != MJRefreshStateIdle || images.count == 0) return; // [self.gifView stopAnimating]; // NSUInteger index = images.count * pullingPercent; if (index >= images.count) index = images.count - 1; self.gifView.image = images[index]; } - (void)placeSubviews { [super placeSubviews]; if (self.gifView.constraints.count) return; self.gifView.frame = self.bounds; if (self.stateLabel.hidden && self.lastUpdatedTimeLabel.hidden) { self.gifView.contentMode = UIViewContentModeCenter; } else { self.gifView.contentMode = UIViewContentModeRight; CGFloat stateWidth = self.stateLabel.mj_textWidth; CGFloat timeWidth = 0.0; if (!self.lastUpdatedTimeLabel.hidden) { timeWidth = self.lastUpdatedTimeLabel.mj_textWidth; } CGFloat textWidth = MAX(stateWidth, timeWidth); self.gifView.mj_w = self.mj_w * 0.5 - textWidth * 0.5 - self.labelLeftInset; } } - (void)setState:(MJRefreshState)state { MJRefreshCheckState // if (state == MJRefreshStatePulling || state == MJRefreshStateRefreshing) { NSArray *images = self.stateImages[@(state)]; if (images.count == 0) return; [self.gifView stopAnimating]; if (images.count == 1) { // self.gifView.image = [images lastObject]; } else { // self.gifView.animationImages = images; self.gifView.animationDuration = [self.stateDurations[@(state)] doubleValue]; [self.gifView startAnimating]; } } else if (state == MJRefreshStateIdle) { [self.gifView stopAnimating]; } } @end ```
/content/code_sandbox/Pods/MJRefresh/MJRefresh/Custom/Header/MJRefreshGifHeader.m
objective-c
2016-02-02T02:51:55
2024-08-09T08:55:27
WMPlayer
zhengwenming/WMPlayer
3,272
863
```objective-c // UIActivityIndicatorView+AFNetworking.h // // 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. #import <Foundation/Foundation.h> #import <TargetConditionals.h> #if TARGET_OS_IOS || TARGET_OS_TV #import <UIKit/UIKit.h> /** This category adds methods to the UIKit framework's `UIActivityIndicatorView` class. The methods in this category provide support for automatically starting and stopping animation depending on the loading state of a session task. */ @interface UIActivityIndicatorView (AFNetworking) ///---------------------------------- /// @name Animating for Session Tasks ///---------------------------------- /** Binds the animating state to the state of the specified task. @param task The task. If `nil`, automatic updating from any previously specified operation will be disabled. */ - (void)setAnimatingWithStateOfTask:(nullable NSURLSessionTask *)task; @end #endif ```
/content/code_sandbox/Pods/AFNetworking/UIKit+AFNetworking/UIActivityIndicatorView+AFNetworking.h
objective-c
2016-02-02T02:51:55
2024-08-09T08:55:27
WMPlayer
zhengwenming/WMPlayer
3,272
377
```objective-c // AFAutoPurgingImageCache.h // // 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. #import <TargetConditionals.h> #import <Foundation/Foundation.h> #if TARGET_OS_IOS || TARGET_OS_TV #import <UIKit/UIKit.h> NS_ASSUME_NONNULL_BEGIN /** The `AFImageCache` protocol defines a set of APIs for adding, removing and fetching images from a cache synchronously. */ @protocol AFImageCache <NSObject> /** Adds the image to the cache with the given identifier. @param image The image to cache. @param identifier The unique identifier for the image in the cache. */ - (void)addImage:(UIImage *)image withIdentifier:(NSString *)identifier; /** Removes the image from the cache matching the given identifier. @param identifier The unique identifier for the image in the cache. @return A BOOL indicating whether or not the image was removed from the cache. */ - (BOOL)removeImageWithIdentifier:(NSString *)identifier; /** Removes all images from the cache. @return A BOOL indicating whether or not all images were removed from the cache. */ - (BOOL)removeAllImages; /** Returns the image in the cache associated with the given identifier. @param identifier The unique identifier for the image in the cache. @return An image for the matching identifier, or nil. */ - (nullable UIImage *)imageWithIdentifier:(NSString *)identifier; @end /** The `ImageRequestCache` protocol extends the `ImageCache` protocol by adding methods for adding, removing and fetching images from a cache given an `NSURLRequest` and additional identifier. */ @protocol AFImageRequestCache <AFImageCache> /** Asks if the image should be cached using an identifier created from the request and additional identifier. @param image The image to be cached. @param request The unique URL request identifing the image asset. @param identifier The additional identifier to apply to the URL request to identify the image. @return A BOOL indicating whether or not the image should be added to the cache. YES will cache, NO will prevent caching. */ - (BOOL)shouldCacheImage:(UIImage *)image forRequest:(NSURLRequest *)request withAdditionalIdentifier:(nullable NSString *)identifier; /** Adds the image to the cache using an identifier created from the request and additional identifier. @param image The image to cache. @param request The unique URL request identifing the image asset. @param identifier The additional identifier to apply to the URL request to identify the image. */ - (void)addImage:(UIImage *)image forRequest:(NSURLRequest *)request withAdditionalIdentifier:(nullable NSString *)identifier; /** Removes the image from the cache using an identifier created from the request and additional identifier. @param request The unique URL request identifing the image asset. @param identifier The additional identifier to apply to the URL request to identify the image. @return A BOOL indicating whether or not all images were removed from the cache. */ - (BOOL)removeImageforRequest:(NSURLRequest *)request withAdditionalIdentifier:(nullable NSString *)identifier; /** Returns the image from the cache associated with an identifier created from the request and additional identifier. @param request The unique URL request identifing the image asset. @param identifier The additional identifier to apply to the URL request to identify the image. @return An image for the matching request and identifier, or nil. */ - (nullable UIImage *)imageforRequest:(NSURLRequest *)request withAdditionalIdentifier:(nullable NSString *)identifier; @end /** The `AutoPurgingImageCache` in an in-memory image cache used to store images up to a given memory capacity. When the memory capacity is reached, the image cache is sorted by last access date, then the oldest image is continuously purged until the preferred memory usage after purge is met. Each time an image is accessed through the cache, the internal access date of the image is updated. */ @interface AFAutoPurgingImageCache : NSObject <AFImageRequestCache> /** The total memory capacity of the cache in bytes. */ @property (nonatomic, assign) UInt64 memoryCapacity; /** The preferred memory usage after purge in bytes. During a purge, images will be purged until the memory capacity drops below this limit. */ @property (nonatomic, assign) UInt64 preferredMemoryUsageAfterPurge; /** The current total memory usage in bytes of all images stored within the cache. */ @property (nonatomic, assign, readonly) UInt64 memoryUsage; /** Initialies the `AutoPurgingImageCache` instance with default values for memory capacity and preferred memory usage after purge limit. `memoryCapcity` defaults to `100 MB`. `preferredMemoryUsageAfterPurge` defaults to `60 MB`. @return The new `AutoPurgingImageCache` instance. */ - (instancetype)init; /** Initialies the `AutoPurgingImageCache` instance with the given memory capacity and preferred memory usage after purge limit. @param memoryCapacity The total memory capacity of the cache in bytes. @param preferredMemoryCapacity The preferred memory usage after purge in bytes. @return The new `AutoPurgingImageCache` instance. */ - (instancetype)initWithMemoryCapacity:(UInt64)memoryCapacity preferredMemoryCapacity:(UInt64)preferredMemoryCapacity; @end NS_ASSUME_NONNULL_END #endif ```
/content/code_sandbox/Pods/AFNetworking/UIKit+AFNetworking/AFAutoPurgingImageCache.h
objective-c
2016-02-02T02:51:55
2024-08-09T08:55:27
WMPlayer
zhengwenming/WMPlayer
3,272
1,288
```objective-c // UIImageView+AFNetworking.h // // 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. #import <Foundation/Foundation.h> #import <TargetConditionals.h> #if TARGET_OS_IOS || TARGET_OS_TV #import <UIKit/UIKit.h> NS_ASSUME_NONNULL_BEGIN @class AFImageDownloader; /** This category adds methods to the UIKit framework's `UIImageView` class. The methods in this category provide support for loading remote images asynchronously from a URL. */ @interface UIImageView (AFNetworking) ///------------------------------------ /// @name Accessing the Image Downloader ///------------------------------------ /** Set the shared image downloader used to download images. @param imageDownloader The shared image downloader used to download images. */ + (void)setSharedImageDownloader:(AFImageDownloader *)imageDownloader; /** The shared image downloader used to download images. */ + (AFImageDownloader *)sharedImageDownloader; ///-------------------- /// @name Setting Image ///-------------------- /** Asynchronously downloads an image from the specified URL, and sets it once the request is finished. Any previous image request for the receiver will be cancelled. If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished. By default, URL requests have a `Accept` header field value of "image / *", a cache policy of `NSURLCacheStorageAllowed` and a timeout interval of 30 seconds, and are set not handle cookies. To configure URL requests differently, use `setImageWithURLRequest:placeholderImage:success:failure:` @param url The URL used for the image request. */ - (void)setImageWithURL:(NSURL *)url; /** Asynchronously downloads an image from the specified URL, and sets it once the request is finished. Any previous image request for the receiver will be cancelled. If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished. By default, URL requests have a `Accept` header field value of "image / *", a cache policy of `NSURLCacheStorageAllowed` and a timeout interval of 30 seconds, and are set not handle cookies. To configure URL requests differently, use `setImageWithURLRequest:placeholderImage:success:failure:` @param url The URL used for the image request. @param placeholderImage The image to be set initially, until the image request finishes. If `nil`, the image view will not change its image until the image request finishes. */ - (void)setImageWithURL:(NSURL *)url placeholderImage:(nullable UIImage *)placeholderImage; /** Asynchronously downloads an image from the specified URL request, and sets it once the request is finished. Any previous image request for the receiver will be cancelled. If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished. If a success block is specified, it is the responsibility of the block to set the image of the image view before returning. If no success block is specified, the default behavior of setting the image with `self.image = image` is applied. @param urlRequest The URL request used for the image request. @param placeholderImage The image to be set initially, until the image request finishes. If `nil`, the image view will not change its image until the image request finishes. @param success A block to be executed when the image data task finishes successfully. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the image created from the response data of request. If the image was returned from cache, the response parameter will be `nil`. @param failure A block object to be executed when the image data task finishes unsuccessfully, or that finishes successfully. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the error object describing the network or parsing error that occurred. */ - (void)setImageWithURLRequest:(NSURLRequest *)urlRequest placeholderImage:(nullable UIImage *)placeholderImage success:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, UIImage *image))success failure:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, NSError *error))failure; /** Cancels any executing image operation for the receiver, if one exists. */ - (void)cancelImageDownloadTask; @end NS_ASSUME_NONNULL_END #endif ```
/content/code_sandbox/Pods/AFNetworking/UIKit+AFNetworking/UIImageView+AFNetworking.h
objective-c
2016-02-02T02:51:55
2024-08-09T08:55:27
WMPlayer
zhengwenming/WMPlayer
3,272
1,155
```objective-c // UIProgressView+AFNetworking.m // // 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. #import "UIProgressView+AFNetworking.h" #import <objc/runtime.h> #if TARGET_OS_IOS || TARGET_OS_TV #import "AFURLSessionManager.h" static void * AFTaskCountOfBytesSentContext = &AFTaskCountOfBytesSentContext; static void * AFTaskCountOfBytesReceivedContext = &AFTaskCountOfBytesReceivedContext; #pragma mark - @implementation UIProgressView (AFNetworking) - (BOOL)af_uploadProgressAnimated { return [(NSNumber *)objc_getAssociatedObject(self, @selector(af_uploadProgressAnimated)) boolValue]; } - (void)af_setUploadProgressAnimated:(BOOL)animated { objc_setAssociatedObject(self, @selector(af_uploadProgressAnimated), @(animated), OBJC_ASSOCIATION_RETAIN_NONATOMIC); } - (BOOL)af_downloadProgressAnimated { return [(NSNumber *)objc_getAssociatedObject(self, @selector(af_downloadProgressAnimated)) boolValue]; } - (void)af_setDownloadProgressAnimated:(BOOL)animated { objc_setAssociatedObject(self, @selector(af_downloadProgressAnimated), @(animated), OBJC_ASSOCIATION_RETAIN_NONATOMIC); } #pragma mark - - (void)setProgressWithUploadProgressOfTask:(NSURLSessionUploadTask *)task animated:(BOOL)animated { if (task.state == NSURLSessionTaskStateCompleted) { return; } [task addObserver:self forKeyPath:@"state" options:(NSKeyValueObservingOptions)0 context:AFTaskCountOfBytesSentContext]; [task addObserver:self forKeyPath:@"countOfBytesSent" options:(NSKeyValueObservingOptions)0 context:AFTaskCountOfBytesSentContext]; [self af_setUploadProgressAnimated:animated]; } - (void)setProgressWithDownloadProgressOfTask:(NSURLSessionDownloadTask *)task animated:(BOOL)animated { if (task.state == NSURLSessionTaskStateCompleted) { return; } [task addObserver:self forKeyPath:@"state" options:(NSKeyValueObservingOptions)0 context:AFTaskCountOfBytesReceivedContext]; [task addObserver:self forKeyPath:@"countOfBytesReceived" options:(NSKeyValueObservingOptions)0 context:AFTaskCountOfBytesReceivedContext]; [self af_setDownloadProgressAnimated:animated]; } #pragma mark - NSKeyValueObserving - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(__unused NSDictionary *)change context:(void *)context { if (context == AFTaskCountOfBytesSentContext || context == AFTaskCountOfBytesReceivedContext) { if ([keyPath isEqualToString:NSStringFromSelector(@selector(countOfBytesSent))]) { if ([object countOfBytesExpectedToSend] > 0) { dispatch_async(dispatch_get_main_queue(), ^{ [self setProgress:[object countOfBytesSent] / ([object countOfBytesExpectedToSend] * 1.0f) animated:self.af_uploadProgressAnimated]; }); } } if ([keyPath isEqualToString:NSStringFromSelector(@selector(countOfBytesReceived))]) { if ([object countOfBytesExpectedToReceive] > 0) { dispatch_async(dispatch_get_main_queue(), ^{ [self setProgress:[object countOfBytesReceived] / ([object countOfBytesExpectedToReceive] * 1.0f) animated:self.af_downloadProgressAnimated]; }); } } if ([keyPath isEqualToString:NSStringFromSelector(@selector(state))]) { if ([(NSURLSessionTask *)object state] == NSURLSessionTaskStateCompleted) { @try { [object removeObserver:self forKeyPath:NSStringFromSelector(@selector(state))]; if (context == AFTaskCountOfBytesSentContext) { [object removeObserver:self forKeyPath:NSStringFromSelector(@selector(countOfBytesSent))]; } if (context == AFTaskCountOfBytesReceivedContext) { [object removeObserver:self forKeyPath:NSStringFromSelector(@selector(countOfBytesReceived))]; } } @catch (NSException * __unused exception) {} } } } } @end #endif ```
/content/code_sandbox/Pods/AFNetworking/UIKit+AFNetworking/UIProgressView+AFNetworking.m
objective-c
2016-02-02T02:51:55
2024-08-09T08:55:27
WMPlayer
zhengwenming/WMPlayer
3,272
1,095
```objective-c // UIRefreshControl+AFNetworking.m // // // 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. #import "UIRefreshControl+AFNetworking.h" #import <objc/runtime.h> #if TARGET_OS_IOS #import "AFURLSessionManager.h" @interface AFRefreshControlNotificationObserver : NSObject @property (readonly, nonatomic, weak) UIRefreshControl *refreshControl; - (instancetype)initWithActivityRefreshControl:(UIRefreshControl *)refreshControl; - (void)setRefreshingWithStateOfTask:(NSURLSessionTask *)task; @end @implementation UIRefreshControl (AFNetworking) - (AFRefreshControlNotificationObserver *)af_notificationObserver { AFRefreshControlNotificationObserver *notificationObserver = objc_getAssociatedObject(self, @selector(af_notificationObserver)); if (notificationObserver == nil) { notificationObserver = [[AFRefreshControlNotificationObserver alloc] initWithActivityRefreshControl:self]; objc_setAssociatedObject(self, @selector(af_notificationObserver), notificationObserver, OBJC_ASSOCIATION_RETAIN_NONATOMIC); } return notificationObserver; } - (void)setRefreshingWithStateOfTask:(NSURLSessionTask *)task { [[self af_notificationObserver] setRefreshingWithStateOfTask:task]; } @end @implementation AFRefreshControlNotificationObserver - (instancetype)initWithActivityRefreshControl:(UIRefreshControl *)refreshControl { self = [super init]; if (self) { _refreshControl = refreshControl; } return self; } - (void)setRefreshingWithStateOfTask:(NSURLSessionTask *)task { NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; [notificationCenter removeObserver:self name:AFNetworkingTaskDidResumeNotification object:nil]; [notificationCenter removeObserver:self name:AFNetworkingTaskDidSuspendNotification object:nil]; [notificationCenter removeObserver:self name:AFNetworkingTaskDidCompleteNotification object:nil]; if (task) { UIRefreshControl *refreshControl = self.refreshControl; if (task.state == NSURLSessionTaskStateRunning) { [refreshControl beginRefreshing]; [notificationCenter addObserver:self selector:@selector(af_beginRefreshing) name:AFNetworkingTaskDidResumeNotification object:task]; [notificationCenter addObserver:self selector:@selector(af_endRefreshing) name:AFNetworkingTaskDidCompleteNotification object:task]; [notificationCenter addObserver:self selector:@selector(af_endRefreshing) name:AFNetworkingTaskDidSuspendNotification object:task]; } else { [refreshControl endRefreshing]; } } } #pragma mark - - (void)af_beginRefreshing { dispatch_async(dispatch_get_main_queue(), ^{ [self.refreshControl beginRefreshing]; }); } - (void)af_endRefreshing { dispatch_async(dispatch_get_main_queue(), ^{ [self.refreshControl endRefreshing]; }); } #pragma mark - - (void)dealloc { NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; [notificationCenter removeObserver:self name:AFNetworkingTaskDidCompleteNotification object:nil]; [notificationCenter removeObserver:self name:AFNetworkingTaskDidResumeNotification object:nil]; [notificationCenter removeObserver:self name:AFNetworkingTaskDidSuspendNotification object:nil]; } @end #endif ```
/content/code_sandbox/Pods/AFNetworking/UIKit+AFNetworking/UIRefreshControl+AFNetworking.m
objective-c
2016-02-02T02:51:55
2024-08-09T08:55:27
WMPlayer
zhengwenming/WMPlayer
3,272
860
```objective-c // UIButton+AFNetworking.m // // 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. #import "UIButton+AFNetworking.h" #import <objc/runtime.h> #if TARGET_OS_IOS || TARGET_OS_TV #import "UIImageView+AFNetworking.h" #import "AFImageDownloader.h" @interface UIButton (_AFNetworking) @end @implementation UIButton (_AFNetworking) #pragma mark - static char AFImageDownloadReceiptNormal; static char AFImageDownloadReceiptHighlighted; static char AFImageDownloadReceiptSelected; static char AFImageDownloadReceiptDisabled; static const char * af_imageDownloadReceiptKeyForState(UIControlState state) { switch (state) { case UIControlStateHighlighted: return &AFImageDownloadReceiptHighlighted; case UIControlStateSelected: return &AFImageDownloadReceiptSelected; case UIControlStateDisabled: return &AFImageDownloadReceiptDisabled; case UIControlStateNormal: default: return &AFImageDownloadReceiptNormal; } } - (AFImageDownloadReceipt *)af_imageDownloadReceiptForState:(UIControlState)state { return (AFImageDownloadReceipt *)objc_getAssociatedObject(self, af_imageDownloadReceiptKeyForState(state)); } - (void)af_setImageDownloadReceipt:(AFImageDownloadReceipt *)imageDownloadReceipt forState:(UIControlState)state { objc_setAssociatedObject(self, af_imageDownloadReceiptKeyForState(state), imageDownloadReceipt, OBJC_ASSOCIATION_RETAIN_NONATOMIC); } #pragma mark - static char AFBackgroundImageDownloadReceiptNormal; static char AFBackgroundImageDownloadReceiptHighlighted; static char AFBackgroundImageDownloadReceiptSelected; static char AFBackgroundImageDownloadReceiptDisabled; static const char * af_backgroundImageDownloadReceiptKeyForState(UIControlState state) { switch (state) { case UIControlStateHighlighted: return &AFBackgroundImageDownloadReceiptHighlighted; case UIControlStateSelected: return &AFBackgroundImageDownloadReceiptSelected; case UIControlStateDisabled: return &AFBackgroundImageDownloadReceiptDisabled; case UIControlStateNormal: default: return &AFBackgroundImageDownloadReceiptNormal; } } - (AFImageDownloadReceipt *)af_backgroundImageDownloadReceiptForState:(UIControlState)state { return (AFImageDownloadReceipt *)objc_getAssociatedObject(self, af_backgroundImageDownloadReceiptKeyForState(state)); } - (void)af_setBackgroundImageDownloadReceipt:(AFImageDownloadReceipt *)imageDownloadReceipt forState:(UIControlState)state { objc_setAssociatedObject(self, af_backgroundImageDownloadReceiptKeyForState(state), imageDownloadReceipt, OBJC_ASSOCIATION_RETAIN_NONATOMIC); } @end #pragma mark - @implementation UIButton (AFNetworking) + (AFImageDownloader *)sharedImageDownloader { return objc_getAssociatedObject(self, @selector(sharedImageDownloader)) ?: [AFImageDownloader defaultInstance]; } + (void)setSharedImageDownloader:(AFImageDownloader *)imageDownloader { objc_setAssociatedObject(self, @selector(sharedImageDownloader), imageDownloader, OBJC_ASSOCIATION_RETAIN_NONATOMIC); } #pragma mark - - (void)setImageForState:(UIControlState)state withURL:(NSURL *)url { [self setImageForState:state withURL:url placeholderImage:nil]; } - (void)setImageForState:(UIControlState)state withURL:(NSURL *)url placeholderImage:(UIImage *)placeholderImage { NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url]; [request addValue:@"image/*" forHTTPHeaderField:@"Accept"]; [self setImageForState:state withURLRequest:request placeholderImage:placeholderImage success:nil failure:nil]; } - (void)setImageForState:(UIControlState)state withURLRequest:(NSURLRequest *)urlRequest placeholderImage:(nullable UIImage *)placeholderImage success:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, UIImage *image))success failure:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, NSError *error))failure { if ([self isActiveTaskURLEqualToURLRequest:urlRequest forState:state]) { return; } [self cancelImageDownloadTaskForState:state]; AFImageDownloader *downloader = [[self class] sharedImageDownloader]; id <AFImageRequestCache> imageCache = downloader.imageCache; //Use the image from the image cache if it exists UIImage *cachedImage = [imageCache imageforRequest:urlRequest withAdditionalIdentifier:nil]; if (cachedImage) { if (success) { success(urlRequest, nil, cachedImage); } else { [self setImage:cachedImage forState:state]; } [self af_setImageDownloadReceipt:nil forState:state]; } else { if (placeholderImage) { [self setImage:placeholderImage forState:state]; } __weak __typeof(self)weakSelf = self; NSUUID *downloadID = [NSUUID UUID]; AFImageDownloadReceipt *receipt; receipt = [downloader downloadImageForURLRequest:urlRequest withReceiptID:downloadID success:^(NSURLRequest * _Nonnull request, NSHTTPURLResponse * _Nullable response, UIImage * _Nonnull responseObject) { __strong __typeof(weakSelf)strongSelf = weakSelf; if ([[strongSelf af_imageDownloadReceiptForState:state].receiptID isEqual:downloadID]) { if (success) { success(request, response, responseObject); } else if(responseObject) { [strongSelf setImage:responseObject forState:state]; } [strongSelf af_setImageDownloadReceipt:nil forState:state]; } } failure:^(NSURLRequest * _Nonnull request, NSHTTPURLResponse * _Nullable response, NSError * _Nonnull error) { __strong __typeof(weakSelf)strongSelf = weakSelf; if ([[strongSelf af_imageDownloadReceiptForState:state].receiptID isEqual:downloadID]) { if (failure) { failure(request, response, error); } [strongSelf af_setImageDownloadReceipt:nil forState:state]; } }]; [self af_setImageDownloadReceipt:receipt forState:state]; } } #pragma mark - - (void)setBackgroundImageForState:(UIControlState)state withURL:(NSURL *)url { [self setBackgroundImageForState:state withURL:url placeholderImage:nil]; } - (void)setBackgroundImageForState:(UIControlState)state withURL:(NSURL *)url placeholderImage:(nullable UIImage *)placeholderImage { NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url]; [request addValue:@"image/*" forHTTPHeaderField:@"Accept"]; [self setBackgroundImageForState:state withURLRequest:request placeholderImage:placeholderImage success:nil failure:nil]; } - (void)setBackgroundImageForState:(UIControlState)state withURLRequest:(NSURLRequest *)urlRequest placeholderImage:(nullable UIImage *)placeholderImage success:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, UIImage *image))success failure:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, NSError *error))failure { if ([self isActiveBackgroundTaskURLEqualToURLRequest:urlRequest forState:state]) { return; } [self cancelBackgroundImageDownloadTaskForState:state]; AFImageDownloader *downloader = [[self class] sharedImageDownloader]; id <AFImageRequestCache> imageCache = downloader.imageCache; //Use the image from the image cache if it exists UIImage *cachedImage = [imageCache imageforRequest:urlRequest withAdditionalIdentifier:nil]; if (cachedImage) { if (success) { success(urlRequest, nil, cachedImage); } else { [self setBackgroundImage:cachedImage forState:state]; } [self af_setBackgroundImageDownloadReceipt:nil forState:state]; } else { if (placeholderImage) { [self setBackgroundImage:placeholderImage forState:state]; } __weak __typeof(self)weakSelf = self; NSUUID *downloadID = [NSUUID UUID]; AFImageDownloadReceipt *receipt; receipt = [downloader downloadImageForURLRequest:urlRequest withReceiptID:downloadID success:^(NSURLRequest * _Nonnull request, NSHTTPURLResponse * _Nullable response, UIImage * _Nonnull responseObject) { __strong __typeof(weakSelf)strongSelf = weakSelf; if ([[strongSelf af_backgroundImageDownloadReceiptForState:state].receiptID isEqual:downloadID]) { if (success) { success(request, response, responseObject); } else if(responseObject) { [strongSelf setBackgroundImage:responseObject forState:state]; } [strongSelf af_setBackgroundImageDownloadReceipt:nil forState:state]; } } failure:^(NSURLRequest * _Nonnull request, NSHTTPURLResponse * _Nullable response, NSError * _Nonnull error) { __strong __typeof(weakSelf)strongSelf = weakSelf; if ([[strongSelf af_backgroundImageDownloadReceiptForState:state].receiptID isEqual:downloadID]) { if (failure) { failure(request, response, error); } [strongSelf af_setBackgroundImageDownloadReceipt:nil forState:state]; } }]; [self af_setBackgroundImageDownloadReceipt:receipt forState:state]; } } #pragma mark - - (void)cancelImageDownloadTaskForState:(UIControlState)state { AFImageDownloadReceipt *receipt = [self af_imageDownloadReceiptForState:state]; if (receipt != nil) { [[self.class sharedImageDownloader] cancelTaskForImageDownloadReceipt:receipt]; [self af_setImageDownloadReceipt:nil forState:state]; } } - (void)cancelBackgroundImageDownloadTaskForState:(UIControlState)state { AFImageDownloadReceipt *receipt = [self af_backgroundImageDownloadReceiptForState:state]; if (receipt != nil) { [[self.class sharedImageDownloader] cancelTaskForImageDownloadReceipt:receipt]; [self af_setBackgroundImageDownloadReceipt:nil forState:state]; } } - (BOOL)isActiveTaskURLEqualToURLRequest:(NSURLRequest *)urlRequest forState:(UIControlState)state { AFImageDownloadReceipt *receipt = [self af_imageDownloadReceiptForState:state]; return [receipt.task.originalRequest.URL.absoluteString isEqualToString:urlRequest.URL.absoluteString]; } - (BOOL)isActiveBackgroundTaskURLEqualToURLRequest:(NSURLRequest *)urlRequest forState:(UIControlState)state { AFImageDownloadReceipt *receipt = [self af_backgroundImageDownloadReceiptForState:state]; return [receipt.task.originalRequest.URL.absoluteString isEqualToString:urlRequest.URL.absoluteString]; } @end #endif ```
/content/code_sandbox/Pods/AFNetworking/UIKit+AFNetworking/UIButton+AFNetworking.m
objective-c
2016-02-02T02:51:55
2024-08-09T08:55:27
WMPlayer
zhengwenming/WMPlayer
3,272
2,474