├── .gitattributes ├── .gitignore ├── LICENSE ├── README.md ├── YZPlayer ├── Category │ ├── UILable+Extension.swift │ ├── UINavigationController+Rotation.swift │ ├── UITabBarController+Rotation.swift │ └── UIView+Position.swift ├── Resource.bundle │ ├── video_back@2x.png │ ├── video_bg_media_default@2x.png │ ├── video_fullScreen@2x.png │ ├── video_like@2x.png │ ├── video_like_sel@2x.png │ ├── video_pause@2x.png │ ├── video_pause_small@2x.png │ ├── video_play@2x.png │ ├── video_play_small@2x.png │ ├── video_progress_left@2x.png │ ├── video_progress_left@3x.png │ ├── video_progress_right@2x.png │ ├── video_progress_right@3x.png │ ├── video_sliderControl@2x.png │ ├── video_sliderControl_small@2x.png │ ├── video_topBackground@2x.png │ └── video_topBackground_small@2x.png ├── YZPlayer.swift ├── YZPlayerTimeSheet.swift ├── YZPlayerView.swift ├── YZPlayerViewBottomTool.swift ├── YZPlayerViewTopTool.swift └── YZVideo.swift └── YZPlayerDemo ├── Demo.gif ├── Demo1.PNG ├── Demo2.PNG ├── Demo3.PNG ├── YZPlayerDemo.xcodeproj ├── project.pbxproj └── project.xcworkspace │ └── contents.xcworkspacedata ├── YZPlayerDemo ├── AppDelegate.swift ├── Assets.xcassets │ ├── AppIcon.appiconset │ │ ├── Contents.json │ │ ├── icon-120-1.png │ │ ├── icon-120.png │ │ ├── icon-180.png │ │ ├── icon-40.png │ │ ├── icon-58.png │ │ ├── icon-60.png │ │ ├── icon-80.png │ │ └── icon-87.png │ ├── Contents.json │ ├── cat.imageset │ │ ├── Contents.json │ │ └── cat@2x.png │ ├── jinx.imageset │ │ ├── Contents.json │ │ └── jinx@2x.png │ ├── list_comment.imageset │ │ ├── Contents.json │ │ └── list_comment@2x.png │ ├── list_daily special.imageset │ │ ├── Contents.json │ │ └── list_daily special@2x.png │ ├── list_header.imageset │ │ ├── Contents.json │ │ └── list_header@3x.png │ ├── list_watch.imageset │ │ ├── Contents.json │ │ └── list_watch@2x.png │ ├── placeholder_blank.imageset │ │ ├── Contents.json │ │ └── placeholder_blank@2x.png │ ├── seven.imageset │ │ ├── Contents.json │ │ └── seven@2x.jpg │ ├── video_comment1.imageset │ │ ├── Contents.json │ │ └── video_comment1@2x.png │ ├── video_commentClose.imageset │ │ ├── Contents.json │ │ └── video_commentClose@2x.png │ ├── video_comment_like.imageset │ │ ├── Contents.json │ │ └── video_comment_like@2x.png │ ├── video_like.imageset │ │ ├── Contents.json │ │ └── video_like@2x.png │ ├── video_like_sel.imageset │ │ ├── Contents.json │ │ └── video_like_sel@2x.png │ ├── video_next.imageset │ │ ├── Contents.json │ │ ├── video_next@2x.png │ │ └── video_next@3x.png │ ├── video_report.imageset │ │ ├── Contents.json │ │ └── video_report@2x.png │ └── video_share.imageset │ │ ├── Contents.json │ │ └── video_share@2x.png ├── Base.lproj │ └── LaunchScreen.storyboard ├── ConfigFile.swift ├── Controller │ ├── YZCommentEditController.swift │ ├── YZVideoController.swift │ └── YZVideoListController.swift ├── Info.plist ├── Libs │ ├── MJRefresh │ │ ├── Base │ │ │ ├── MJRefreshAutoFooter.h │ │ │ ├── MJRefreshAutoFooter.m │ │ │ ├── MJRefreshBackFooter.h │ │ │ ├── MJRefreshBackFooter.m │ │ │ ├── MJRefreshComponent.h │ │ │ ├── MJRefreshComponent.m │ │ │ ├── MJRefreshFooter.h │ │ │ ├── MJRefreshFooter.m │ │ │ ├── MJRefreshHeader.h │ │ │ └── MJRefreshHeader.m │ │ ├── Custom │ │ │ ├── Footer │ │ │ │ ├── Auto │ │ │ │ │ ├── MJRefreshAutoGifFooter.h │ │ │ │ │ ├── MJRefreshAutoGifFooter.m │ │ │ │ │ ├── MJRefreshAutoNormalFooter.h │ │ │ │ │ ├── MJRefreshAutoNormalFooter.m │ │ │ │ │ ├── MJRefreshAutoStateFooter.h │ │ │ │ │ └── MJRefreshAutoStateFooter.m │ │ │ │ └── Back │ │ │ │ │ ├── MJRefreshBackGifFooter.h │ │ │ │ │ ├── MJRefreshBackGifFooter.m │ │ │ │ │ ├── MJRefreshBackNormalFooter.h │ │ │ │ │ ├── MJRefreshBackNormalFooter.m │ │ │ │ │ ├── MJRefreshBackStateFooter.h │ │ │ │ │ └── MJRefreshBackStateFooter.m │ │ │ └── Header │ │ │ │ ├── MJRefreshGifHeader.h │ │ │ │ ├── MJRefreshGifHeader.m │ │ │ │ ├── MJRefreshNormalHeader.h │ │ │ │ ├── MJRefreshNormalHeader.m │ │ │ │ ├── MJRefreshStateHeader.h │ │ │ │ └── MJRefreshStateHeader.m │ │ ├── MJRefresh.bundle │ │ │ ├── arrow@2x.png │ │ │ ├── en.lproj │ │ │ │ └── Localizable.strings │ │ │ ├── zh-Hans.lproj │ │ │ │ └── Localizable.strings │ │ │ └── zh-Hant.lproj │ │ │ │ └── Localizable.strings │ │ ├── MJRefresh.h │ │ ├── MJRefreshConst.h │ │ ├── MJRefreshConst.m │ │ ├── NSBundle+MJRefresh.h │ │ ├── NSBundle+MJRefresh.m │ │ ├── UIScrollView+MJExtension.h │ │ ├── UIScrollView+MJExtension.m │ │ ├── UIScrollView+MJRefresh.h │ │ ├── UIScrollView+MJRefresh.m │ │ ├── UIView+MJExtension.h │ │ └── UIView+MJExtension.m │ ├── SnapKit │ │ ├── Constraint.swift │ │ ├── ConstraintAttributes.swift │ │ ├── ConstraintConfig.swift │ │ ├── ConstraintConstantTarget.swift │ │ ├── ConstraintDSL.swift │ │ ├── ConstraintDescription.swift │ │ ├── ConstraintInsetTarget.swift │ │ ├── ConstraintInsets.swift │ │ ├── ConstraintItem.swift │ │ ├── ConstraintLayoutGuide+Extensions.swift │ │ ├── ConstraintLayoutGuide.swift │ │ ├── ConstraintLayoutGuideDSL.swift │ │ ├── ConstraintLayoutSupport.swift │ │ ├── ConstraintLayoutSupportDSL.swift │ │ ├── ConstraintMaker.swift │ │ ├── ConstraintMakerEditable.swift │ │ ├── ConstraintMakerExtendable.swift │ │ ├── ConstraintMakerFinalizable.swift │ │ ├── ConstraintMakerPriortizable.swift │ │ ├── ConstraintMakerRelatable.swift │ │ ├── ConstraintMultiplierTarget.swift │ │ ├── ConstraintOffsetTarget.swift │ │ ├── ConstraintPriority.swift │ │ ├── ConstraintPriorityTarget.swift │ │ ├── ConstraintRelatableTarget.swift │ │ ├── ConstraintRelation.swift │ │ ├── ConstraintView+Extensions.swift │ │ ├── ConstraintView.swift │ │ ├── ConstraintViewDSL.swift │ │ ├── Debugging.swift │ │ ├── Info.plist │ │ ├── LayoutConstraint.swift │ │ ├── LayoutConstraintItem.swift │ │ ├── SnapKit.h │ │ └── UILayoutSupport+Extensions.swift │ └── YYWebImage │ │ ├── Cache │ │ ├── YYCache.h │ │ ├── YYCache.m │ │ ├── YYDiskCache.h │ │ ├── YYDiskCache.m │ │ ├── YYKVStorage.h │ │ ├── YYKVStorage.m │ │ ├── YYMemoryCache.h │ │ └── YYMemoryCache.m │ │ ├── Categories │ │ ├── CALayer+YYWebImage.h │ │ ├── CALayer+YYWebImage.m │ │ ├── MKAnnotationView+YYWebImage.h │ │ ├── MKAnnotationView+YYWebImage.m │ │ ├── UIButton+YYWebImage.h │ │ ├── UIButton+YYWebImage.m │ │ ├── UIImage+YYWebImage.h │ │ ├── UIImage+YYWebImage.m │ │ ├── UIImageView+YYWebImage.h │ │ ├── UIImageView+YYWebImage.m │ │ ├── _YYWebImageSetter.h │ │ └── _YYWebImageSetter.m │ │ ├── Image │ │ ├── YYAnimatedImageView.h │ │ ├── YYAnimatedImageView.m │ │ ├── YYFrameImage.h │ │ ├── YYFrameImage.m │ │ ├── YYImage.h │ │ ├── YYImage.m │ │ ├── YYImageCoder.h │ │ ├── YYImageCoder.m │ │ ├── YYSpriteSheetImage.h │ │ └── YYSpriteSheetImage.m │ │ ├── YYImageCache.h │ │ ├── YYImageCache.m │ │ ├── YYWebImage.h │ │ ├── YYWebImageManager.h │ │ ├── YYWebImageManager.m │ │ ├── YYWebImageOperation.h │ │ └── YYWebImageOperation.m ├── Model │ └── YZDemoVideo.swift ├── Tools │ ├── CommonTools.swift │ ├── UIBarButtonItem+Extension.swift │ ├── UIImage+Extension.swift │ └── UIViewController+Extension.swift ├── View │ ├── List │ │ ├── YZListHeaderView.swift │ │ └── YZVideoListCell.swift │ ├── Others │ │ ├── YZVideoAllCommentCell.swift │ │ ├── YZVideoAuthorInfoCell.swift │ │ ├── YZVideoCommentCell.swift │ │ ├── YZVideoInfoCell.swift │ │ ├── YZVideoRecommendMediaCell.swift │ │ ├── YZVideoSelectionsCell.swift │ │ └── YZVideoUserInputCell.swift │ ├── YZVideoCommentView.swift │ └── YZVideoToolBar.swift ├── ViewModel │ └── YZVideoListViewModel.swift ├── YZPlayerDemo-Bridging-Header.h └── video └── YZPlayerDemoTests ├── Info.plist └── YZPlayerDemoTests.swift /.gitattributes: -------------------------------------------------------------------------------- 1 | *.h linguist-language=swift 2 | *.m linguist-language=swift -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## Build generated 6 | build/ 7 | DerivedData 8 | 9 | ## Various settings 10 | *.pbxuser 11 | !default.pbxuser 12 | *.mode1v3 13 | !default.mode1v3 14 | *.mode2v3 15 | !default.mode2v3 16 | *.perspectivev3 17 | !default.perspectivev3 18 | xcuserdata 19 | 20 | ## Other 21 | *.xccheckout 22 | *.moved-aside 23 | *.xcuserstate 24 | *.xcscmblueprint 25 | 26 | ## Obj-C/Swift specific 27 | *.hmap 28 | *.ipa 29 | 30 | # Swift Package Manager 31 | # 32 | # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. 33 | # Packages/ 34 | .build/ 35 | 36 | # CocoaPods 37 | # 38 | # We recommend against adding the Pods directory to your .gitignore. However 39 | # you should judge for yourself, the pros and cons are mentioned at: 40 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 41 | # 42 | Pods/ 43 | 44 | # Carthage 45 | # 46 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 47 | # Carthage/Checkouts 48 | 49 | Carthage/Build 50 | 51 | # fastlane 52 | # 53 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 54 | # screenshots whenever they are needed. 55 | # For more information about the recommended setup visit: 56 | # https://github.com/fastlane/fastlane/blob/master/docs/Gitignore.md 57 | 58 | fastlane/report.xml 59 | fastlane/screenshots 60 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2017 Yuze He 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## YZPlayer 2 | 3 | [![License MIT](https://img.shields.io/badge/license-MIT-green.svg?style=flat)](https://raw.githubusercontent.com/coolryze/YZPlayer/master/LICENSE)  4 | [![Platform](https://img.shields.io/badge/platform-iOS-lightgrey.svg)](https://www.apple.com/nl/ios/)  5 | [![Support](https://img.shields.io/badge/support-iOS%207%2B%20-blue.svg?style=flat)](https://www.apple.com/nl/ios/)  6 | 7 | A simple video player for iOS, based on AVPlayer. Support the vertical, horizontal screen. Support adjust volume, screen brigtness and video progress. 8 | 9 | Update: Swift 2.2 -> Swift 3.0 -> Swift 3.1 10 | 11 | ![Demo](https://raw.github.com/coolryze/YZPlayer/master/YZPlayerDemo/Demo.gif) 12 | 13 | 14 | ## Features 15 | 16 | - Rotate automatically according to the screen. 17 | - Support for horizontal and vertical play mode. 18 | - Support play with online URL video file. 19 | - Adjust screen brightness by slide vertical at left side of screen. 20 | - Adjust volume by slide vertical at right side of screen. 21 | - Slide horizontal to fast forward and rewind. 22 | 23 | 24 | ## Requirements 25 | 26 | This library requires `iOS 7.0+`, `Swift 3` and `Xcode 8.0+`. 27 | 28 | 29 | ## Usage 30 | 31 | 1. Add Key `View controller-based status bar appearance` value `NO` to `info.plist`. 32 | 33 | 2. In your ViewController, override `shouldAutorotate`. 34 | 35 | ```swift 36 | override var shouldAutorotate : Bool { 37 | return false 38 | } 39 | ``` 40 | 41 | 3. Add YZPlayerView to play video. 42 | 43 | ```swift 44 | let video = YZVideo(play_address: "https://mu.mumov.com/videogHDk7k6vxjiahC0yPRAXBN3omu", title: "旅游丨柏林的符号学") 45 | let playerView = YZPlayerView() 46 | playerView.video = video 47 | playerView.delegate = self 48 | playerView.containerController = self 49 | self.view.addSubview(playerView) 50 | 51 | playerView.play() 52 | ``` 53 | 54 | 4. Implements YZPlayerViewDelegate. 55 | 56 | ```swift 57 | // click backButton 58 | func backAction() { 59 | // _ = navigationController?.popViewController(animated: true) 60 | } 61 | 62 | // click likeButton 63 | func likeAction(isLike: Bool) { 64 | // isLike ? print("like") : print("dislike") 65 | } 66 | ``` 67 | 68 | 69 | ## Installation 70 | 71 | 1. Download all the files in the YYPlayer subdirectory. 72 | 2. Add the source files to your Xcode project. 73 | 74 | 75 | ## Picture demonstration 76 | 77 | ![Demo1](https://github.com/coolryze/YZPlayer/blob/master/YZPlayerDemo/Demo1.PNG?raw=true) 78 | ![Demo2](https://github.com/coolryze/YZPlayer/blob/master/YZPlayerDemo/Demo2.PNG?raw=true) 79 | ![Demo3](https://github.com/coolryze/YZPlayer/blob/master/YZPlayerDemo/Demo3.PNG?raw=true) 80 | 81 | 82 | ## License 83 | 84 | YZPlayer is provided under the MIT license. See LICENSE file for details. -------------------------------------------------------------------------------- /YZPlayer/Category/UILable+Extension.swift: -------------------------------------------------------------------------------- 1 | // 2 | // UILable+Extension.swift 3 | // MU 4 | // 5 | // Created by heyuze on 16/7/11. 6 | // Copyright © 2016年 HYZ. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | extension UILabel { 12 | 13 | convenience init(text: String? = nil, textColor: UIColor, fontSize: CGFloat) { 14 | self.init() 15 | if text != nil { 16 | self.text = text 17 | } 18 | self.textColor = textColor 19 | self.font = UIFont.systemFont(ofSize: fontSize) 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /YZPlayer/Category/UINavigationController+Rotation.swift: -------------------------------------------------------------------------------- 1 | // 2 | // UINavigationController+Rotation.swift 3 | // YZPlayerDemo 4 | // 5 | // Created by heyuze on 2017/5/15. 6 | // Copyright © 2017年 heyuze. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | extension UINavigationController { 12 | 13 | // 重写 shouldAutorotate 属性,保证 NavigationController 嵌套下的控制器能根据自身属性决定是否旋转 14 | open override var shouldAutorotate: Bool { 15 | return viewControllers.last!.shouldAutorotate 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /YZPlayer/Category/UITabBarController+Rotation.swift: -------------------------------------------------------------------------------- 1 | // 2 | // UITabBarViewController+Rotation.swift 3 | // YZPlayerDemo 4 | // 5 | // Created by heyuze on 2017/5/15. 6 | // Copyright © 2017年 heyuze. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | extension UITabBarController { 12 | 13 | // 重写 shouldAutorotate 属性,保证 TabBarController 嵌套下的控制器能根据自身属性决定是否旋转 14 | open override var shouldAutorotate: Bool { 15 | return viewControllers!.last!.shouldAutorotate 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /YZPlayer/Category/UIView+Position.swift: -------------------------------------------------------------------------------- 1 | // 2 | // UIView+Position.swift 3 | // MU 4 | // 5 | // Created by heyuze on 16/7/14. 6 | // Copyright © 2016年 HYZ. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | extension UIView { 12 | 13 | public var x: CGFloat { 14 | get { 15 | return self.frame.origin.x 16 | } 17 | set { 18 | var r = self.frame 19 | r.origin.x = newValue 20 | self.frame = r 21 | } 22 | } 23 | 24 | public var y: CGFloat { 25 | get{ 26 | return self.frame.origin.y 27 | } 28 | set { 29 | var r = self.frame 30 | r.origin.y = newValue 31 | self.frame = r 32 | } 33 | } 34 | 35 | // 右边界的x值 36 | public var rightX: CGFloat { 37 | get { 38 | return self.x + self.width 39 | } 40 | set { 41 | var r = self.frame 42 | r.origin.x = newValue - frame.size.width 43 | self.frame = r 44 | } 45 | } 46 | 47 | // 下边界的y值 48 | public var bottomY: CGFloat { 49 | get { 50 | return self.y + self.height 51 | } 52 | set { 53 | var r = self.frame 54 | r.origin.y = newValue - frame.size.height 55 | self.frame = r 56 | } 57 | } 58 | 59 | public var centerX : CGFloat { 60 | get { 61 | return self.center.x 62 | } 63 | set { 64 | self.center = CGPoint(x: newValue, y: self.center.y) 65 | } 66 | } 67 | 68 | public var centerY : CGFloat { 69 | get { 70 | return self.center.y 71 | } 72 | set { 73 | self.center = CGPoint(x: self.center.x, y: newValue) 74 | } 75 | } 76 | 77 | public var width: CGFloat { 78 | get { 79 | return self.frame.size.width 80 | } 81 | set { 82 | var r = self.frame 83 | r.size.width = newValue 84 | self.frame = r 85 | } 86 | } 87 | 88 | public var height: CGFloat { 89 | get { 90 | return self.frame.size.height 91 | } 92 | set { 93 | var r = self.frame 94 | r.size.height = newValue 95 | self.frame = r 96 | } 97 | } 98 | 99 | 100 | public var origin: CGPoint { 101 | get { 102 | return self.frame.origin 103 | } 104 | set { 105 | self.x = newValue.x 106 | self.y = newValue.y 107 | } 108 | } 109 | 110 | public var size: CGSize { 111 | get { 112 | return self.frame.size 113 | } 114 | set { 115 | self.width = newValue.width 116 | self.height = newValue.height 117 | } 118 | } 119 | 120 | } 121 | -------------------------------------------------------------------------------- /YZPlayer/Resource.bundle/video_back@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coolryze/Player/8f0b6dd1bfd9521618d76786bced9154fdce81db/YZPlayer/Resource.bundle/video_back@2x.png -------------------------------------------------------------------------------- /YZPlayer/Resource.bundle/video_bg_media_default@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coolryze/Player/8f0b6dd1bfd9521618d76786bced9154fdce81db/YZPlayer/Resource.bundle/video_bg_media_default@2x.png -------------------------------------------------------------------------------- /YZPlayer/Resource.bundle/video_fullScreen@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coolryze/Player/8f0b6dd1bfd9521618d76786bced9154fdce81db/YZPlayer/Resource.bundle/video_fullScreen@2x.png -------------------------------------------------------------------------------- /YZPlayer/Resource.bundle/video_like@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coolryze/Player/8f0b6dd1bfd9521618d76786bced9154fdce81db/YZPlayer/Resource.bundle/video_like@2x.png -------------------------------------------------------------------------------- /YZPlayer/Resource.bundle/video_like_sel@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coolryze/Player/8f0b6dd1bfd9521618d76786bced9154fdce81db/YZPlayer/Resource.bundle/video_like_sel@2x.png -------------------------------------------------------------------------------- /YZPlayer/Resource.bundle/video_pause@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coolryze/Player/8f0b6dd1bfd9521618d76786bced9154fdce81db/YZPlayer/Resource.bundle/video_pause@2x.png -------------------------------------------------------------------------------- /YZPlayer/Resource.bundle/video_pause_small@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coolryze/Player/8f0b6dd1bfd9521618d76786bced9154fdce81db/YZPlayer/Resource.bundle/video_pause_small@2x.png -------------------------------------------------------------------------------- /YZPlayer/Resource.bundle/video_play@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coolryze/Player/8f0b6dd1bfd9521618d76786bced9154fdce81db/YZPlayer/Resource.bundle/video_play@2x.png -------------------------------------------------------------------------------- /YZPlayer/Resource.bundle/video_play_small@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coolryze/Player/8f0b6dd1bfd9521618d76786bced9154fdce81db/YZPlayer/Resource.bundle/video_play_small@2x.png -------------------------------------------------------------------------------- /YZPlayer/Resource.bundle/video_progress_left@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coolryze/Player/8f0b6dd1bfd9521618d76786bced9154fdce81db/YZPlayer/Resource.bundle/video_progress_left@2x.png -------------------------------------------------------------------------------- /YZPlayer/Resource.bundle/video_progress_left@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coolryze/Player/8f0b6dd1bfd9521618d76786bced9154fdce81db/YZPlayer/Resource.bundle/video_progress_left@3x.png -------------------------------------------------------------------------------- /YZPlayer/Resource.bundle/video_progress_right@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coolryze/Player/8f0b6dd1bfd9521618d76786bced9154fdce81db/YZPlayer/Resource.bundle/video_progress_right@2x.png -------------------------------------------------------------------------------- /YZPlayer/Resource.bundle/video_progress_right@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coolryze/Player/8f0b6dd1bfd9521618d76786bced9154fdce81db/YZPlayer/Resource.bundle/video_progress_right@3x.png -------------------------------------------------------------------------------- /YZPlayer/Resource.bundle/video_sliderControl@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coolryze/Player/8f0b6dd1bfd9521618d76786bced9154fdce81db/YZPlayer/Resource.bundle/video_sliderControl@2x.png -------------------------------------------------------------------------------- /YZPlayer/Resource.bundle/video_sliderControl_small@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coolryze/Player/8f0b6dd1bfd9521618d76786bced9154fdce81db/YZPlayer/Resource.bundle/video_sliderControl_small@2x.png -------------------------------------------------------------------------------- /YZPlayer/Resource.bundle/video_topBackground@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coolryze/Player/8f0b6dd1bfd9521618d76786bced9154fdce81db/YZPlayer/Resource.bundle/video_topBackground@2x.png -------------------------------------------------------------------------------- /YZPlayer/Resource.bundle/video_topBackground_small@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coolryze/Player/8f0b6dd1bfd9521618d76786bced9154fdce81db/YZPlayer/Resource.bundle/video_topBackground_small@2x.png -------------------------------------------------------------------------------- /YZPlayer/YZPlayer.swift: -------------------------------------------------------------------------------- 1 | // 2 | // YZPlayer.swift 3 | // YZPlayerDemo 4 | // 5 | // Created by heyuze on 2017/5/15. 6 | // Copyright © 2017年 heyuze. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | 12 | // MARK: - Size 13 | 14 | let kScreenWidth = UIScreen.main.bounds.size.width 15 | let kScreenHeight = UIScreen.main.bounds.size.height 16 | let kScreenBounds = UIScreen.main.bounds 17 | let PlayerViewHeight: CGFloat = kScreenWidth * (750/1334) 18 | 19 | 20 | // MARK: - Color 21 | 22 | let WHITE = RGB(r: 0xff, g: 0xff, b: 0xff, alpha: 1) 23 | let BLUE = RGB(r: 0x00, g: 0x56, b: 0xff, alpha: 1) 24 | 25 | 26 | // MARK: - String 27 | 28 | private let ResourcePath = Bundle.main.path(forResource: "Resource", ofType: "bundle") 29 | 30 | 31 | // MARK: - Function 32 | 33 | // 加载 Resource.bundle 存放的图片 34 | func YZPlayerImage(named: String) -> UIImage? { 35 | let imageName = ResourcePath?.appending("/\(named)") 36 | let image = UIImage(named: imageName!) 37 | return image 38 | } 39 | 40 | // RGB 颜色 41 | func RGB(r: CGFloat, g: CGFloat, b: CGFloat, alpha: CGFloat) -> UIColor { 42 | return UIColor(red: r / 255, green: g / 255, blue: b / 255, alpha: alpha) 43 | } 44 | 45 | // 自定义 Log 46 | func printLog(_ message: Any, file: String = #file, line: Int = #line, function: String = #function) 47 | { 48 | #if DEBUG 49 | print("\((file as NSString).lastPathComponent)[\(line)], \(function): \(message)\n") 50 | #endif 51 | } 52 | 53 | -------------------------------------------------------------------------------- /YZPlayer/YZPlayerTimeSheet.swift: -------------------------------------------------------------------------------- 1 | // 2 | // YZPlayerTimeSheet.swift 3 | // AVPlayerDemo 4 | // 5 | // Created by heyuze on 2016/11/24. 6 | // Copyright © 2016年 heyuze. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class YZPlayerTimeSheet: UIView { 12 | 13 | var isLeft: Bool = true { 14 | didSet { 15 | if isLeft { 16 | sheetStateImageView.image = YZPlayerImage(named: "video_progress_left") 17 | } else { 18 | sheetStateImageView.image = YZPlayerImage(named: "video_progress_right") 19 | } 20 | } 21 | } 22 | 23 | var timeStr: String? { 24 | didSet { 25 | sheetTimeLabel.text = timeStr 26 | } 27 | } 28 | 29 | 30 | // MARK: - init 31 | 32 | override init(frame: CGRect) { 33 | super.init(frame: frame) 34 | 35 | setupUI() 36 | } 37 | 38 | required init?(coder aDecoder: NSCoder) { 39 | fatalError("init(coder:) has not been implemented") 40 | } 41 | 42 | deinit { 43 | printLog("YZPlayerTimeSheet deinit") 44 | } 45 | 46 | 47 | // MARK: - Set up 48 | 49 | private func setupUI() { 50 | backgroundColor = RGB(r: 0x00, g: 0x00, b: 0x00, alpha: 0.3) 51 | 52 | addSubview(sheetStateImageView) 53 | addSubview(sheetTimeLabel) 54 | } 55 | 56 | 57 | // MARK: - Lazy Load 58 | 59 | private lazy var sheetStateImageView: UIImageView = { 60 | let sheetStateImageView = UIImageView(frame: CGRect(x: 54, y: 12, width: 43, height: 25)) 61 | sheetStateImageView.image = YZPlayerImage(named: "video_progress_left") 62 | return sheetStateImageView 63 | }() 64 | 65 | private lazy var sheetTimeLabel: UILabel = { 66 | let sheetTimeLabel = UILabel(text: "00:00:00 / 00:00:00", textColor: WHITE, fontSize: 12) 67 | sheetTimeLabel.frame = CGRect(x: 16, y: 49, width: 118, height: 16) 68 | sheetTimeLabel.textAlignment = .center 69 | return sheetTimeLabel 70 | }() 71 | 72 | } 73 | -------------------------------------------------------------------------------- /YZPlayer/YZPlayerViewTopTool.swift: -------------------------------------------------------------------------------- 1 | // 2 | // YZPlayerViewTopTool.swift 3 | // AVPlayerDemo 4 | // 5 | // Created by heyuze on 2016/11/23. 6 | // Copyright © 2016年 heyuze. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | protocol YZPlayerViewTopToolDelegate: NSObjectProtocol { 12 | 13 | func back() 14 | 15 | func like(isLike: Bool) 16 | 17 | } 18 | 19 | 20 | class YZPlayerViewTopTool: UIView { 21 | 22 | weak var delegate: YZPlayerViewTopToolDelegate? 23 | 24 | var title: String? { 25 | didSet { 26 | titleLabel.text = title 27 | } 28 | } 29 | 30 | 31 | // MARK: - init 32 | 33 | override init(frame: CGRect) { 34 | super.init(frame: frame) 35 | 36 | setupUI() 37 | } 38 | 39 | required init?(coder aDecoder: NSCoder) { 40 | fatalError("init(coder:) has not been implemented") 41 | } 42 | 43 | deinit { 44 | printLog("YZPlayerViewTopTool deinit") 45 | } 46 | 47 | 48 | // MARK: - Set up 49 | 50 | private func setupUI() { 51 | addSubview(backgroundView) 52 | addSubview(backBtn) 53 | addSubview(titleLabel) 54 | addSubview(likeBtn) 55 | 56 | setupFrame(isFullScreen: false) 57 | } 58 | 59 | func setupFrame(isFullScreen: Bool) { 60 | if isFullScreen { 61 | titleLabel.isHidden = false 62 | likeBtn.isHidden = false 63 | backgroundView.frame = CGRect(x: 0, y: 0, width: self.width, height: self.height) 64 | backgroundView.image = YZPlayerImage(named: "video_topBackground") 65 | backBtn.frame = CGRect(x: 20, y: 25, width: 40, height: 40) 66 | titleLabel.frame = CGRect(x: backBtn.rightX+10, y: 0, width: self.width-200, height: 30) 67 | titleLabel.centerY = backBtn.centerY 68 | likeBtn.frame = CGRect(x: self.width-25-40, y: 25, width: 40, height: 40) 69 | } else { 70 | likeBtn.isHidden = true 71 | titleLabel.isHidden = true 72 | backgroundView.frame = CGRect(x: 0, y: 0, width: self.width, height: self.height) 73 | backgroundView.image = YZPlayerImage(named: "video_topBackground_small") 74 | backBtn.frame = CGRect(x: 5, y: 22, width: 40, height: 40) 75 | } 76 | } 77 | 78 | 79 | // MARK: - Action 80 | 81 | @objc fileprivate func clickBackBtn() { 82 | if delegate != nil { 83 | delegate?.back() 84 | } 85 | } 86 | 87 | @objc fileprivate func clickLikeBtn() { 88 | let isLike = likeBtn.isSelected 89 | likeBtn.isSelected = !isLike 90 | if delegate != nil { 91 | delegate?.like(isLike: !isLike) 92 | } 93 | let animation: CAKeyframeAnimation = CAKeyframeAnimation() 94 | animation.keyPath = "transform.scale" 95 | animation.values = [1.0, 1.3, 0.9, 1.0] 96 | animation.duration = 0.25 97 | animation.calculationMode = kCAAnimationCubic 98 | likeBtn.layer.add(animation, forKey: nil) 99 | } 100 | 101 | func likeBtnSelect(selected: Bool) { 102 | likeBtn.isSelected = selected 103 | } 104 | 105 | 106 | // MARK: - Lazy load 107 | 108 | private lazy var backgroundView = UIImageView() 109 | 110 | private lazy var backBtn: UIButton = { 111 | let backBtn = UIButton() 112 | backBtn.setImage(YZPlayerImage(named: "video_back"), for: .normal) 113 | backBtn.addTarget(self, action: #selector(self.clickBackBtn), for: .touchUpInside) 114 | return backBtn 115 | }() 116 | 117 | private lazy var titleLabel = UILabel(text: "Title", textColor: WHITE, fontSize: 15) 118 | 119 | private lazy var likeBtn: UIButton = { 120 | let likeBtn = UIButton() 121 | likeBtn.setImage(YZPlayerImage(named: "video_like"), for: .normal) 122 | likeBtn.setImage(YZPlayerImage(named: "video_like_sel"), for: .selected) 123 | likeBtn.addTarget(self, action: #selector(self.clickLikeBtn), for: .touchUpInside) 124 | return likeBtn 125 | }() 126 | 127 | } 128 | -------------------------------------------------------------------------------- /YZPlayer/YZVideo.swift: -------------------------------------------------------------------------------- 1 | // 2 | // YZVideo.swift 3 | // YZPlayerDemo 4 | // 5 | // Created by heyuze on 2017/5/16. 6 | // Copyright © 2017年 heyuze. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class YZVideo: NSObject { 12 | 13 | var play_address: String = "" // 视频播放地址 14 | 15 | var title: String = "" // 视频标题 16 | 17 | 18 | // MARK: - init 19 | 20 | init(play_address: String, title: String) { 21 | super.init() 22 | self.play_address = play_address 23 | self.title = title 24 | } 25 | 26 | init(dict: [String : Any]) { 27 | super.init() 28 | 29 | setValuesForKeys(dict) 30 | } 31 | 32 | override func setValue(_ value: Any?, forUndefinedKey key: String) { 33 | 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /YZPlayerDemo/Demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coolryze/Player/8f0b6dd1bfd9521618d76786bced9154fdce81db/YZPlayerDemo/Demo.gif -------------------------------------------------------------------------------- /YZPlayerDemo/Demo1.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coolryze/Player/8f0b6dd1bfd9521618d76786bced9154fdce81db/YZPlayerDemo/Demo1.PNG -------------------------------------------------------------------------------- /YZPlayerDemo/Demo2.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coolryze/Player/8f0b6dd1bfd9521618d76786bced9154fdce81db/YZPlayerDemo/Demo2.PNG -------------------------------------------------------------------------------- /YZPlayerDemo/Demo3.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coolryze/Player/8f0b6dd1bfd9521618d76786bced9154fdce81db/YZPlayerDemo/Demo3.PNG -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // YZPlayerDemo 4 | // 5 | // Created by heyuze on 2017/5/12. 6 | // Copyright © 2017年 heyuze. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | 17 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 18 | 19 | let videoListController = YZVideoListController() 20 | let navigationController = UINavigationController(rootViewController: videoListController) 21 | 22 | window = UIWindow() 23 | window?.backgroundColor = UIColor.white 24 | window?.rootViewController = navigationController 25 | window?.makeKeyAndVisible() 26 | 27 | return true 28 | } 29 | 30 | func applicationWillResignActive(_ application: UIApplication) { 31 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 32 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 33 | } 34 | 35 | func applicationDidEnterBackground(_ application: UIApplication) { 36 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 37 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 38 | } 39 | 40 | func applicationWillEnterForeground(_ application: UIApplication) { 41 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. 42 | } 43 | 44 | func applicationDidBecomeActive(_ application: UIApplication) { 45 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 46 | } 47 | 48 | func applicationWillTerminate(_ application: UIApplication) { 49 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 50 | } 51 | 52 | 53 | } 54 | 55 | -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "20x20", 5 | "idiom" : "iphone", 6 | "filename" : "icon-40.png", 7 | "scale" : "2x" 8 | }, 9 | { 10 | "size" : "20x20", 11 | "idiom" : "iphone", 12 | "filename" : "icon-60.png", 13 | "scale" : "3x" 14 | }, 15 | { 16 | "size" : "29x29", 17 | "idiom" : "iphone", 18 | "filename" : "icon-58.png", 19 | "scale" : "2x" 20 | }, 21 | { 22 | "size" : "29x29", 23 | "idiom" : "iphone", 24 | "filename" : "icon-87.png", 25 | "scale" : "3x" 26 | }, 27 | { 28 | "size" : "40x40", 29 | "idiom" : "iphone", 30 | "filename" : "icon-80.png", 31 | "scale" : "2x" 32 | }, 33 | { 34 | "size" : "40x40", 35 | "idiom" : "iphone", 36 | "filename" : "icon-120.png", 37 | "scale" : "3x" 38 | }, 39 | { 40 | "size" : "60x60", 41 | "idiom" : "iphone", 42 | "filename" : "icon-120-1.png", 43 | "scale" : "2x" 44 | }, 45 | { 46 | "size" : "60x60", 47 | "idiom" : "iphone", 48 | "filename" : "icon-180.png", 49 | "scale" : "3x" 50 | } 51 | ], 52 | "info" : { 53 | "version" : 1, 54 | "author" : "xcode" 55 | } 56 | } -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/Assets.xcassets/AppIcon.appiconset/icon-120-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coolryze/Player/8f0b6dd1bfd9521618d76786bced9154fdce81db/YZPlayerDemo/YZPlayerDemo/Assets.xcassets/AppIcon.appiconset/icon-120-1.png -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/Assets.xcassets/AppIcon.appiconset/icon-120.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coolryze/Player/8f0b6dd1bfd9521618d76786bced9154fdce81db/YZPlayerDemo/YZPlayerDemo/Assets.xcassets/AppIcon.appiconset/icon-120.png -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/Assets.xcassets/AppIcon.appiconset/icon-180.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coolryze/Player/8f0b6dd1bfd9521618d76786bced9154fdce81db/YZPlayerDemo/YZPlayerDemo/Assets.xcassets/AppIcon.appiconset/icon-180.png -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/Assets.xcassets/AppIcon.appiconset/icon-40.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coolryze/Player/8f0b6dd1bfd9521618d76786bced9154fdce81db/YZPlayerDemo/YZPlayerDemo/Assets.xcassets/AppIcon.appiconset/icon-40.png -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/Assets.xcassets/AppIcon.appiconset/icon-58.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coolryze/Player/8f0b6dd1bfd9521618d76786bced9154fdce81db/YZPlayerDemo/YZPlayerDemo/Assets.xcassets/AppIcon.appiconset/icon-58.png -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/Assets.xcassets/AppIcon.appiconset/icon-60.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coolryze/Player/8f0b6dd1bfd9521618d76786bced9154fdce81db/YZPlayerDemo/YZPlayerDemo/Assets.xcassets/AppIcon.appiconset/icon-60.png -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/Assets.xcassets/AppIcon.appiconset/icon-80.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coolryze/Player/8f0b6dd1bfd9521618d76786bced9154fdce81db/YZPlayerDemo/YZPlayerDemo/Assets.xcassets/AppIcon.appiconset/icon-80.png -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/Assets.xcassets/AppIcon.appiconset/icon-87.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coolryze/Player/8f0b6dd1bfd9521618d76786bced9154fdce81db/YZPlayerDemo/YZPlayerDemo/Assets.xcassets/AppIcon.appiconset/icon-87.png -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/Assets.xcassets/cat.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "cat@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/Assets.xcassets/cat.imageset/cat@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coolryze/Player/8f0b6dd1bfd9521618d76786bced9154fdce81db/YZPlayerDemo/YZPlayerDemo/Assets.xcassets/cat.imageset/cat@2x.png -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/Assets.xcassets/jinx.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "jinx@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/Assets.xcassets/jinx.imageset/jinx@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coolryze/Player/8f0b6dd1bfd9521618d76786bced9154fdce81db/YZPlayerDemo/YZPlayerDemo/Assets.xcassets/jinx.imageset/jinx@2x.png -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/Assets.xcassets/list_comment.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "list_comment@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/Assets.xcassets/list_comment.imageset/list_comment@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coolryze/Player/8f0b6dd1bfd9521618d76786bced9154fdce81db/YZPlayerDemo/YZPlayerDemo/Assets.xcassets/list_comment.imageset/list_comment@2x.png -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/Assets.xcassets/list_daily special.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "list_daily special@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/Assets.xcassets/list_daily special.imageset/list_daily special@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coolryze/Player/8f0b6dd1bfd9521618d76786bced9154fdce81db/YZPlayerDemo/YZPlayerDemo/Assets.xcassets/list_daily special.imageset/list_daily special@2x.png -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/Assets.xcassets/list_header.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "scale" : "2x" 10 | }, 11 | { 12 | "idiom" : "universal", 13 | "filename" : "list_header@3x.png", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/Assets.xcassets/list_header.imageset/list_header@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coolryze/Player/8f0b6dd1bfd9521618d76786bced9154fdce81db/YZPlayerDemo/YZPlayerDemo/Assets.xcassets/list_header.imageset/list_header@3x.png -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/Assets.xcassets/list_watch.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "list_watch@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/Assets.xcassets/list_watch.imageset/list_watch@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coolryze/Player/8f0b6dd1bfd9521618d76786bced9154fdce81db/YZPlayerDemo/YZPlayerDemo/Assets.xcassets/list_watch.imageset/list_watch@2x.png -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/Assets.xcassets/placeholder_blank.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "placeholder_blank@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/Assets.xcassets/placeholder_blank.imageset/placeholder_blank@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coolryze/Player/8f0b6dd1bfd9521618d76786bced9154fdce81db/YZPlayerDemo/YZPlayerDemo/Assets.xcassets/placeholder_blank.imageset/placeholder_blank@2x.png -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/Assets.xcassets/seven.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "seven@2x.jpg", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/Assets.xcassets/seven.imageset/seven@2x.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coolryze/Player/8f0b6dd1bfd9521618d76786bced9154fdce81db/YZPlayerDemo/YZPlayerDemo/Assets.xcassets/seven.imageset/seven@2x.jpg -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/Assets.xcassets/video_comment1.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "video_comment1@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/Assets.xcassets/video_comment1.imageset/video_comment1@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coolryze/Player/8f0b6dd1bfd9521618d76786bced9154fdce81db/YZPlayerDemo/YZPlayerDemo/Assets.xcassets/video_comment1.imageset/video_comment1@2x.png -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/Assets.xcassets/video_commentClose.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "video_commentClose@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/Assets.xcassets/video_commentClose.imageset/video_commentClose@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coolryze/Player/8f0b6dd1bfd9521618d76786bced9154fdce81db/YZPlayerDemo/YZPlayerDemo/Assets.xcassets/video_commentClose.imageset/video_commentClose@2x.png -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/Assets.xcassets/video_comment_like.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "video_comment_like@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/Assets.xcassets/video_comment_like.imageset/video_comment_like@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coolryze/Player/8f0b6dd1bfd9521618d76786bced9154fdce81db/YZPlayerDemo/YZPlayerDemo/Assets.xcassets/video_comment_like.imageset/video_comment_like@2x.png -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/Assets.xcassets/video_like.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "video_like@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/Assets.xcassets/video_like.imageset/video_like@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coolryze/Player/8f0b6dd1bfd9521618d76786bced9154fdce81db/YZPlayerDemo/YZPlayerDemo/Assets.xcassets/video_like.imageset/video_like@2x.png -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/Assets.xcassets/video_like_sel.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "video_like_sel@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/Assets.xcassets/video_like_sel.imageset/video_like_sel@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coolryze/Player/8f0b6dd1bfd9521618d76786bced9154fdce81db/YZPlayerDemo/YZPlayerDemo/Assets.xcassets/video_like_sel.imageset/video_like_sel@2x.png -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/Assets.xcassets/video_next.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "video_next@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "video_next@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/Assets.xcassets/video_next.imageset/video_next@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coolryze/Player/8f0b6dd1bfd9521618d76786bced9154fdce81db/YZPlayerDemo/YZPlayerDemo/Assets.xcassets/video_next.imageset/video_next@2x.png -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/Assets.xcassets/video_next.imageset/video_next@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coolryze/Player/8f0b6dd1bfd9521618d76786bced9154fdce81db/YZPlayerDemo/YZPlayerDemo/Assets.xcassets/video_next.imageset/video_next@3x.png -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/Assets.xcassets/video_report.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "video_report@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/Assets.xcassets/video_report.imageset/video_report@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coolryze/Player/8f0b6dd1bfd9521618d76786bced9154fdce81db/YZPlayerDemo/YZPlayerDemo/Assets.xcassets/video_report.imageset/video_report@2x.png -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/Assets.xcassets/video_share.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "video_share@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/Assets.xcassets/video_share.imageset/video_share@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coolryze/Player/8f0b6dd1bfd9521618d76786bced9154fdce81db/YZPlayerDemo/YZPlayerDemo/Assets.xcassets/video_share.imageset/video_share@2x.png -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/ConfigFile.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ConfigFile.swift 3 | // YZPlayerDemo 4 | // 5 | // Created by heyuze on 2017/5/12. 6 | // Copyright © 2017年 heyuze. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | 12 | // Size 13 | let ListCellHeight: CGFloat = kScreenWidth*(420/750) 14 | 15 | 16 | // Color 17 | //let WHITE = RGB(r: 0xff, g: 0xff, b: 0xff, alpha: 1) 18 | //let BLUE = RGB(r: 0x00, g: 0x56, b: 0xff, alpha: 1) 19 | let BLACK = RGB(r: 0x1a, g: 0x1a, b: 0x1a, alpha: 1) 20 | let BLACK_26 = RGB(r: 0x26, g: 0x26, b: 0x26, alpha: 1) 21 | let GRAY = RGB(r: 0x66, g: 0x66, b: 0x66, alpha: 1) // 灰 22 | let GRAY_99 = RGB(r: 0x99, g: 0x99, b: 0x99, alpha: 1) 23 | let BACKGROUND_COLOR = RGB(r: 0xe6, g: 0xec, b: 0xf0, alpha: 1) 24 | //let BACKGROUND_COLOR = RGB(r: 0xf6, g: 0xf7, b: 0xf8, alpha: 1) // 背景色 25 | let SHADOW_COLOR = RGB(r: 0xee, g: 0xee, b: 0xee, alpha: 1) // 阴影色 26 | 27 | 28 | // video 占位图 29 | let PLACEHOLDER_VIDEO = "placeholder_blank" 30 | -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/Controller/YZCommentEditController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // VideoCommentEditController.swift 3 | // Mov 4 | // 5 | // Created by heyuze on 2016/11/26. 6 | // Copyright © 2016年 heyuze. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class YZCommentEditController: UIViewController { 12 | 13 | deinit { 14 | print("YZCommentEditController deinit") 15 | NotificationCenter.default.removeObserver(self) 16 | } 17 | 18 | 19 | // MARK: - Life Cycle 20 | 21 | override func viewWillAppear(_ animated: Bool) { 22 | navigationController?.setNavigationBarHidden(false, animated: animated) 23 | navigationController?.navigationBar.setBackgroundImage(UIImage.colorImage(color: RGB(r: 0xf6, g: 0xf7, b: 0xf8, alpha: 1)), for: .default) 24 | navigationController?.navigationBar.shadowImage = UIImage() 25 | UIApplication.shared.statusBarStyle = .default 26 | super.viewWillAppear(animated) 27 | } 28 | 29 | override func viewDidLoad() { 30 | super.viewDidLoad() 31 | 32 | setupUI() 33 | 34 | setupEvent() 35 | 36 | textView.becomeFirstResponder() 37 | } 38 | 39 | 40 | // MARK: - Set up 41 | 42 | private func setupUI() { 43 | navigationController?.navigationBar.layer.shadowColor = RGB(r: 0xee, g: 0xee, b: 0xee, alpha: 1).cgColor 44 | navigationController?.navigationBar.layer.shadowOffset = CGSize(width: 0, height: 0.5) 45 | navigationController?.navigationBar.layer.shadowOpacity = 1 46 | navigationController?.navigationBar.layer.shadowRadius = 0.5 47 | navigationItem.titleView = naviTitleLabel(title: "评论") 48 | navigationItem.rightBarButtonItem = UIBarButtonItem(title: "发送", target: self, action: #selector(self.sendComment)) 49 | navigationItem.leftBarButtonItem = UIBarButtonItem(imageName: "video_commentClose", target: self, action: #selector(self.close)) 50 | view.backgroundColor = WHITE 51 | 52 | view.addSubview(textView) 53 | textView.snp.makeConstraints { (make) in 54 | make.top.equalTo(view).offset(5) 55 | make.leading.equalTo(view).offset(5) 56 | make.trailing.equalTo(view).offset(-5) 57 | make.bottom.equalTo(view).offset(-5) 58 | } 59 | 60 | view.addSubview(placeholderLabel) 61 | placeholderLabel.snp.makeConstraints { (make) in 62 | make.top.equalTo(view).offset(13) 63 | make.leading.equalTo(view).offset(9) 64 | } 65 | } 66 | 67 | private func setupEvent() { 68 | NotificationCenter.default.addObserver(self, selector: #selector(textViewDidChanged), name: .UITextViewTextDidChange, object: nil) 69 | } 70 | 71 | 72 | // MARK: - Action 73 | 74 | @objc private func sendComment() { 75 | 76 | } 77 | 78 | @objc private func close() { 79 | textView.resignFirstResponder() 80 | dismiss(animated: true) { 81 | print("closed") 82 | } 83 | } 84 | 85 | 86 | // MARK: - Event 87 | 88 | @objc private func textViewDidChanged() { 89 | if textView.text.characters.count == 0 { 90 | placeholderLabel.isHidden = false 91 | } else { 92 | placeholderLabel.isHidden = true 93 | } 94 | } 95 | 96 | 97 | // MARK: - Lazy Load 98 | 99 | private lazy var textView: UITextView = { 100 | let textView = UITextView() 101 | textView.font = UIFont.systemFont(ofSize: 15) 102 | textView.textColor = BLACK 103 | return textView 104 | }() 105 | 106 | private lazy var placeholderLabel = UILabel(text: "此时此刻的感想......", textColor: GRAY_99, fontSize: 15) 107 | 108 | } 109 | -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIMainStoryboardFile 26 | 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | 35 | UIViewControllerBasedStatusBarAppearance 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/Libs/MJRefresh/Base/MJRefreshAutoFooter.h: -------------------------------------------------------------------------------- 1 | // 2 | // MJRefreshAutoFooter.h 3 | // MJRefreshExample 4 | // 5 | // Created by MJ Lee on 15/4/24. 6 | // Copyright (c) 2015年 小码哥. All rights reserved. 7 | // 8 | 9 | #import "MJRefreshFooter.h" 10 | 11 | @interface MJRefreshAutoFooter : MJRefreshFooter 12 | /** 是否自动刷新(默认为YES) */ 13 | @property (assign, nonatomic, getter=isAutomaticallyRefresh) BOOL automaticallyRefresh; 14 | 15 | /** 当底部控件出现多少时就自动刷新(默认为1.0,也就是底部控件完全出现时,才会自动刷新) */ 16 | @property (assign, nonatomic) CGFloat appearencePercentTriggerAutoRefresh MJRefreshDeprecated("请使用triggerAutomaticallyRefreshPercent属性"); 17 | 18 | /** 当底部控件出现多少时就自动刷新(默认为1.0,也就是底部控件完全出现时,才会自动刷新) */ 19 | @property (assign, nonatomic) CGFloat triggerAutomaticallyRefreshPercent; 20 | @end 21 | -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/Libs/MJRefresh/Base/MJRefreshBackFooter.h: -------------------------------------------------------------------------------- 1 | // 2 | // MJRefreshBackFooter.h 3 | // MJRefreshExample 4 | // 5 | // Created by MJ Lee on 15/4/24. 6 | // Copyright (c) 2015年 小码哥. All rights reserved. 7 | // 8 | 9 | #import "MJRefreshFooter.h" 10 | 11 | @interface MJRefreshBackFooter : MJRefreshFooter 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/Libs/MJRefresh/Base/MJRefreshComponent.h: -------------------------------------------------------------------------------- 1 | // 代码地址: https://github.com/CoderMJLee/MJRefresh 2 | // 代码地址: http://code4app.com/ios/%E5%BF%AB%E9%80%9F%E9%9B%86%E6%88%90%E4%B8%8B%E6%8B%89%E4%B8%8A%E6%8B%89%E5%88%B7%E6%96%B0/52326ce26803fabc46000000 3 | // MJRefreshComponent.h 4 | // MJRefreshExample 5 | // 6 | // Created by MJ Lee on 15/3/4. 7 | // Copyright (c) 2015年 小码哥. All rights reserved. 8 | // 刷新控件的基类 9 | 10 | #import 11 | #import "MJRefreshConst.h" 12 | #import "UIView+MJExtension.h" 13 | #import "UIScrollView+MJExtension.h" 14 | #import "UIScrollView+MJRefresh.h" 15 | #import "NSBundle+MJRefresh.h" 16 | 17 | /** 刷新控件的状态 */ 18 | typedef NS_ENUM(NSInteger, MJRefreshState) { 19 | /** 普通闲置状态 */ 20 | MJRefreshStateIdle = 1, 21 | /** 松开就可以进行刷新的状态 */ 22 | MJRefreshStatePulling, 23 | /** 正在刷新中的状态 */ 24 | MJRefreshStateRefreshing, 25 | /** 即将刷新的状态 */ 26 | MJRefreshStateWillRefresh, 27 | /** 所有数据加载完毕,没有更多的数据了 */ 28 | MJRefreshStateNoMoreData 29 | }; 30 | 31 | /** 进入刷新状态的回调 */ 32 | typedef void (^MJRefreshComponentRefreshingBlock)(); 33 | /** 开始刷新后的回调(进入刷新状态后的回调) */ 34 | typedef void (^MJRefreshComponentbeginRefreshingCompletionBlock)(); 35 | /** 结束刷新后的回调 */ 36 | typedef void (^MJRefreshComponentEndRefreshingCompletionBlock)(); 37 | 38 | /** 刷新控件的基类 */ 39 | @interface MJRefreshComponent : UIView 40 | { 41 | /** 记录scrollView刚开始的inset */ 42 | UIEdgeInsets _scrollViewOriginalInset; 43 | /** 父控件 */ 44 | __weak UIScrollView *_scrollView; 45 | } 46 | #pragma mark - 刷新回调 47 | /** 正在刷新的回调 */ 48 | @property (copy, nonatomic) MJRefreshComponentRefreshingBlock refreshingBlock; 49 | /** 设置回调对象和回调方法 */ 50 | - (void)setRefreshingTarget:(id)target refreshingAction:(SEL)action; 51 | 52 | /** 回调对象 */ 53 | @property (weak, nonatomic) id refreshingTarget; 54 | /** 回调方法 */ 55 | @property (assign, nonatomic) SEL refreshingAction; 56 | /** 触发回调(交给子类去调用) */ 57 | - (void)executeRefreshingCallback; 58 | 59 | #pragma mark - 刷新状态控制 60 | /** 进入刷新状态 */ 61 | - (void)beginRefreshing; 62 | - (void)beginRefreshingWithCompletionBlock:(void (^)())completionBlock; 63 | /** 开始刷新后的回调(进入刷新状态后的回调) */ 64 | @property (copy, nonatomic) MJRefreshComponentbeginRefreshingCompletionBlock beginRefreshingCompletionBlock; 65 | /** 结束刷新的回调 */ 66 | @property (copy, nonatomic) MJRefreshComponentEndRefreshingCompletionBlock endRefreshingCompletionBlock; 67 | /** 结束刷新状态 */ 68 | - (void)endRefreshing; 69 | - (void)endRefreshingWithCompletionBlock:(void (^)())completionBlock; 70 | /** 是否正在刷新 */ 71 | - (BOOL)isRefreshing; 72 | /** 刷新状态 一般交给子类内部实现 */ 73 | @property (assign, nonatomic) MJRefreshState state; 74 | 75 | #pragma mark - 交给子类去访问 76 | /** 记录scrollView刚开始的inset */ 77 | @property (assign, nonatomic, readonly) UIEdgeInsets scrollViewOriginalInset; 78 | /** 父控件 */ 79 | @property (weak, nonatomic, readonly) UIScrollView *scrollView; 80 | 81 | #pragma mark - 交给子类们去实现 82 | /** 初始化 */ 83 | - (void)prepare NS_REQUIRES_SUPER; 84 | /** 摆放子控件frame */ 85 | - (void)placeSubviews NS_REQUIRES_SUPER; 86 | /** 当scrollView的contentOffset发生改变的时候调用 */ 87 | - (void)scrollViewContentOffsetDidChange:(NSDictionary *)change NS_REQUIRES_SUPER; 88 | /** 当scrollView的contentSize发生改变的时候调用 */ 89 | - (void)scrollViewContentSizeDidChange:(NSDictionary *)change NS_REQUIRES_SUPER; 90 | /** 当scrollView的拖拽状态发生改变的时候调用 */ 91 | - (void)scrollViewPanStateDidChange:(NSDictionary *)change NS_REQUIRES_SUPER; 92 | 93 | 94 | #pragma mark - 其他 95 | /** 拉拽的百分比(交给子类重写) */ 96 | @property (assign, nonatomic) CGFloat pullingPercent; 97 | /** 根据拖拽比例自动切换透明度 */ 98 | @property (assign, nonatomic, getter=isAutoChangeAlpha) BOOL autoChangeAlpha MJRefreshDeprecated("请使用automaticallyChangeAlpha属性"); 99 | /** 根据拖拽比例自动切换透明度 */ 100 | @property (assign, nonatomic, getter=isAutomaticallyChangeAlpha) BOOL automaticallyChangeAlpha; 101 | @end 102 | 103 | @interface UILabel(MJRefresh) 104 | + (instancetype)mj_label; 105 | - (CGFloat)mj_textWith; 106 | @end 107 | -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/Libs/MJRefresh/Base/MJRefreshFooter.h: -------------------------------------------------------------------------------- 1 | // 代码地址: https://github.com/CoderMJLee/MJRefresh 2 | // 代码地址: http://code4app.com/ios/%E5%BF%AB%E9%80%9F%E9%9B%86%E6%88%90%E4%B8%8B%E6%8B%89%E4%B8%8A%E6%8B%89%E5%88%B7%E6%96%B0/52326ce26803fabc46000000 3 | // MJRefreshFooter.h 4 | // MJRefreshExample 5 | // 6 | // Created by MJ Lee on 15/3/5. 7 | // Copyright (c) 2015年 小码哥. All rights reserved. 8 | // 上拉刷新控件 9 | 10 | #import "MJRefreshComponent.h" 11 | 12 | @interface MJRefreshFooter : MJRefreshComponent 13 | /** 创建footer */ 14 | + (instancetype)footerWithRefreshingBlock:(MJRefreshComponentRefreshingBlock)refreshingBlock; 15 | /** 创建footer */ 16 | + (instancetype)footerWithRefreshingTarget:(id)target refreshingAction:(SEL)action; 17 | 18 | /** 提示没有更多的数据 */ 19 | - (void)endRefreshingWithNoMoreData; 20 | - (void)noticeNoMoreData MJRefreshDeprecated("使用endRefreshingWithNoMoreData"); 21 | 22 | /** 重置没有更多的数据(消除没有更多数据的状态) */ 23 | - (void)resetNoMoreData; 24 | 25 | /** 忽略多少scrollView的contentInset的bottom */ 26 | @property (assign, nonatomic) CGFloat ignoredScrollViewContentInsetBottom; 27 | 28 | /** 自动根据有无数据来显示和隐藏(有数据就显示,没有数据隐藏。默认是NO) */ 29 | @property (assign, nonatomic, getter=isAutomaticallyHidden) BOOL automaticallyHidden; 30 | @end 31 | -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/Libs/MJRefresh/Base/MJRefreshFooter.m: -------------------------------------------------------------------------------- 1 | // 代码地址: https://github.com/CoderMJLee/MJRefresh 2 | // 代码地址: http://code4app.com/ios/%E5%BF%AB%E9%80%9F%E9%9B%86%E6%88%90%E4%B8%8B%E6%8B%89%E4%B8%8A%E6%8B%89%E5%88%B7%E6%96%B0/52326ce26803fabc46000000 3 | // MJRefreshFooter.m 4 | // MJRefreshExample 5 | // 6 | // Created by MJ Lee on 15/3/5. 7 | // Copyright (c) 2015年 小码哥. All rights reserved. 8 | // 9 | 10 | #import "MJRefreshFooter.h" 11 | 12 | @interface MJRefreshFooter() 13 | 14 | @end 15 | 16 | @implementation MJRefreshFooter 17 | #pragma mark - 构造方法 18 | + (instancetype)footerWithRefreshingBlock:(MJRefreshComponentRefreshingBlock)refreshingBlock 19 | { 20 | MJRefreshFooter *cmp = [[self alloc] init]; 21 | cmp.refreshingBlock = refreshingBlock; 22 | return cmp; 23 | } 24 | + (instancetype)footerWithRefreshingTarget:(id)target refreshingAction:(SEL)action 25 | { 26 | MJRefreshFooter *cmp = [[self alloc] init]; 27 | [cmp setRefreshingTarget:target refreshingAction:action]; 28 | return cmp; 29 | } 30 | 31 | #pragma mark - 重写父类的方法 32 | - (void)prepare 33 | { 34 | [super prepare]; 35 | 36 | // 设置自己的高度 37 | self.mj_h = MJRefreshFooterHeight; 38 | 39 | // 默认不会自动隐藏 40 | self.automaticallyHidden = NO; 41 | } 42 | 43 | - (void)willMoveToSuperview:(UIView *)newSuperview 44 | { 45 | [super willMoveToSuperview:newSuperview]; 46 | 47 | if (newSuperview) { 48 | // 监听scrollView数据的变化 49 | if ([self.scrollView isKindOfClass:[UITableView class]] || [self.scrollView isKindOfClass:[UICollectionView class]]) { 50 | [self.scrollView setMj_reloadDataBlock:^(NSInteger totalDataCount) { 51 | if (self.isAutomaticallyHidden) { 52 | self.hidden = (totalDataCount == 0); 53 | } 54 | }]; 55 | } 56 | } 57 | } 58 | 59 | #pragma mark - 公共方法 60 | - (void)endRefreshingWithNoMoreData 61 | { 62 | self.state = MJRefreshStateNoMoreData; 63 | } 64 | 65 | - (void)noticeNoMoreData 66 | { 67 | [self endRefreshingWithNoMoreData]; 68 | } 69 | 70 | - (void)resetNoMoreData 71 | { 72 | self.state = MJRefreshStateIdle; 73 | } 74 | @end 75 | -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/Libs/MJRefresh/Base/MJRefreshHeader.h: -------------------------------------------------------------------------------- 1 | // 代码地址: https://github.com/CoderMJLee/MJRefresh 2 | // 代码地址: http://code4app.com/ios/%E5%BF%AB%E9%80%9F%E9%9B%86%E6%88%90%E4%B8%8B%E6%8B%89%E4%B8%8A%E6%8B%89%E5%88%B7%E6%96%B0/52326ce26803fabc46000000 3 | // MJRefreshHeader.h 4 | // MJRefreshExample 5 | // 6 | // Created by MJ Lee on 15/3/4. 7 | // Copyright (c) 2015年 小码哥. All rights reserved. 8 | // 下拉刷新控件:负责监控用户下拉的状态 9 | 10 | #import "MJRefreshComponent.h" 11 | 12 | @interface MJRefreshHeader : MJRefreshComponent 13 | /** 创建header */ 14 | + (instancetype)headerWithRefreshingBlock:(MJRefreshComponentRefreshingBlock)refreshingBlock; 15 | /** 创建header */ 16 | + (instancetype)headerWithRefreshingTarget:(id)target refreshingAction:(SEL)action; 17 | 18 | /** 这个key用来存储上一次下拉刷新成功的时间 */ 19 | @property (copy, nonatomic) NSString *lastUpdatedTimeKey; 20 | /** 上一次下拉刷新成功的时间 */ 21 | @property (strong, nonatomic, readonly) NSDate *lastUpdatedTime; 22 | 23 | /** 忽略多少scrollView的contentInset的top */ 24 | @property (assign, nonatomic) CGFloat ignoredScrollViewContentInsetTop; 25 | @end 26 | -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/Libs/MJRefresh/Custom/Footer/Auto/MJRefreshAutoGifFooter.h: -------------------------------------------------------------------------------- 1 | // 2 | // MJRefreshAutoGifFooter.h 3 | // MJRefreshExample 4 | // 5 | // Created by MJ Lee on 15/4/24. 6 | // Copyright (c) 2015年 小码哥. All rights reserved. 7 | // 8 | 9 | #import "MJRefreshAutoStateFooter.h" 10 | 11 | @interface MJRefreshAutoGifFooter : MJRefreshAutoStateFooter 12 | @property (weak, nonatomic, readonly) UIImageView *gifView; 13 | 14 | /** 设置state状态下的动画图片images 动画持续时间duration*/ 15 | - (void)setImages:(NSArray *)images duration:(NSTimeInterval)duration forState:(MJRefreshState)state; 16 | - (void)setImages:(NSArray *)images forState:(MJRefreshState)state; 17 | @end 18 | -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/Libs/MJRefresh/Custom/Footer/Auto/MJRefreshAutoGifFooter.m: -------------------------------------------------------------------------------- 1 | // 2 | // MJRefreshAutoGifFooter.m 3 | // MJRefreshExample 4 | // 5 | // Created by MJ Lee on 15/4/24. 6 | // Copyright (c) 2015年 小码哥. All rights reserved. 7 | // 8 | 9 | #import "MJRefreshAutoGifFooter.h" 10 | 11 | @interface MJRefreshAutoGifFooter() 12 | { 13 | __unsafe_unretained UIImageView *_gifView; 14 | } 15 | /** 所有状态对应的动画图片 */ 16 | @property (strong, nonatomic) NSMutableDictionary *stateImages; 17 | /** 所有状态对应的动画时间 */ 18 | @property (strong, nonatomic) NSMutableDictionary *stateDurations; 19 | @end 20 | 21 | @implementation MJRefreshAutoGifFooter 22 | #pragma mark - 懒加载 23 | - (UIImageView *)gifView 24 | { 25 | if (!_gifView) { 26 | UIImageView *gifView = [[UIImageView alloc] init]; 27 | [self addSubview:_gifView = gifView]; 28 | } 29 | return _gifView; 30 | } 31 | 32 | - (NSMutableDictionary *)stateImages 33 | { 34 | if (!_stateImages) { 35 | self.stateImages = [NSMutableDictionary dictionary]; 36 | } 37 | return _stateImages; 38 | } 39 | 40 | - (NSMutableDictionary *)stateDurations 41 | { 42 | if (!_stateDurations) { 43 | self.stateDurations = [NSMutableDictionary dictionary]; 44 | } 45 | return _stateDurations; 46 | } 47 | 48 | #pragma mark - 公共方法 49 | - (void)setImages:(NSArray *)images duration:(NSTimeInterval)duration forState:(MJRefreshState)state 50 | { 51 | if (images == nil) return; 52 | 53 | self.stateImages[@(state)] = images; 54 | self.stateDurations[@(state)] = @(duration); 55 | 56 | /* 根据图片设置控件的高度 */ 57 | UIImage *image = [images firstObject]; 58 | if (image.size.height > self.mj_h) { 59 | self.mj_h = image.size.height; 60 | } 61 | } 62 | 63 | - (void)setImages:(NSArray *)images forState:(MJRefreshState)state 64 | { 65 | [self setImages:images duration:images.count * 0.1 forState:state]; 66 | } 67 | 68 | #pragma mark - 实现父类的方法 69 | - (void)prepare 70 | { 71 | [super prepare]; 72 | 73 | // 初始化间距 74 | self.labelLeftInset = 20; 75 | } 76 | 77 | - (void)placeSubviews 78 | { 79 | [super placeSubviews]; 80 | 81 | if (self.gifView.constraints.count) return; 82 | 83 | self.gifView.frame = self.bounds; 84 | if (self.isRefreshingTitleHidden) { 85 | self.gifView.contentMode = UIViewContentModeCenter; 86 | } else { 87 | self.gifView.contentMode = UIViewContentModeRight; 88 | self.gifView.mj_w = self.mj_w * 0.5 - self.labelLeftInset - self.stateLabel.mj_textWith * 0.5; 89 | } 90 | } 91 | 92 | - (void)setState:(MJRefreshState)state 93 | { 94 | MJRefreshCheckState 95 | 96 | // 根据状态做事情 97 | if (state == MJRefreshStateRefreshing) { 98 | NSArray *images = self.stateImages[@(state)]; 99 | if (images.count == 0) return; 100 | [self.gifView stopAnimating]; 101 | 102 | self.gifView.hidden = NO; 103 | if (images.count == 1) { // 单张图片 104 | self.gifView.image = [images lastObject]; 105 | } else { // 多张图片 106 | self.gifView.animationImages = images; 107 | self.gifView.animationDuration = [self.stateDurations[@(state)] doubleValue]; 108 | [self.gifView startAnimating]; 109 | } 110 | } else if (state == MJRefreshStateNoMoreData || state == MJRefreshStateIdle) { 111 | [self.gifView stopAnimating]; 112 | self.gifView.hidden = YES; 113 | } 114 | } 115 | @end 116 | 117 | -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/Libs/MJRefresh/Custom/Footer/Auto/MJRefreshAutoNormalFooter.h: -------------------------------------------------------------------------------- 1 | // 2 | // MJRefreshAutoNormalFooter.h 3 | // MJRefreshExample 4 | // 5 | // Created by MJ Lee on 15/4/24. 6 | // Copyright (c) 2015年 小码哥. All rights reserved. 7 | // 8 | 9 | #import "MJRefreshAutoStateFooter.h" 10 | 11 | @interface MJRefreshAutoNormalFooter : MJRefreshAutoStateFooter 12 | /** 菊花的样式 */ 13 | @property (assign, nonatomic) UIActivityIndicatorViewStyle activityIndicatorViewStyle; 14 | @end 15 | -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/Libs/MJRefresh/Custom/Footer/Auto/MJRefreshAutoNormalFooter.m: -------------------------------------------------------------------------------- 1 | // 2 | // MJRefreshAutoNormalFooter.m 3 | // MJRefreshExample 4 | // 5 | // Created by MJ Lee on 15/4/24. 6 | // Copyright (c) 2015年 小码哥. All rights reserved. 7 | // 8 | 9 | #import "MJRefreshAutoNormalFooter.h" 10 | 11 | @interface MJRefreshAutoNormalFooter() 12 | @property (weak, nonatomic) UIActivityIndicatorView *loadingView; 13 | @end 14 | 15 | @implementation MJRefreshAutoNormalFooter 16 | #pragma mark - 懒加载子控件 17 | - (UIActivityIndicatorView *)loadingView 18 | { 19 | if (!_loadingView) { 20 | UIActivityIndicatorView *loadingView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:self.activityIndicatorViewStyle]; 21 | loadingView.hidesWhenStopped = YES; 22 | [self addSubview:_loadingView = loadingView]; 23 | } 24 | return _loadingView; 25 | } 26 | 27 | - (void)setActivityIndicatorViewStyle:(UIActivityIndicatorViewStyle)activityIndicatorViewStyle 28 | { 29 | _activityIndicatorViewStyle = activityIndicatorViewStyle; 30 | 31 | self.loadingView = nil; 32 | [self setNeedsLayout]; 33 | } 34 | #pragma mark - 重写父类的方法 35 | - (void)prepare 36 | { 37 | [super prepare]; 38 | 39 | self.activityIndicatorViewStyle = UIActivityIndicatorViewStyleGray; 40 | } 41 | 42 | - (void)placeSubviews 43 | { 44 | [super placeSubviews]; 45 | 46 | if (self.loadingView.constraints.count) return; 47 | 48 | // 圈圈 49 | CGFloat loadingCenterX = self.mj_w * 0.5; 50 | if (!self.isRefreshingTitleHidden) { 51 | loadingCenterX -= self.stateLabel.mj_textWith * 0.5 + self.labelLeftInset; 52 | } 53 | CGFloat loadingCenterY = self.mj_h * 0.5; 54 | self.loadingView.center = CGPointMake(loadingCenterX, loadingCenterY); 55 | } 56 | 57 | - (void)setState:(MJRefreshState)state 58 | { 59 | MJRefreshCheckState 60 | 61 | // 根据状态做事情 62 | if (state == MJRefreshStateNoMoreData || state == MJRefreshStateIdle) { 63 | [self.loadingView stopAnimating]; 64 | } else if (state == MJRefreshStateRefreshing) { 65 | [self.loadingView startAnimating]; 66 | } 67 | } 68 | 69 | @end 70 | -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/Libs/MJRefresh/Custom/Footer/Auto/MJRefreshAutoStateFooter.h: -------------------------------------------------------------------------------- 1 | // 2 | // MJRefreshAutoStateFooter.h 3 | // MJRefreshExample 4 | // 5 | // Created by MJ Lee on 15/6/13. 6 | // Copyright © 2015年 小码哥. All rights reserved. 7 | // 8 | 9 | #import "MJRefreshAutoFooter.h" 10 | 11 | @interface MJRefreshAutoStateFooter : MJRefreshAutoFooter 12 | /** 文字距离圈圈、箭头的距离 */ 13 | @property (assign, nonatomic) CGFloat labelLeftInset; 14 | /** 显示刷新状态的label */ 15 | @property (weak, nonatomic, readonly) UILabel *stateLabel; 16 | 17 | /** 设置state状态下的文字 */ 18 | - (void)setTitle:(NSString *)title forState:(MJRefreshState)state; 19 | 20 | /** 隐藏刷新状态的文字 */ 21 | @property (assign, nonatomic, getter=isRefreshingTitleHidden) BOOL refreshingTitleHidden; 22 | @end 23 | -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/Libs/MJRefresh/Custom/Footer/Auto/MJRefreshAutoStateFooter.m: -------------------------------------------------------------------------------- 1 | // 2 | // MJRefreshAutoStateFooter.m 3 | // MJRefreshExample 4 | // 5 | // Created by MJ Lee on 15/6/13. 6 | // Copyright © 2015年 小码哥. All rights reserved. 7 | // 8 | 9 | #import "MJRefreshAutoStateFooter.h" 10 | 11 | @interface MJRefreshAutoStateFooter() 12 | { 13 | /** 显示刷新状态的label */ 14 | __unsafe_unretained UILabel *_stateLabel; 15 | } 16 | /** 所有状态对应的文字 */ 17 | @property (strong, nonatomic) NSMutableDictionary *stateTitles; 18 | @end 19 | 20 | @implementation MJRefreshAutoStateFooter 21 | #pragma mark - 懒加载 22 | - (NSMutableDictionary *)stateTitles 23 | { 24 | if (!_stateTitles) { 25 | self.stateTitles = [NSMutableDictionary dictionary]; 26 | } 27 | return _stateTitles; 28 | } 29 | 30 | - (UILabel *)stateLabel 31 | { 32 | if (!_stateLabel) { 33 | [self addSubview:_stateLabel = [UILabel mj_label]]; 34 | } 35 | return _stateLabel; 36 | } 37 | 38 | #pragma mark - 公共方法 39 | - (void)setTitle:(NSString *)title forState:(MJRefreshState)state 40 | { 41 | if (title == nil) return; 42 | self.stateTitles[@(state)] = title; 43 | self.stateLabel.text = self.stateTitles[@(self.state)]; 44 | } 45 | 46 | #pragma mark - 私有方法 47 | - (void)stateLabelClick 48 | { 49 | if (self.state == MJRefreshStateIdle) { 50 | [self beginRefreshing]; 51 | } 52 | } 53 | 54 | #pragma mark - 重写父类的方法 55 | - (void)prepare 56 | { 57 | [super prepare]; 58 | 59 | // 初始化间距 60 | self.labelLeftInset = MJRefreshLabelLeftInset; 61 | 62 | // 初始化文字 63 | [self setTitle:[NSBundle mj_localizedStringForKey:MJRefreshAutoFooterIdleText] forState:MJRefreshStateIdle]; 64 | [self setTitle:[NSBundle mj_localizedStringForKey:MJRefreshAutoFooterRefreshingText] forState:MJRefreshStateRefreshing]; 65 | [self setTitle:[NSBundle mj_localizedStringForKey:MJRefreshAutoFooterNoMoreDataText] forState:MJRefreshStateNoMoreData]; 66 | 67 | // 监听label 68 | self.stateLabel.userInteractionEnabled = YES; 69 | [self.stateLabel addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(stateLabelClick)]]; 70 | } 71 | 72 | - (void)placeSubviews 73 | { 74 | [super placeSubviews]; 75 | 76 | if (self.stateLabel.constraints.count) return; 77 | 78 | // 状态标签 79 | self.stateLabel.frame = self.bounds; 80 | } 81 | 82 | - (void)setState:(MJRefreshState)state 83 | { 84 | MJRefreshCheckState 85 | 86 | if (self.isRefreshingTitleHidden && state == MJRefreshStateRefreshing) { 87 | self.stateLabel.text = nil; 88 | } else { 89 | self.stateLabel.text = self.stateTitles[@(state)]; 90 | } 91 | } 92 | @end -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/Libs/MJRefresh/Custom/Footer/Back/MJRefreshBackGifFooter.h: -------------------------------------------------------------------------------- 1 | // 2 | // MJRefreshBackGifFooter.h 3 | // MJRefreshExample 4 | // 5 | // Created by MJ Lee on 15/4/24. 6 | // Copyright (c) 2015年 小码哥. All rights reserved. 7 | // 8 | 9 | #import "MJRefreshBackStateFooter.h" 10 | 11 | @interface MJRefreshBackGifFooter : MJRefreshBackStateFooter 12 | @property (weak, nonatomic, readonly) UIImageView *gifView; 13 | 14 | /** 设置state状态下的动画图片images 动画持续时间duration*/ 15 | - (void)setImages:(NSArray *)images duration:(NSTimeInterval)duration forState:(MJRefreshState)state; 16 | - (void)setImages:(NSArray *)images forState:(MJRefreshState)state; 17 | @end 18 | -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/Libs/MJRefresh/Custom/Footer/Back/MJRefreshBackGifFooter.m: -------------------------------------------------------------------------------- 1 | // 2 | // MJRefreshBackGifFooter.m 3 | // MJRefreshExample 4 | // 5 | // Created by MJ Lee on 15/4/24. 6 | // Copyright (c) 2015年 小码哥. All rights reserved. 7 | // 8 | 9 | #import "MJRefreshBackGifFooter.h" 10 | 11 | @interface MJRefreshBackGifFooter() 12 | { 13 | __unsafe_unretained UIImageView *_gifView; 14 | } 15 | /** 所有状态对应的动画图片 */ 16 | @property (strong, nonatomic) NSMutableDictionary *stateImages; 17 | /** 所有状态对应的动画时间 */ 18 | @property (strong, nonatomic) NSMutableDictionary *stateDurations; 19 | @end 20 | 21 | @implementation MJRefreshBackGifFooter 22 | #pragma mark - 懒加载 23 | - (UIImageView *)gifView 24 | { 25 | if (!_gifView) { 26 | UIImageView *gifView = [[UIImageView alloc] init]; 27 | [self addSubview:_gifView = gifView]; 28 | } 29 | return _gifView; 30 | } 31 | 32 | - (NSMutableDictionary *)stateImages 33 | { 34 | if (!_stateImages) { 35 | self.stateImages = [NSMutableDictionary dictionary]; 36 | } 37 | return _stateImages; 38 | } 39 | 40 | - (NSMutableDictionary *)stateDurations 41 | { 42 | if (!_stateDurations) { 43 | self.stateDurations = [NSMutableDictionary dictionary]; 44 | } 45 | return _stateDurations; 46 | } 47 | 48 | #pragma mark - 公共方法 49 | - (void)setImages:(NSArray *)images duration:(NSTimeInterval)duration forState:(MJRefreshState)state 50 | { 51 | if (images == nil) return; 52 | 53 | self.stateImages[@(state)] = images; 54 | self.stateDurations[@(state)] = @(duration); 55 | 56 | /* 根据图片设置控件的高度 */ 57 | UIImage *image = [images firstObject]; 58 | if (image.size.height > self.mj_h) { 59 | self.mj_h = image.size.height; 60 | } 61 | } 62 | 63 | - (void)setImages:(NSArray *)images forState:(MJRefreshState)state 64 | { 65 | [self setImages:images duration:images.count * 0.1 forState:state]; 66 | } 67 | 68 | #pragma mark - 实现父类的方法 69 | - (void)prepare 70 | { 71 | [super prepare]; 72 | 73 | // 初始化间距 74 | self.labelLeftInset = 20; 75 | } 76 | 77 | - (void)setPullingPercent:(CGFloat)pullingPercent 78 | { 79 | [super setPullingPercent:pullingPercent]; 80 | NSArray *images = self.stateImages[@(MJRefreshStateIdle)]; 81 | if (self.state != MJRefreshStateIdle || images.count == 0) return; 82 | [self.gifView stopAnimating]; 83 | NSUInteger index = images.count * pullingPercent; 84 | if (index >= images.count) index = images.count - 1; 85 | self.gifView.image = images[index]; 86 | } 87 | 88 | - (void)placeSubviews 89 | { 90 | [super placeSubviews]; 91 | 92 | if (self.gifView.constraints.count) return; 93 | 94 | self.gifView.frame = self.bounds; 95 | if (self.stateLabel.hidden) { 96 | self.gifView.contentMode = UIViewContentModeCenter; 97 | } else { 98 | self.gifView.contentMode = UIViewContentModeRight; 99 | self.gifView.mj_w = self.mj_w * 0.5 - self.labelLeftInset - self.stateLabel.mj_textWith * 0.5; 100 | } 101 | } 102 | 103 | - (void)setState:(MJRefreshState)state 104 | { 105 | MJRefreshCheckState 106 | 107 | // 根据状态做事情 108 | if (state == MJRefreshStatePulling || state == MJRefreshStateRefreshing) { 109 | NSArray *images = self.stateImages[@(state)]; 110 | if (images.count == 0) return; 111 | 112 | self.gifView.hidden = NO; 113 | [self.gifView stopAnimating]; 114 | if (images.count == 1) { // 单张图片 115 | self.gifView.image = [images lastObject]; 116 | } else { // 多张图片 117 | self.gifView.animationImages = images; 118 | self.gifView.animationDuration = [self.stateDurations[@(state)] doubleValue]; 119 | [self.gifView startAnimating]; 120 | } 121 | } else if (state == MJRefreshStateIdle) { 122 | self.gifView.hidden = NO; 123 | } else if (state == MJRefreshStateNoMoreData) { 124 | self.gifView.hidden = YES; 125 | } 126 | } 127 | @end 128 | -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/Libs/MJRefresh/Custom/Footer/Back/MJRefreshBackNormalFooter.h: -------------------------------------------------------------------------------- 1 | // 2 | // MJRefreshBackNormalFooter.h 3 | // MJRefreshExample 4 | // 5 | // Created by MJ Lee on 15/4/24. 6 | // Copyright (c) 2015年 小码哥. All rights reserved. 7 | // 8 | 9 | #import "MJRefreshBackStateFooter.h" 10 | 11 | @interface MJRefreshBackNormalFooter : MJRefreshBackStateFooter 12 | @property (weak, nonatomic, readonly) UIImageView *arrowView; 13 | /** 菊花的样式 */ 14 | @property (assign, nonatomic) UIActivityIndicatorViewStyle activityIndicatorViewStyle; 15 | @end 16 | -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/Libs/MJRefresh/Custom/Footer/Back/MJRefreshBackNormalFooter.m: -------------------------------------------------------------------------------- 1 | // 2 | // MJRefreshBackNormalFooter.m 3 | // MJRefreshExample 4 | // 5 | // Created by MJ Lee on 15/4/24. 6 | // Copyright (c) 2015年 小码哥. All rights reserved. 7 | // 8 | 9 | #import "MJRefreshBackNormalFooter.h" 10 | #import "NSBundle+MJRefresh.h" 11 | 12 | @interface MJRefreshBackNormalFooter() 13 | { 14 | __unsafe_unretained UIImageView *_arrowView; 15 | } 16 | @property (weak, nonatomic) UIActivityIndicatorView *loadingView; 17 | @end 18 | 19 | @implementation MJRefreshBackNormalFooter 20 | #pragma mark - 懒加载子控件 21 | - (UIImageView *)arrowView 22 | { 23 | if (!_arrowView) { 24 | UIImageView *arrowView = [[UIImageView alloc] initWithImage:[NSBundle mj_arrowImage]]; 25 | [self addSubview:_arrowView = arrowView]; 26 | } 27 | return _arrowView; 28 | } 29 | 30 | 31 | - (UIActivityIndicatorView *)loadingView 32 | { 33 | if (!_loadingView) { 34 | UIActivityIndicatorView *loadingView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:self.activityIndicatorViewStyle]; 35 | loadingView.hidesWhenStopped = YES; 36 | [self addSubview:_loadingView = loadingView]; 37 | } 38 | return _loadingView; 39 | } 40 | 41 | - (void)setActivityIndicatorViewStyle:(UIActivityIndicatorViewStyle)activityIndicatorViewStyle 42 | { 43 | _activityIndicatorViewStyle = activityIndicatorViewStyle; 44 | 45 | self.loadingView = nil; 46 | [self setNeedsLayout]; 47 | } 48 | #pragma mark - 重写父类的方法 49 | - (void)prepare 50 | { 51 | [super prepare]; 52 | 53 | self.activityIndicatorViewStyle = UIActivityIndicatorViewStyleGray; 54 | } 55 | 56 | - (void)placeSubviews 57 | { 58 | [super placeSubviews]; 59 | 60 | // 箭头的中心点 61 | CGFloat arrowCenterX = self.mj_w * 0.5; 62 | if (!self.stateLabel.hidden) { 63 | arrowCenterX -= self.labelLeftInset + self.stateLabel.mj_textWith * 0.5; 64 | } 65 | CGFloat arrowCenterY = self.mj_h * 0.5; 66 | CGPoint arrowCenter = CGPointMake(arrowCenterX, arrowCenterY); 67 | 68 | // 箭头 69 | if (self.arrowView.constraints.count == 0) { 70 | self.arrowView.mj_size = self.arrowView.image.size; 71 | self.arrowView.center = arrowCenter; 72 | } 73 | 74 | // 圈圈 75 | if (self.loadingView.constraints.count == 0) { 76 | self.loadingView.center = arrowCenter; 77 | } 78 | 79 | self.arrowView.tintColor = self.stateLabel.textColor; 80 | } 81 | 82 | - (void)setState:(MJRefreshState)state 83 | { 84 | MJRefreshCheckState 85 | 86 | // 根据状态做事情 87 | if (state == MJRefreshStateIdle) { 88 | if (oldState == MJRefreshStateRefreshing) { 89 | self.arrowView.transform = CGAffineTransformMakeRotation(0.000001 - M_PI); 90 | [UIView animateWithDuration:MJRefreshSlowAnimationDuration animations:^{ 91 | self.loadingView.alpha = 0.0; 92 | } completion:^(BOOL finished) { 93 | self.loadingView.alpha = 1.0; 94 | [self.loadingView stopAnimating]; 95 | 96 | self.arrowView.hidden = NO; 97 | }]; 98 | } else { 99 | self.arrowView.hidden = NO; 100 | [self.loadingView stopAnimating]; 101 | [UIView animateWithDuration:MJRefreshFastAnimationDuration animations:^{ 102 | self.arrowView.transform = CGAffineTransformMakeRotation(0.000001 - M_PI); 103 | }]; 104 | } 105 | } else if (state == MJRefreshStatePulling) { 106 | self.arrowView.hidden = NO; 107 | [self.loadingView stopAnimating]; 108 | [UIView animateWithDuration:MJRefreshFastAnimationDuration animations:^{ 109 | self.arrowView.transform = CGAffineTransformIdentity; 110 | }]; 111 | } else if (state == MJRefreshStateRefreshing) { 112 | self.arrowView.hidden = YES; 113 | [self.loadingView startAnimating]; 114 | } else if (state == MJRefreshStateNoMoreData) { 115 | self.arrowView.hidden = YES; 116 | [self.loadingView stopAnimating]; 117 | } 118 | } 119 | 120 | @end 121 | -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/Libs/MJRefresh/Custom/Footer/Back/MJRefreshBackStateFooter.h: -------------------------------------------------------------------------------- 1 | // 2 | // MJRefreshBackStateFooter.h 3 | // MJRefreshExample 4 | // 5 | // Created by MJ Lee on 15/6/13. 6 | // Copyright © 2015年 小码哥. All rights reserved. 7 | // 8 | 9 | #import "MJRefreshBackFooter.h" 10 | 11 | @interface MJRefreshBackStateFooter : MJRefreshBackFooter 12 | /** 文字距离圈圈、箭头的距离 */ 13 | @property (assign, nonatomic) CGFloat labelLeftInset; 14 | /** 显示刷新状态的label */ 15 | @property (weak, nonatomic, readonly) UILabel *stateLabel; 16 | /** 设置state状态下的文字 */ 17 | - (void)setTitle:(NSString *)title forState:(MJRefreshState)state; 18 | 19 | /** 获取state状态下的title */ 20 | - (NSString *)titleForState:(MJRefreshState)state; 21 | @end 22 | -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/Libs/MJRefresh/Custom/Footer/Back/MJRefreshBackStateFooter.m: -------------------------------------------------------------------------------- 1 | // 2 | // MJRefreshBackStateFooter.m 3 | // MJRefreshExample 4 | // 5 | // Created by MJ Lee on 15/6/13. 6 | // Copyright © 2015年 小码哥. All rights reserved. 7 | // 8 | 9 | #import "MJRefreshBackStateFooter.h" 10 | 11 | @interface MJRefreshBackStateFooter() 12 | { 13 | /** 显示刷新状态的label */ 14 | __unsafe_unretained UILabel *_stateLabel; 15 | } 16 | /** 所有状态对应的文字 */ 17 | @property (strong, nonatomic) NSMutableDictionary *stateTitles; 18 | @end 19 | 20 | @implementation MJRefreshBackStateFooter 21 | #pragma mark - 懒加载 22 | - (NSMutableDictionary *)stateTitles 23 | { 24 | if (!_stateTitles) { 25 | self.stateTitles = [NSMutableDictionary dictionary]; 26 | } 27 | return _stateTitles; 28 | } 29 | 30 | - (UILabel *)stateLabel 31 | { 32 | if (!_stateLabel) { 33 | [self addSubview:_stateLabel = [UILabel mj_label]]; 34 | } 35 | return _stateLabel; 36 | } 37 | 38 | #pragma mark - 公共方法 39 | - (void)setTitle:(NSString *)title forState:(MJRefreshState)state 40 | { 41 | if (title == nil) return; 42 | self.stateTitles[@(state)] = title; 43 | self.stateLabel.text = self.stateTitles[@(self.state)]; 44 | } 45 | 46 | - (NSString *)titleForState:(MJRefreshState)state { 47 | return self.stateTitles[@(state)]; 48 | } 49 | 50 | #pragma mark - 重写父类的方法 51 | - (void)prepare 52 | { 53 | [super prepare]; 54 | 55 | // 初始化间距 56 | self.labelLeftInset = MJRefreshLabelLeftInset; 57 | 58 | // 初始化文字 59 | [self setTitle:[NSBundle mj_localizedStringForKey:MJRefreshBackFooterIdleText] forState:MJRefreshStateIdle]; 60 | [self setTitle:[NSBundle mj_localizedStringForKey:MJRefreshBackFooterPullingText] forState:MJRefreshStatePulling]; 61 | [self setTitle:[NSBundle mj_localizedStringForKey:MJRefreshBackFooterRefreshingText] forState:MJRefreshStateRefreshing]; 62 | [self setTitle:[NSBundle mj_localizedStringForKey:MJRefreshBackFooterNoMoreDataText] forState:MJRefreshStateNoMoreData]; 63 | } 64 | 65 | - (void)placeSubviews 66 | { 67 | [super placeSubviews]; 68 | 69 | if (self.stateLabel.constraints.count) return; 70 | 71 | // 状态标签 72 | self.stateLabel.frame = self.bounds; 73 | } 74 | 75 | - (void)setState:(MJRefreshState)state 76 | { 77 | MJRefreshCheckState 78 | 79 | // 设置状态文字 80 | self.stateLabel.text = self.stateTitles[@(state)]; 81 | } 82 | @end 83 | -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/Libs/MJRefresh/Custom/Header/MJRefreshGifHeader.h: -------------------------------------------------------------------------------- 1 | // 2 | // MJRefreshGifHeader.h 3 | // MJRefreshExample 4 | // 5 | // Created by MJ Lee on 15/4/24. 6 | // Copyright (c) 2015年 小码哥. All rights reserved. 7 | // 8 | 9 | #import "MJRefreshStateHeader.h" 10 | 11 | @interface MJRefreshGifHeader : MJRefreshStateHeader 12 | @property (weak, nonatomic, readonly) UIImageView *gifView; 13 | 14 | /** 设置state状态下的动画图片images 动画持续时间duration*/ 15 | - (void)setImages:(NSArray *)images duration:(NSTimeInterval)duration forState:(MJRefreshState)state; 16 | - (void)setImages:(NSArray *)images forState:(MJRefreshState)state; 17 | @end 18 | -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/Libs/MJRefresh/Custom/Header/MJRefreshGifHeader.m: -------------------------------------------------------------------------------- 1 | // 2 | // MJRefreshGifHeader.m 3 | // MJRefreshExample 4 | // 5 | // Created by MJ Lee on 15/4/24. 6 | // Copyright (c) 2015年 小码哥. All rights reserved. 7 | // 8 | 9 | #import "MJRefreshGifHeader.h" 10 | 11 | @interface MJRefreshGifHeader() 12 | { 13 | __unsafe_unretained UIImageView *_gifView; 14 | } 15 | /** 所有状态对应的动画图片 */ 16 | @property (strong, nonatomic) NSMutableDictionary *stateImages; 17 | /** 所有状态对应的动画时间 */ 18 | @property (strong, nonatomic) NSMutableDictionary *stateDurations; 19 | @end 20 | 21 | @implementation MJRefreshGifHeader 22 | #pragma mark - 懒加载 23 | - (UIImageView *)gifView 24 | { 25 | if (!_gifView) { 26 | UIImageView *gifView = [[UIImageView alloc] init]; 27 | [self addSubview:_gifView = gifView]; 28 | } 29 | return _gifView; 30 | } 31 | 32 | - (NSMutableDictionary *)stateImages 33 | { 34 | if (!_stateImages) { 35 | self.stateImages = [NSMutableDictionary dictionary]; 36 | } 37 | return _stateImages; 38 | } 39 | 40 | - (NSMutableDictionary *)stateDurations 41 | { 42 | if (!_stateDurations) { 43 | self.stateDurations = [NSMutableDictionary dictionary]; 44 | } 45 | return _stateDurations; 46 | } 47 | 48 | #pragma mark - 公共方法 49 | - (void)setImages:(NSArray *)images duration:(NSTimeInterval)duration forState:(MJRefreshState)state 50 | { 51 | if (images == nil) return; 52 | 53 | self.stateImages[@(state)] = images; 54 | self.stateDurations[@(state)] = @(duration); 55 | 56 | /* 根据图片设置控件的高度 */ 57 | UIImage *image = [images firstObject]; 58 | if (image.size.height > self.mj_h) { 59 | self.mj_h = image.size.height; 60 | } 61 | } 62 | 63 | - (void)setImages:(NSArray *)images forState:(MJRefreshState)state 64 | { 65 | [self setImages:images duration:images.count * 0.1 forState:state]; 66 | } 67 | 68 | #pragma mark - 实现父类的方法 69 | - (void)prepare 70 | { 71 | [super prepare]; 72 | 73 | // 初始化间距 74 | self.labelLeftInset = 20; 75 | } 76 | 77 | - (void)setPullingPercent:(CGFloat)pullingPercent 78 | { 79 | [super setPullingPercent:pullingPercent]; 80 | NSArray *images = self.stateImages[@(MJRefreshStateIdle)]; 81 | if (self.state != MJRefreshStateIdle || images.count == 0) return; 82 | // 停止动画 83 | [self.gifView stopAnimating]; 84 | // 设置当前需要显示的图片 85 | NSUInteger index = images.count * pullingPercent; 86 | if (index >= images.count) index = images.count - 1; 87 | self.gifView.image = images[index]; 88 | } 89 | 90 | - (void)placeSubviews 91 | { 92 | [super placeSubviews]; 93 | 94 | if (self.gifView.constraints.count) return; 95 | 96 | self.gifView.frame = self.bounds; 97 | if (self.stateLabel.hidden && self.lastUpdatedTimeLabel.hidden) { 98 | self.gifView.contentMode = UIViewContentModeCenter; 99 | } else { 100 | self.gifView.contentMode = UIViewContentModeRight; 101 | 102 | CGFloat stateWidth = self.stateLabel.mj_textWith; 103 | CGFloat timeWidth = 0.0; 104 | if (!self.lastUpdatedTimeLabel.hidden) { 105 | timeWidth = self.lastUpdatedTimeLabel.mj_textWith; 106 | } 107 | CGFloat textWidth = MAX(stateWidth, timeWidth); 108 | self.gifView.mj_w = self.mj_w * 0.5 - textWidth * 0.5 - self.labelLeftInset; 109 | } 110 | } 111 | 112 | - (void)setState:(MJRefreshState)state 113 | { 114 | MJRefreshCheckState 115 | 116 | // 根据状态做事情 117 | if (state == MJRefreshStatePulling || state == MJRefreshStateRefreshing) { 118 | NSArray *images = self.stateImages[@(state)]; 119 | if (images.count == 0) return; 120 | 121 | [self.gifView stopAnimating]; 122 | if (images.count == 1) { // 单张图片 123 | self.gifView.image = [images lastObject]; 124 | } else { // 多张图片 125 | self.gifView.animationImages = images; 126 | self.gifView.animationDuration = [self.stateDurations[@(state)] doubleValue]; 127 | [self.gifView startAnimating]; 128 | } 129 | } else if (state == MJRefreshStateIdle) { 130 | [self.gifView stopAnimating]; 131 | } 132 | } 133 | @end 134 | -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/Libs/MJRefresh/Custom/Header/MJRefreshNormalHeader.h: -------------------------------------------------------------------------------- 1 | // 2 | // MJRefreshNormalHeader.h 3 | // MJRefreshExample 4 | // 5 | // Created by MJ Lee on 15/4/24. 6 | // Copyright (c) 2015年 小码哥. All rights reserved. 7 | // 8 | 9 | #import "MJRefreshStateHeader.h" 10 | 11 | @interface MJRefreshNormalHeader : MJRefreshStateHeader 12 | @property (weak, nonatomic, readonly) UIImageView *arrowView; 13 | /** 菊花的样式 */ 14 | @property (assign, nonatomic) UIActivityIndicatorViewStyle activityIndicatorViewStyle; 15 | @end 16 | -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/Libs/MJRefresh/Custom/Header/MJRefreshStateHeader.h: -------------------------------------------------------------------------------- 1 | // 2 | // MJRefreshStateHeader.h 3 | // MJRefreshExample 4 | // 5 | // Created by MJ Lee on 15/4/24. 6 | // Copyright (c) 2015年 小码哥. All rights reserved. 7 | // 8 | 9 | #import "MJRefreshHeader.h" 10 | 11 | @interface MJRefreshStateHeader : MJRefreshHeader 12 | #pragma mark - 刷新时间相关 13 | /** 利用这个block来决定显示的更新时间文字 */ 14 | @property (copy, nonatomic) NSString *(^lastUpdatedTimeText)(NSDate *lastUpdatedTime); 15 | /** 显示上一次刷新时间的label */ 16 | @property (weak, nonatomic, readonly) UILabel *lastUpdatedTimeLabel; 17 | 18 | #pragma mark - 状态相关 19 | /** 文字距离圈圈、箭头的距离 */ 20 | @property (assign, nonatomic) CGFloat labelLeftInset; 21 | /** 显示刷新状态的label */ 22 | @property (weak, nonatomic, readonly) UILabel *stateLabel; 23 | /** 设置state状态下的文字 */ 24 | - (void)setTitle:(NSString *)title forState:(MJRefreshState)state; 25 | @end 26 | -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/Libs/MJRefresh/MJRefresh.bundle/arrow@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coolryze/Player/8f0b6dd1bfd9521618d76786bced9154fdce81db/YZPlayerDemo/YZPlayerDemo/Libs/MJRefresh/MJRefresh.bundle/arrow@2x.png -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/Libs/MJRefresh/MJRefresh.bundle/en.lproj/Localizable.strings: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coolryze/Player/8f0b6dd1bfd9521618d76786bced9154fdce81db/YZPlayerDemo/YZPlayerDemo/Libs/MJRefresh/MJRefresh.bundle/en.lproj/Localizable.strings -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/Libs/MJRefresh/MJRefresh.bundle/zh-Hans.lproj/Localizable.strings: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coolryze/Player/8f0b6dd1bfd9521618d76786bced9154fdce81db/YZPlayerDemo/YZPlayerDemo/Libs/MJRefresh/MJRefresh.bundle/zh-Hans.lproj/Localizable.strings -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/Libs/MJRefresh/MJRefresh.bundle/zh-Hant.lproj/Localizable.strings: -------------------------------------------------------------------------------- 1 | "MJRefreshHeaderIdleText" = "下拉可以刷新"; 2 | "MJRefreshHeaderPullingText" = "鬆開立即刷新"; 3 | "MJRefreshHeaderRefreshingText" = "正在刷新數據中..."; 4 | 5 | "MJRefreshAutoFooterIdleText" = "點擊或上拉加載更多"; 6 | "MJRefreshAutoFooterRefreshingText" = "正在加載更多的數據..."; 7 | "MJRefreshAutoFooterNoMoreDataText" = "已經全部加載完畢"; 8 | 9 | "MJRefreshBackFooterIdleText" = "上拉可以加載更多"; 10 | "MJRefreshBackFooterPullingText" = "鬆開立即加載更多"; 11 | "MJRefreshBackFooterRefreshingText" = "正在加載更多的數據..."; 12 | "MJRefreshBackFooterNoMoreDataText" = "已經全部加載完畢"; 13 | 14 | "MJRefreshHeaderLastTimeText" = "最後更新:"; 15 | "MJRefreshHeaderDateTodayText" = "今天"; 16 | "MJRefreshHeaderNoneLastDateText" = "無記錄"; 17 | -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/Libs/MJRefresh/MJRefresh.h: -------------------------------------------------------------------------------- 1 | // 代码地址: https://github.com/CoderMJLee/MJRefresh 2 | // 代码地址: http://code4app.com/ios/%E5%BF%AB%E9%80%9F%E9%9B%86%E6%88%90%E4%B8%8B%E6%8B%89%E4%B8%8A%E6%8B%89%E5%88%B7%E6%96%B0/52326ce26803fabc46000000 3 | 4 | #import "UIScrollView+MJRefresh.h" 5 | #import "UIScrollView+MJExtension.h" 6 | #import "UIView+MJExtension.h" 7 | 8 | #import "MJRefreshNormalHeader.h" 9 | #import "MJRefreshGifHeader.h" 10 | 11 | #import "MJRefreshBackNormalFooter.h" 12 | #import "MJRefreshBackGifFooter.h" 13 | #import "MJRefreshAutoNormalFooter.h" 14 | #import "MJRefreshAutoGifFooter.h" -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/Libs/MJRefresh/MJRefreshConst.h: -------------------------------------------------------------------------------- 1 | // 代码地址: https://github.com/CoderMJLee/MJRefresh 2 | // 代码地址: http://code4app.com/ios/%E5%BF%AB%E9%80%9F%E9%9B%86%E6%88%90%E4%B8%8B%E6%8B%89%E4%B8%8A%E6%8B%89%E5%88%B7%E6%96%B0/52326ce26803fabc46000000 3 | #import 4 | #import 5 | 6 | // 弱引用 7 | #define MJWeakSelf __weak typeof(self) weakSelf = self; 8 | 9 | // 日志输出 10 | #ifdef DEBUG 11 | #define MJRefreshLog(...) NSLog(__VA_ARGS__) 12 | #else 13 | #define MJRefreshLog(...) 14 | #endif 15 | 16 | // 过期提醒 17 | #define MJRefreshDeprecated(instead) NS_DEPRECATED(2_0, 2_0, 2_0, 2_0, instead) 18 | 19 | // 运行时objc_msgSend 20 | #define MJRefreshMsgSend(...) ((void (*)(void *, SEL, UIView *))objc_msgSend)(__VA_ARGS__) 21 | #define MJRefreshMsgTarget(target) (__bridge void *)(target) 22 | 23 | // RGB颜色 24 | #define MJRefreshColor(r, g, b) [UIColor colorWithRed:(r)/255.0 green:(g)/255.0 blue:(b)/255.0 alpha:1.0] 25 | 26 | // 文字颜色 27 | #define MJRefreshLabelTextColor MJRefreshColor(90, 90, 90) 28 | 29 | // 字体大小 30 | #define MJRefreshLabelFont [UIFont boldSystemFontOfSize:14] 31 | 32 | // 常量 33 | UIKIT_EXTERN const CGFloat MJRefreshLabelLeftInset; 34 | UIKIT_EXTERN const CGFloat MJRefreshHeaderHeight; 35 | UIKIT_EXTERN const CGFloat MJRefreshFooterHeight; 36 | UIKIT_EXTERN const CGFloat MJRefreshFastAnimationDuration; 37 | UIKIT_EXTERN const CGFloat MJRefreshSlowAnimationDuration; 38 | 39 | UIKIT_EXTERN NSString *const MJRefreshKeyPathContentOffset; 40 | UIKIT_EXTERN NSString *const MJRefreshKeyPathContentSize; 41 | UIKIT_EXTERN NSString *const MJRefreshKeyPathContentInset; 42 | UIKIT_EXTERN NSString *const MJRefreshKeyPathPanState; 43 | 44 | UIKIT_EXTERN NSString *const MJRefreshHeaderLastUpdatedTimeKey; 45 | 46 | UIKIT_EXTERN NSString *const MJRefreshHeaderIdleText; 47 | UIKIT_EXTERN NSString *const MJRefreshHeaderPullingText; 48 | UIKIT_EXTERN NSString *const MJRefreshHeaderRefreshingText; 49 | 50 | UIKIT_EXTERN NSString *const MJRefreshAutoFooterIdleText; 51 | UIKIT_EXTERN NSString *const MJRefreshAutoFooterRefreshingText; 52 | UIKIT_EXTERN NSString *const MJRefreshAutoFooterNoMoreDataText; 53 | 54 | UIKIT_EXTERN NSString *const MJRefreshBackFooterIdleText; 55 | UIKIT_EXTERN NSString *const MJRefreshBackFooterPullingText; 56 | UIKIT_EXTERN NSString *const MJRefreshBackFooterRefreshingText; 57 | UIKIT_EXTERN NSString *const MJRefreshBackFooterNoMoreDataText; 58 | 59 | UIKIT_EXTERN NSString *const MJRefreshHeaderLastTimeText; 60 | UIKIT_EXTERN NSString *const MJRefreshHeaderDateTodayText; 61 | UIKIT_EXTERN NSString *const MJRefreshHeaderNoneLastDateText; 62 | 63 | // 状态检查 64 | #define MJRefreshCheckState \ 65 | MJRefreshState oldState = self.state; \ 66 | if (state == oldState) return; \ 67 | [super setState:state]; 68 | -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/Libs/MJRefresh/MJRefreshConst.m: -------------------------------------------------------------------------------- 1 | // 代码地址: https://github.com/CoderMJLee/MJRefresh 2 | // 代码地址: http://code4app.com/ios/%E5%BF%AB%E9%80%9F%E9%9B%86%E6%88%90%E4%B8%8B%E6%8B%89%E4%B8%8A%E6%8B%89%E5%88%B7%E6%96%B0/52326ce26803fabc46000000 3 | #import 4 | 5 | const CGFloat MJRefreshLabelLeftInset = 25; 6 | const CGFloat MJRefreshHeaderHeight = 54.0; 7 | const CGFloat MJRefreshFooterHeight = 44.0; 8 | const CGFloat MJRefreshFastAnimationDuration = 0.25; 9 | const CGFloat MJRefreshSlowAnimationDuration = 0.4; 10 | 11 | NSString *const MJRefreshKeyPathContentOffset = @"contentOffset"; 12 | NSString *const MJRefreshKeyPathContentInset = @"contentInset"; 13 | NSString *const MJRefreshKeyPathContentSize = @"contentSize"; 14 | NSString *const MJRefreshKeyPathPanState = @"state"; 15 | 16 | NSString *const MJRefreshHeaderLastUpdatedTimeKey = @"MJRefreshHeaderLastUpdatedTimeKey"; 17 | 18 | NSString *const MJRefreshHeaderIdleText = @"MJRefreshHeaderIdleText"; 19 | NSString *const MJRefreshHeaderPullingText = @"MJRefreshHeaderPullingText"; 20 | NSString *const MJRefreshHeaderRefreshingText = @"MJRefreshHeaderRefreshingText"; 21 | 22 | NSString *const MJRefreshAutoFooterIdleText = @"MJRefreshAutoFooterIdleText"; 23 | NSString *const MJRefreshAutoFooterRefreshingText = @"MJRefreshAutoFooterRefreshingText"; 24 | NSString *const MJRefreshAutoFooterNoMoreDataText = @"MJRefreshAutoFooterNoMoreDataText"; 25 | 26 | NSString *const MJRefreshBackFooterIdleText = @"MJRefreshBackFooterIdleText"; 27 | NSString *const MJRefreshBackFooterPullingText = @"MJRefreshBackFooterPullingText"; 28 | NSString *const MJRefreshBackFooterRefreshingText = @"MJRefreshBackFooterRefreshingText"; 29 | NSString *const MJRefreshBackFooterNoMoreDataText = @"MJRefreshBackFooterNoMoreDataText"; 30 | 31 | NSString *const MJRefreshHeaderLastTimeText = @"MJRefreshHeaderLastTimeText"; 32 | NSString *const MJRefreshHeaderDateTodayText = @"MJRefreshHeaderDateTodayText"; 33 | NSString *const MJRefreshHeaderNoneLastDateText = @"MJRefreshHeaderNoneLastDateText"; -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/Libs/MJRefresh/NSBundle+MJRefresh.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSBundle+MJRefresh.h 3 | // MJRefreshExample 4 | // 5 | // Created by MJ Lee on 16/6/13. 6 | // Copyright © 2016年 小码哥. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface NSBundle (MJRefresh) 12 | + (instancetype)mj_refreshBundle; 13 | + (UIImage *)mj_arrowImage; 14 | + (NSString *)mj_localizedStringForKey:(NSString *)key value:(NSString *)value; 15 | + (NSString *)mj_localizedStringForKey:(NSString *)key; 16 | @end 17 | -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/Libs/MJRefresh/NSBundle+MJRefresh.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSBundle+MJRefresh.m 3 | // MJRefreshExample 4 | // 5 | // Created by MJ Lee on 16/6/13. 6 | // Copyright © 2016年 小码哥. All rights reserved. 7 | // 8 | 9 | #import "NSBundle+MJRefresh.h" 10 | #import "MJRefreshComponent.h" 11 | 12 | @implementation NSBundle (MJRefresh) 13 | + (instancetype)mj_refreshBundle 14 | { 15 | static NSBundle *refreshBundle = nil; 16 | if (refreshBundle == nil) { 17 | // 这里不使用mainBundle是为了适配pod 1.x和0.x 18 | refreshBundle = [NSBundle bundleWithPath:[[NSBundle bundleForClass:[MJRefreshComponent class]] pathForResource:@"MJRefresh" ofType:@"bundle"]]; 19 | } 20 | return refreshBundle; 21 | } 22 | 23 | + (UIImage *)mj_arrowImage 24 | { 25 | static UIImage *arrowImage = nil; 26 | if (arrowImage == nil) { 27 | arrowImage = [[UIImage imageWithContentsOfFile:[[self mj_refreshBundle] pathForResource:@"arrow@2x" ofType:@"png"]] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]; 28 | } 29 | return arrowImage; 30 | } 31 | 32 | + (NSString *)mj_localizedStringForKey:(NSString *)key 33 | { 34 | return [self mj_localizedStringForKey:key value:nil]; 35 | } 36 | 37 | + (NSString *)mj_localizedStringForKey:(NSString *)key value:(NSString *)value 38 | { 39 | static NSBundle *bundle = nil; 40 | if (bundle == nil) { 41 | // (iOS获取的语言字符串比较不稳定)目前框架只处理en、zh-Hans、zh-Hant三种情况,其他按照系统默认处理 42 | NSString *language = [NSLocale preferredLanguages].firstObject; 43 | if ([language hasPrefix:@"en"]) { 44 | language = @"en"; 45 | } else if ([language hasPrefix:@"zh"]) { 46 | if ([language rangeOfString:@"Hans"].location != NSNotFound) { 47 | language = @"zh-Hans"; // 简体中文 48 | } else { // zh-Hant\zh-HK\zh-TW 49 | language = @"zh-Hant"; // 繁體中文 50 | } 51 | } else { 52 | language = @"en"; 53 | } 54 | 55 | // 从MJRefresh.bundle中查找资源 56 | bundle = [NSBundle bundleWithPath:[[NSBundle mj_refreshBundle] pathForResource:language ofType:@"lproj"]]; 57 | } 58 | value = [bundle localizedStringForKey:key value:value table:nil]; 59 | return [[NSBundle mainBundle] localizedStringForKey:key value:value table:nil]; 60 | } 61 | @end 62 | -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/Libs/MJRefresh/UIScrollView+MJExtension.h: -------------------------------------------------------------------------------- 1 | // 代码地址: https://github.com/CoderMJLee/MJRefresh 2 | // 代码地址: http://code4app.com/ios/%E5%BF%AB%E9%80%9F%E9%9B%86%E6%88%90%E4%B8%8B%E6%8B%89%E4%B8%8A%E6%8B%89%E5%88%B7%E6%96%B0/52326ce26803fabc46000000 3 | // UIScrollView+Extension.h 4 | // MJRefreshExample 5 | // 6 | // Created by MJ Lee on 14-5-28. 7 | // Copyright (c) 2014年 小码哥. All rights reserved. 8 | // 9 | 10 | #import 11 | 12 | @interface UIScrollView (MJExtension) 13 | @property (assign, nonatomic) CGFloat mj_insetT; 14 | @property (assign, nonatomic) CGFloat mj_insetB; 15 | @property (assign, nonatomic) CGFloat mj_insetL; 16 | @property (assign, nonatomic) CGFloat mj_insetR; 17 | 18 | @property (assign, nonatomic) CGFloat mj_offsetX; 19 | @property (assign, nonatomic) CGFloat mj_offsetY; 20 | 21 | @property (assign, nonatomic) CGFloat mj_contentW; 22 | @property (assign, nonatomic) CGFloat mj_contentH; 23 | @end 24 | -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/Libs/MJRefresh/UIScrollView+MJExtension.m: -------------------------------------------------------------------------------- 1 | // 代码地址: https://github.com/CoderMJLee/MJRefresh 2 | // 代码地址: http://code4app.com/ios/%E5%BF%AB%E9%80%9F%E9%9B%86%E6%88%90%E4%B8%8B%E6%8B%89%E4%B8%8A%E6%8B%89%E5%88%B7%E6%96%B0/52326ce26803fabc46000000 3 | // UIScrollView+Extension.m 4 | // MJRefreshExample 5 | // 6 | // Created by MJ Lee on 14-5-28. 7 | // Copyright (c) 2014年 小码哥. All rights reserved. 8 | // 9 | 10 | #import "UIScrollView+MJExtension.h" 11 | #import 12 | 13 | @implementation UIScrollView (MJExtension) 14 | 15 | - (void)setMj_insetT:(CGFloat)mj_insetT 16 | { 17 | UIEdgeInsets inset = self.contentInset; 18 | inset.top = mj_insetT; 19 | self.contentInset = inset; 20 | } 21 | 22 | - (CGFloat)mj_insetT 23 | { 24 | return self.contentInset.top; 25 | } 26 | 27 | - (void)setMj_insetB:(CGFloat)mj_insetB 28 | { 29 | UIEdgeInsets inset = self.contentInset; 30 | inset.bottom = mj_insetB; 31 | self.contentInset = inset; 32 | } 33 | 34 | - (CGFloat)mj_insetB 35 | { 36 | return self.contentInset.bottom; 37 | } 38 | 39 | - (void)setMj_insetL:(CGFloat)mj_insetL 40 | { 41 | UIEdgeInsets inset = self.contentInset; 42 | inset.left = mj_insetL; 43 | self.contentInset = inset; 44 | } 45 | 46 | - (CGFloat)mj_insetL 47 | { 48 | return self.contentInset.left; 49 | } 50 | 51 | - (void)setMj_insetR:(CGFloat)mj_insetR 52 | { 53 | UIEdgeInsets inset = self.contentInset; 54 | inset.right = mj_insetR; 55 | self.contentInset = inset; 56 | } 57 | 58 | - (CGFloat)mj_insetR 59 | { 60 | return self.contentInset.right; 61 | } 62 | 63 | - (void)setMj_offsetX:(CGFloat)mj_offsetX 64 | { 65 | CGPoint offset = self.contentOffset; 66 | offset.x = mj_offsetX; 67 | self.contentOffset = offset; 68 | } 69 | 70 | - (CGFloat)mj_offsetX 71 | { 72 | return self.contentOffset.x; 73 | } 74 | 75 | - (void)setMj_offsetY:(CGFloat)mj_offsetY 76 | { 77 | CGPoint offset = self.contentOffset; 78 | offset.y = mj_offsetY; 79 | self.contentOffset = offset; 80 | } 81 | 82 | - (CGFloat)mj_offsetY 83 | { 84 | return self.contentOffset.y; 85 | } 86 | 87 | - (void)setMj_contentW:(CGFloat)mj_contentW 88 | { 89 | CGSize size = self.contentSize; 90 | size.width = mj_contentW; 91 | self.contentSize = size; 92 | } 93 | 94 | - (CGFloat)mj_contentW 95 | { 96 | return self.contentSize.width; 97 | } 98 | 99 | - (void)setMj_contentH:(CGFloat)mj_contentH 100 | { 101 | CGSize size = self.contentSize; 102 | size.height = mj_contentH; 103 | self.contentSize = size; 104 | } 105 | 106 | - (CGFloat)mj_contentH 107 | { 108 | return self.contentSize.height; 109 | } 110 | @end 111 | -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/Libs/MJRefresh/UIScrollView+MJRefresh.h: -------------------------------------------------------------------------------- 1 | // 代码地址: https://github.com/CoderMJLee/MJRefresh 2 | // 代码地址: http://code4app.com/ios/%E5%BF%AB%E9%80%9F%E9%9B%86%E6%88%90%E4%B8%8B%E6%8B%89%E4%B8%8A%E6%8B%89%E5%88%B7%E6%96%B0/52326ce26803fabc46000000 3 | // UIScrollView+MJRefresh.h 4 | // MJRefreshExample 5 | // 6 | // Created by MJ Lee on 15/3/4. 7 | // Copyright (c) 2015年 小码哥. All rights reserved. 8 | // 给ScrollView增加下拉刷新、上拉刷新的功能 9 | 10 | #import 11 | #import "MJRefreshConst.h" 12 | 13 | @class MJRefreshHeader, MJRefreshFooter; 14 | 15 | @interface UIScrollView (MJRefresh) 16 | /** 下拉刷新控件 */ 17 | @property (strong, nonatomic) MJRefreshHeader *mj_header; 18 | @property (strong, nonatomic) MJRefreshHeader *header MJRefreshDeprecated("使用mj_header"); 19 | /** 上拉刷新控件 */ 20 | @property (strong, nonatomic) MJRefreshFooter *mj_footer; 21 | @property (strong, nonatomic) MJRefreshFooter *footer MJRefreshDeprecated("使用mj_footer"); 22 | 23 | #pragma mark - other 24 | - (NSInteger)mj_totalDataCount; 25 | @property (copy, nonatomic) void (^mj_reloadDataBlock)(NSInteger totalDataCount); 26 | @end 27 | -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/Libs/MJRefresh/UIView+MJExtension.h: -------------------------------------------------------------------------------- 1 | // 代码地址: https://github.com/CoderMJLee/MJRefresh 2 | // 代码地址: http://code4app.com/ios/%E5%BF%AB%E9%80%9F%E9%9B%86%E6%88%90%E4%B8%8B%E6%8B%89%E4%B8%8A%E6%8B%89%E5%88%B7%E6%96%B0/52326ce26803fabc46000000 3 | // UIView+Extension.h 4 | // MJRefreshExample 5 | // 6 | // Created by MJ Lee on 14-5-28. 7 | // Copyright (c) 2014年 小码哥. All rights reserved. 8 | // 9 | 10 | #import 11 | 12 | @interface UIView (MJExtension) 13 | @property (assign, nonatomic) CGFloat mj_x; 14 | @property (assign, nonatomic) CGFloat mj_y; 15 | @property (assign, nonatomic) CGFloat mj_w; 16 | @property (assign, nonatomic) CGFloat mj_h; 17 | @property (assign, nonatomic) CGSize mj_size; 18 | @property (assign, nonatomic) CGPoint mj_origin; 19 | @end 20 | -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/Libs/MJRefresh/UIView+MJExtension.m: -------------------------------------------------------------------------------- 1 | // 代码地址: https://github.com/CoderMJLee/MJRefresh 2 | // 代码地址: http://code4app.com/ios/%E5%BF%AB%E9%80%9F%E9%9B%86%E6%88%90%E4%B8%8B%E6%8B%89%E4%B8%8A%E6%8B%89%E5%88%B7%E6%96%B0/52326ce26803fabc46000000 3 | // UIView+Extension.m 4 | // MJRefreshExample 5 | // 6 | // Created by MJ Lee on 14-5-28. 7 | // Copyright (c) 2014年 小码哥. All rights reserved. 8 | // 9 | 10 | #import "UIView+MJExtension.h" 11 | 12 | @implementation UIView (MJExtension) 13 | - (void)setMj_x:(CGFloat)mj_x 14 | { 15 | CGRect frame = self.frame; 16 | frame.origin.x = mj_x; 17 | self.frame = frame; 18 | } 19 | 20 | - (CGFloat)mj_x 21 | { 22 | return self.frame.origin.x; 23 | } 24 | 25 | - (void)setMj_y:(CGFloat)mj_y 26 | { 27 | CGRect frame = self.frame; 28 | frame.origin.y = mj_y; 29 | self.frame = frame; 30 | } 31 | 32 | - (CGFloat)mj_y 33 | { 34 | return self.frame.origin.y; 35 | } 36 | 37 | - (void)setMj_w:(CGFloat)mj_w 38 | { 39 | CGRect frame = self.frame; 40 | frame.size.width = mj_w; 41 | self.frame = frame; 42 | } 43 | 44 | - (CGFloat)mj_w 45 | { 46 | return self.frame.size.width; 47 | } 48 | 49 | - (void)setMj_h:(CGFloat)mj_h 50 | { 51 | CGRect frame = self.frame; 52 | frame.size.height = mj_h; 53 | self.frame = frame; 54 | } 55 | 56 | - (CGFloat)mj_h 57 | { 58 | return self.frame.size.height; 59 | } 60 | 61 | - (void)setMj_size:(CGSize)mj_size 62 | { 63 | CGRect frame = self.frame; 64 | frame.size = mj_size; 65 | self.frame = frame; 66 | } 67 | 68 | - (CGSize)mj_size 69 | { 70 | return self.frame.size; 71 | } 72 | 73 | - (void)setMj_origin:(CGPoint)mj_origin 74 | { 75 | CGRect frame = self.frame; 76 | frame.origin = mj_origin; 77 | self.frame = frame; 78 | } 79 | 80 | - (CGPoint)mj_origin 81 | { 82 | return self.frame.origin; 83 | } 84 | @end 85 | -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/Libs/SnapKit/ConstraintConfig.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SnapKit 3 | // 4 | // Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | 24 | #if os(iOS) || os(tvOS) 25 | import UIKit 26 | public typealias ConstraintInterfaceLayoutDirection = UIUserInterfaceLayoutDirection 27 | #else 28 | import AppKit 29 | public typealias ConstraintInterfaceLayoutDirection = NSUserInterfaceLayoutDirection 30 | #endif 31 | 32 | 33 | public struct ConstraintConfig { 34 | 35 | public static var interfaceLayoutDirection: ConstraintInterfaceLayoutDirection = .leftToRight 36 | 37 | } 38 | -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/Libs/SnapKit/ConstraintDescription.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SnapKit 3 | // 4 | // Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | 24 | #if os(iOS) || os(tvOS) 25 | import UIKit 26 | #else 27 | import AppKit 28 | #endif 29 | 30 | 31 | public class ConstraintDescription { 32 | 33 | internal let item: LayoutConstraintItem 34 | internal var attributes: ConstraintAttributes 35 | internal var relation: ConstraintRelation? = nil 36 | internal var sourceLocation: (String, UInt)? = nil 37 | internal var label: String? = nil 38 | internal var related: ConstraintItem? = nil 39 | internal var multiplier: ConstraintMultiplierTarget = 1.0 40 | internal var constant: ConstraintConstantTarget = 0.0 41 | internal var priority: ConstraintPriorityTarget = 1000.0 42 | internal lazy var constraint: Constraint? = { 43 | guard let relation = self.relation, 44 | let related = self.related, 45 | let sourceLocation = self.sourceLocation else { 46 | return nil 47 | } 48 | let from = ConstraintItem(target: self.item, attributes: self.attributes) 49 | 50 | return Constraint( 51 | from: from, 52 | to: related, 53 | relation: relation, 54 | sourceLocation: sourceLocation, 55 | label: self.label, 56 | multiplier: self.multiplier, 57 | constant: self.constant, 58 | priority: self.priority 59 | ) 60 | }() 61 | 62 | // MARK: Initialization 63 | 64 | internal init(item: LayoutConstraintItem, attributes: ConstraintAttributes) { 65 | self.item = item 66 | self.attributes = attributes 67 | } 68 | 69 | } 70 | -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/Libs/SnapKit/ConstraintInsetTarget.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SnapKit 3 | // 4 | // Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | 24 | #if os(iOS) || os(tvOS) 25 | import UIKit 26 | #else 27 | import AppKit 28 | #endif 29 | 30 | 31 | public protocol ConstraintInsetTarget: ConstraintConstantTarget { 32 | } 33 | 34 | extension Int: ConstraintInsetTarget { 35 | } 36 | 37 | extension UInt: ConstraintInsetTarget { 38 | } 39 | 40 | extension Float: ConstraintInsetTarget { 41 | } 42 | 43 | extension Double: ConstraintInsetTarget { 44 | } 45 | 46 | extension CGFloat: ConstraintInsetTarget { 47 | } 48 | 49 | extension ConstraintInsets: ConstraintInsetTarget { 50 | } 51 | 52 | extension ConstraintInsetTarget { 53 | 54 | internal var constraintInsetTargetValue: ConstraintInsets { 55 | if let amount = self as? ConstraintInsets { 56 | return amount 57 | } else if let amount = self as? Float { 58 | return ConstraintInsets(top: CGFloat(amount), left: CGFloat(amount), bottom: CGFloat(amount), right: CGFloat(amount)) 59 | } else if let amount = self as? Double { 60 | return ConstraintInsets(top: CGFloat(amount), left: CGFloat(amount), bottom: CGFloat(amount), right: CGFloat(amount)) 61 | } else if let amount = self as? CGFloat { 62 | return ConstraintInsets(top: amount, left: amount, bottom: amount, right: amount) 63 | } else if let amount = self as? Int { 64 | return ConstraintInsets(top: CGFloat(amount), left: CGFloat(amount), bottom: CGFloat(amount), right: CGFloat(amount)) 65 | } else if let amount = self as? UInt { 66 | return ConstraintInsets(top: CGFloat(amount), left: CGFloat(amount), bottom: CGFloat(amount), right: CGFloat(amount)) 67 | } else { 68 | return ConstraintInsets(top: 0, left: 0, bottom: 0, right: 0) 69 | } 70 | } 71 | 72 | } 73 | -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/Libs/SnapKit/ConstraintInsets.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SnapKit 3 | // 4 | // Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | 24 | #if os(iOS) || os(tvOS) 25 | import UIKit 26 | #else 27 | import AppKit 28 | #endif 29 | 30 | 31 | #if os(iOS) || os(tvOS) 32 | public typealias ConstraintInsets = UIEdgeInsets 33 | #else 34 | public typealias ConstraintInsets = EdgeInsets 35 | #endif 36 | -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/Libs/SnapKit/ConstraintItem.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SnapKit 3 | // 4 | // Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | 24 | #if os(iOS) || os(tvOS) 25 | import UIKit 26 | #else 27 | import AppKit 28 | #endif 29 | 30 | 31 | public final class ConstraintItem { 32 | 33 | internal weak var target: AnyObject? 34 | internal let attributes: ConstraintAttributes 35 | 36 | internal init(target: AnyObject?, attributes: ConstraintAttributes) { 37 | self.target = target 38 | self.attributes = attributes 39 | } 40 | 41 | internal var layoutConstraintItem: LayoutConstraintItem? { 42 | return self.target as? LayoutConstraintItem 43 | } 44 | 45 | } 46 | 47 | public func ==(lhs: ConstraintItem, rhs: ConstraintItem) -> Bool { 48 | // pointer equality 49 | guard lhs !== rhs else { 50 | return true 51 | } 52 | 53 | // must both have valid targets and identical attributes 54 | guard let target1 = lhs.target, 55 | let target2 = rhs.target, 56 | target1 === target2 && lhs.attributes == rhs.attributes else { 57 | return false 58 | } 59 | 60 | return true 61 | } 62 | -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/Libs/SnapKit/ConstraintLayoutGuide+Extensions.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SnapKit 3 | // 4 | // Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | 24 | #if os(iOS) || os(tvOS) 25 | import UIKit 26 | #endif 27 | 28 | 29 | @available(iOS 9.0, OSX 10.11, *) 30 | public extension ConstraintLayoutGuide { 31 | 32 | public var snp: ConstraintLayoutGuideDSL { 33 | return ConstraintLayoutGuideDSL(guide: self) 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/Libs/SnapKit/ConstraintLayoutGuide.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SnapKit 3 | // 4 | // Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | 24 | #if os(iOS) || os(tvOS) 25 | import UIKit 26 | #else 27 | import AppKit 28 | #endif 29 | 30 | 31 | #if os(iOS) || os(tvOS) 32 | @available(iOS 9.0, *) 33 | public typealias ConstraintLayoutGuide = UILayoutGuide 34 | #else 35 | @available(OSX 10.11, *) 36 | public typealias ConstraintLayoutGuide = NSLayoutGuide 37 | #endif 38 | -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/Libs/SnapKit/ConstraintLayoutGuideDSL.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SnapKit 3 | // 4 | // Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | 24 | #if os(iOS) || os(tvOS) 25 | import UIKit 26 | #else 27 | import AppKit 28 | #endif 29 | 30 | 31 | @available(iOS 9.0, OSX 10.11, *) 32 | public struct ConstraintLayoutGuideDSL: ConstraintAttributesDSL { 33 | 34 | @discardableResult 35 | public func prepareConstraints(_ closure: (_ make: ConstraintMaker) -> Void) -> [Constraint] { 36 | return ConstraintMaker.prepareConstraints(item: self.guide, closure: closure) 37 | } 38 | 39 | public func makeConstraints(_ closure: (_ make: ConstraintMaker) -> Void) { 40 | ConstraintMaker.makeConstraints(item: self.guide, closure: closure) 41 | } 42 | 43 | public func remakeConstraints(_ closure: (_ make: ConstraintMaker) -> Void) { 44 | ConstraintMaker.remakeConstraints(item: self.guide, closure: closure) 45 | } 46 | 47 | public func updateConstraints(_ closure: (_ make: ConstraintMaker) -> Void) { 48 | ConstraintMaker.updateConstraints(item: self.guide, closure: closure) 49 | } 50 | 51 | public func removeConstraints() { 52 | ConstraintMaker.removeConstraints(item: self.guide) 53 | } 54 | 55 | public var target: AnyObject? { 56 | return self.guide 57 | } 58 | 59 | internal let guide: ConstraintLayoutGuide 60 | 61 | internal init(guide: ConstraintLayoutGuide) { 62 | self.guide = guide 63 | 64 | } 65 | 66 | } 67 | -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/Libs/SnapKit/ConstraintLayoutSupport.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SnapKit 3 | // 4 | // Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | 24 | #if os(iOS) || os(tvOS) 25 | import UIKit 26 | #else 27 | import AppKit 28 | #endif 29 | 30 | 31 | #if os(iOS) || os(tvOS) 32 | @available(iOS 8.0, *) 33 | public typealias ConstraintLayoutSupport = UILayoutSupport 34 | #else 35 | public class ConstraintLayoutSupport {} 36 | #endif 37 | -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/Libs/SnapKit/ConstraintLayoutSupportDSL.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SnapKit 3 | // 4 | // Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | 24 | #if os(iOS) || os(tvOS) 25 | import UIKit 26 | #else 27 | import AppKit 28 | #endif 29 | 30 | 31 | @available(iOS 8.0, *) 32 | public struct ConstraintLayoutSupportDSL: ConstraintDSL { 33 | 34 | public var target: AnyObject? { 35 | return self.support 36 | } 37 | 38 | internal let support: ConstraintLayoutSupport 39 | 40 | internal init(support: ConstraintLayoutSupport) { 41 | self.support = support 42 | 43 | } 44 | 45 | public var top: ConstraintItem { 46 | return ConstraintItem(target: self.target, attributes: ConstraintAttributes.top) 47 | } 48 | 49 | public var bottom: ConstraintItem { 50 | return ConstraintItem(target: self.target, attributes: ConstraintAttributes.bottom) 51 | } 52 | 53 | public var height: ConstraintItem { 54 | return ConstraintItem(target: self.target, attributes: ConstraintAttributes.height) 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/Libs/SnapKit/ConstraintMakerEditable.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SnapKit 3 | // 4 | // Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | 24 | #if os(iOS) || os(tvOS) 25 | import UIKit 26 | #else 27 | import AppKit 28 | #endif 29 | 30 | 31 | public class ConstraintMakerEditable: ConstraintMakerPriortizable { 32 | 33 | @discardableResult 34 | public func multipliedBy(_ amount: ConstraintMultiplierTarget) -> ConstraintMakerEditable { 35 | self.description.multiplier = amount 36 | return self 37 | } 38 | 39 | @discardableResult 40 | public func dividedBy(_ amount: ConstraintMultiplierTarget) -> ConstraintMakerEditable { 41 | return self.multipliedBy(1.0 / amount.constraintMultiplierTargetValue) 42 | } 43 | 44 | @discardableResult 45 | public func offset(_ amount: ConstraintOffsetTarget) -> ConstraintMakerEditable { 46 | self.description.constant = amount.constraintOffsetTargetValue 47 | return self 48 | } 49 | 50 | @discardableResult 51 | public func inset(_ amount: ConstraintInsetTarget) -> ConstraintMakerEditable { 52 | self.description.constant = amount.constraintInsetTargetValue 53 | return self 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/Libs/SnapKit/ConstraintMakerFinalizable.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SnapKit 3 | // 4 | // Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | 24 | #if os(iOS) || os(tvOS) 25 | import UIKit 26 | #else 27 | import AppKit 28 | #endif 29 | 30 | 31 | public class ConstraintMakerFinalizable { 32 | 33 | internal let description: ConstraintDescription 34 | 35 | internal init(_ description: ConstraintDescription) { 36 | self.description = description 37 | } 38 | 39 | @discardableResult 40 | public func labeled(_ label: String) -> ConstraintMakerFinalizable { 41 | self.description.label = label 42 | return self 43 | } 44 | 45 | public var constraint: Constraint { 46 | return self.description.constraint! 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/Libs/SnapKit/ConstraintMakerPriortizable.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SnapKit 3 | // 4 | // Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | 24 | #if os(iOS) || os(tvOS) 25 | import UIKit 26 | #else 27 | import AppKit 28 | #endif 29 | 30 | 31 | public class ConstraintMakerPriortizable: ConstraintMakerFinalizable { 32 | 33 | @discardableResult 34 | public func priority(_ amount: ConstraintPriority) -> ConstraintMakerFinalizable { 35 | self.description.priority = amount.value 36 | return self 37 | } 38 | 39 | @discardableResult 40 | public func priority(_ amount: ConstraintPriorityTarget) -> ConstraintMakerFinalizable { 41 | self.description.priority = amount 42 | return self 43 | } 44 | 45 | @available(*, deprecated:3.0, message:"Use priority(.required) instead.") 46 | @discardableResult 47 | public func priorityRequired() -> ConstraintMakerFinalizable { 48 | return self.priority(.required) 49 | } 50 | 51 | @available(*, deprecated:3.0, message:"Use priority(.high) instead.") 52 | @discardableResult 53 | public func priorityHigh() -> ConstraintMakerFinalizable { 54 | return self.priority(.high) 55 | } 56 | 57 | @available(*, deprecated:3.0, message:"Use priority(.medium) instead.") 58 | @discardableResult 59 | public func priorityMedium() -> ConstraintMakerFinalizable { 60 | return self.priority(.medium) 61 | } 62 | 63 | @available(*, deprecated:3.0, message:"Use priority(.low) instead.") 64 | @discardableResult 65 | public func priorityLow() -> ConstraintMakerFinalizable { 66 | return self.priority(.low) 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/Libs/SnapKit/ConstraintMultiplierTarget.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SnapKit 3 | // 4 | // Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | 24 | #if os(iOS) || os(tvOS) 25 | import UIKit 26 | #else 27 | import AppKit 28 | #endif 29 | 30 | 31 | public protocol ConstraintMultiplierTarget { 32 | 33 | var constraintMultiplierTargetValue: CGFloat { get } 34 | 35 | } 36 | 37 | extension Int: ConstraintMultiplierTarget { 38 | 39 | public var constraintMultiplierTargetValue: CGFloat { 40 | return CGFloat(self) 41 | } 42 | 43 | } 44 | 45 | extension UInt: ConstraintMultiplierTarget { 46 | 47 | public var constraintMultiplierTargetValue: CGFloat { 48 | return CGFloat(self) 49 | } 50 | 51 | } 52 | 53 | extension Float: ConstraintMultiplierTarget { 54 | 55 | public var constraintMultiplierTargetValue: CGFloat { 56 | return CGFloat(self) 57 | } 58 | 59 | } 60 | 61 | extension Double: ConstraintMultiplierTarget { 62 | 63 | public var constraintMultiplierTargetValue: CGFloat { 64 | return CGFloat(self) 65 | } 66 | 67 | } 68 | 69 | extension CGFloat: ConstraintMultiplierTarget { 70 | 71 | public var constraintMultiplierTargetValue: CGFloat { 72 | return self 73 | } 74 | 75 | } 76 | -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/Libs/SnapKit/ConstraintOffsetTarget.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SnapKit 3 | // 4 | // Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | 24 | #if os(iOS) || os(tvOS) 25 | import UIKit 26 | #else 27 | import AppKit 28 | #endif 29 | 30 | 31 | public protocol ConstraintOffsetTarget: ConstraintConstantTarget { 32 | } 33 | 34 | extension Int: ConstraintOffsetTarget { 35 | } 36 | 37 | extension UInt: ConstraintOffsetTarget { 38 | } 39 | 40 | extension Float: ConstraintOffsetTarget { 41 | } 42 | 43 | extension Double: ConstraintOffsetTarget { 44 | } 45 | 46 | extension CGFloat: ConstraintOffsetTarget { 47 | } 48 | 49 | extension ConstraintOffsetTarget { 50 | 51 | internal var constraintOffsetTargetValue: CGFloat { 52 | let offset: CGFloat 53 | if let amount = self as? Float { 54 | offset = CGFloat(amount) 55 | } else if let amount = self as? Double { 56 | offset = CGFloat(amount) 57 | } else if let amount = self as? CGFloat { 58 | offset = CGFloat(amount) 59 | } else if let amount = self as? Int { 60 | offset = CGFloat(amount) 61 | } else if let amount = self as? UInt { 62 | offset = CGFloat(amount) 63 | } else { 64 | offset = 0.0 65 | } 66 | return offset 67 | } 68 | 69 | } 70 | -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/Libs/SnapKit/ConstraintPriority.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SnapKit 3 | // 4 | // Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | 24 | #if os(iOS) || os(tvOS) 25 | import UIKit 26 | #else 27 | import AppKit 28 | #endif 29 | 30 | public struct ConstraintPriority : ExpressibleByFloatLiteral, Equatable, Strideable { 31 | public typealias FloatLiteralType = Float 32 | 33 | public let value: Float 34 | 35 | public init(floatLiteral value: Float) { 36 | self.value = value 37 | } 38 | 39 | public init(_ value: Float) { 40 | self.value = value 41 | } 42 | 43 | public static var required: ConstraintPriority { 44 | return 1000.0 45 | } 46 | 47 | public static var high: ConstraintPriority { 48 | return 750.0 49 | } 50 | 51 | public static var medium: ConstraintPriority { 52 | #if os(OSX) 53 | return 501.0 54 | #else 55 | return 500.0 56 | #endif 57 | 58 | } 59 | 60 | public static var low: ConstraintPriority { 61 | return 250.0 62 | } 63 | 64 | public static func ==(lhs: ConstraintPriority, rhs: ConstraintPriority) -> Bool { 65 | return lhs.value == rhs.value 66 | } 67 | 68 | // MARK: Strideable 69 | 70 | public func advanced(by n: FloatLiteralType) -> ConstraintPriority { 71 | return ConstraintPriority(floatLiteral: value + n) 72 | } 73 | 74 | public func distance(to other: ConstraintPriority) -> FloatLiteralType { 75 | return other.value - value 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/Libs/SnapKit/ConstraintPriorityTarget.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SnapKit 3 | // 4 | // Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | 24 | #if os(iOS) || os(tvOS) 25 | import UIKit 26 | #else 27 | import AppKit 28 | #endif 29 | 30 | 31 | public protocol ConstraintPriorityTarget { 32 | 33 | var constraintPriorityTargetValue: Float { get } 34 | 35 | } 36 | 37 | extension Int: ConstraintPriorityTarget { 38 | 39 | public var constraintPriorityTargetValue: Float { 40 | return Float(self) 41 | } 42 | 43 | } 44 | 45 | extension UInt: ConstraintPriorityTarget { 46 | 47 | public var constraintPriorityTargetValue: Float { 48 | return Float(self) 49 | } 50 | 51 | } 52 | 53 | extension Float: ConstraintPriorityTarget { 54 | 55 | public var constraintPriorityTargetValue: Float { 56 | return self 57 | } 58 | 59 | } 60 | 61 | extension Double: ConstraintPriorityTarget { 62 | 63 | public var constraintPriorityTargetValue: Float { 64 | return Float(self) 65 | } 66 | 67 | } 68 | 69 | extension CGFloat: ConstraintPriorityTarget { 70 | 71 | public var constraintPriorityTargetValue: Float { 72 | return Float(self) 73 | } 74 | 75 | } 76 | -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/Libs/SnapKit/ConstraintRelatableTarget.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SnapKit 3 | // 4 | // Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | 24 | #if os(iOS) || os(tvOS) 25 | import UIKit 26 | #else 27 | import AppKit 28 | #endif 29 | 30 | 31 | public protocol ConstraintRelatableTarget { 32 | } 33 | 34 | extension Int: ConstraintRelatableTarget { 35 | } 36 | 37 | extension UInt: ConstraintRelatableTarget { 38 | } 39 | 40 | extension Float: ConstraintRelatableTarget { 41 | } 42 | 43 | extension Double: ConstraintRelatableTarget { 44 | } 45 | 46 | extension CGFloat: ConstraintRelatableTarget { 47 | } 48 | 49 | extension CGSize: ConstraintRelatableTarget { 50 | } 51 | 52 | extension CGPoint: ConstraintRelatableTarget { 53 | } 54 | 55 | extension ConstraintInsets: ConstraintRelatableTarget { 56 | } 57 | 58 | extension ConstraintItem: ConstraintRelatableTarget { 59 | } 60 | 61 | extension ConstraintView: ConstraintRelatableTarget { 62 | } 63 | 64 | @available(iOS 9.0, OSX 10.11, *) 65 | extension ConstraintLayoutGuide: ConstraintRelatableTarget { 66 | } 67 | -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/Libs/SnapKit/ConstraintRelation.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SnapKit 3 | // 4 | // Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | 24 | #if os(iOS) || os(tvOS) 25 | import UIKit 26 | #else 27 | import AppKit 28 | #endif 29 | 30 | 31 | internal enum ConstraintRelation : Int { 32 | case equal = 1 33 | case lessThanOrEqual 34 | case greaterThanOrEqual 35 | 36 | internal var layoutRelation: NSLayoutRelation { 37 | get { 38 | switch(self) { 39 | case .equal: 40 | return .equal 41 | case .lessThanOrEqual: 42 | return .lessThanOrEqual 43 | case .greaterThanOrEqual: 44 | return .greaterThanOrEqual 45 | } 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/Libs/SnapKit/ConstraintView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SnapKit 3 | // 4 | // Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | 24 | #if os(iOS) || os(tvOS) 25 | import UIKit 26 | #else 27 | import AppKit 28 | #endif 29 | 30 | 31 | #if os(iOS) || os(tvOS) 32 | public typealias ConstraintView = UIView 33 | #else 34 | public typealias ConstraintView = NSView 35 | #endif 36 | -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/Libs/SnapKit/ConstraintViewDSL.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SnapKit 3 | // 4 | // Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | 24 | #if os(iOS) || os(tvOS) 25 | import UIKit 26 | #else 27 | import AppKit 28 | #endif 29 | 30 | 31 | public struct ConstraintViewDSL: ConstraintAttributesDSL { 32 | 33 | @discardableResult 34 | public func prepareConstraints(_ closure: (_ make: ConstraintMaker) -> Void) -> [Constraint] { 35 | return ConstraintMaker.prepareConstraints(item: self.view, closure: closure) 36 | } 37 | 38 | public func makeConstraints(_ closure: (_ make: ConstraintMaker) -> Void) { 39 | ConstraintMaker.makeConstraints(item: self.view, closure: closure) 40 | } 41 | 42 | public func remakeConstraints(_ closure: (_ make: ConstraintMaker) -> Void) { 43 | ConstraintMaker.remakeConstraints(item: self.view, closure: closure) 44 | } 45 | 46 | public func updateConstraints(_ closure: (_ make: ConstraintMaker) -> Void) { 47 | ConstraintMaker.updateConstraints(item: self.view, closure: closure) 48 | } 49 | 50 | public func removeConstraints() { 51 | ConstraintMaker.removeConstraints(item: self.view) 52 | } 53 | 54 | public var contentHuggingHorizontalPriority: Float { 55 | get { 56 | return self.view.contentHuggingPriority(for: .horizontal) 57 | } 58 | set { 59 | self.view.setContentHuggingPriority(newValue, for: .horizontal) 60 | } 61 | } 62 | 63 | public var contentHuggingVerticalPriority: Float { 64 | get { 65 | return self.view.contentHuggingPriority(for: .vertical) 66 | } 67 | set { 68 | self.view.setContentHuggingPriority(newValue, for: .vertical) 69 | } 70 | } 71 | 72 | public var contentCompressionResistanceHorizontalPriority: Float { 73 | get { 74 | return self.view.contentCompressionResistancePriority(for: .horizontal) 75 | } 76 | set { 77 | self.view.setContentCompressionResistancePriority(newValue, for: .horizontal) 78 | } 79 | } 80 | 81 | public var contentCompressionResistanceVerticalPriority: Float { 82 | get { 83 | return self.view.contentCompressionResistancePriority(for: .vertical) 84 | } 85 | set { 86 | self.view.setContentCompressionResistancePriority(newValue, for: .vertical) 87 | } 88 | } 89 | 90 | public var target: AnyObject? { 91 | return self.view 92 | } 93 | 94 | internal let view: ConstraintView 95 | 96 | internal init(view: ConstraintView) { 97 | self.view = view 98 | 99 | } 100 | 101 | } 102 | -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/Libs/SnapKit/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | $(PRODUCT_BUNDLE_PACKAGE_TYPE) 17 | CFBundleShortVersionString 18 | $(CURRENT_PROJECT_VERSION) 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | $(CURRENT_PROJECT_VERSION) 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/Libs/SnapKit/LayoutConstraint.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SnapKit 3 | // 4 | // Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | 24 | #if os(iOS) || os(tvOS) 25 | import UIKit 26 | #else 27 | import AppKit 28 | #endif 29 | 30 | 31 | public class LayoutConstraint : NSLayoutConstraint { 32 | 33 | public var label: String? { 34 | get { 35 | return self.identifier 36 | } 37 | set { 38 | self.identifier = newValue 39 | } 40 | } 41 | 42 | internal weak var constraint: Constraint? = nil 43 | 44 | } 45 | 46 | internal func ==(lhs: LayoutConstraint, rhs: LayoutConstraint) -> Bool { 47 | guard lhs.firstItem === rhs.firstItem && 48 | lhs.secondItem === rhs.secondItem && 49 | lhs.firstAttribute == rhs.firstAttribute && 50 | lhs.secondAttribute == rhs.secondAttribute && 51 | lhs.relation == rhs.relation && 52 | lhs.priority == rhs.priority && 53 | lhs.multiplier == rhs.multiplier else { 54 | return false 55 | } 56 | return true 57 | } 58 | -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/Libs/SnapKit/LayoutConstraintItem.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SnapKit 3 | // 4 | // Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | 24 | #if os(iOS) || os(tvOS) 25 | import UIKit 26 | #else 27 | import AppKit 28 | #endif 29 | 30 | 31 | public protocol LayoutConstraintItem: class { 32 | } 33 | 34 | @available(iOS 9.0, OSX 10.11, *) 35 | extension ConstraintLayoutGuide : LayoutConstraintItem { 36 | } 37 | 38 | extension ConstraintView : LayoutConstraintItem { 39 | } 40 | 41 | 42 | extension LayoutConstraintItem { 43 | 44 | internal func prepare() { 45 | if let view = self as? ConstraintView { 46 | view.translatesAutoresizingMaskIntoConstraints = false 47 | } 48 | } 49 | 50 | internal var superview: ConstraintView? { 51 | if let view = self as? ConstraintView { 52 | return view.superview 53 | } 54 | 55 | if #available(iOS 9.0, OSX 10.11, *), let guide = self as? ConstraintLayoutGuide { 56 | return guide.owningView 57 | } 58 | 59 | return nil 60 | } 61 | internal var constraints: [Constraint] { 62 | return self.constraintsSet.allObjects as! [Constraint] 63 | } 64 | 65 | internal func add(constraints: [Constraint]) { 66 | let constraintsSet = self.constraintsSet 67 | for constraint in constraints { 68 | constraintsSet.add(constraint) 69 | } 70 | } 71 | 72 | internal func remove(constraints: [Constraint]) { 73 | let constraintsSet = self.constraintsSet 74 | for constraint in constraints { 75 | constraintsSet.remove(constraint) 76 | } 77 | } 78 | 79 | private var constraintsSet: NSMutableSet { 80 | let constraintsSet: NSMutableSet 81 | 82 | if let existing = objc_getAssociatedObject(self, &constraintsKey) as? NSMutableSet { 83 | constraintsSet = existing 84 | } else { 85 | constraintsSet = NSMutableSet() 86 | objc_setAssociatedObject(self, &constraintsKey, constraintsSet, .OBJC_ASSOCIATION_RETAIN_NONATOMIC) 87 | } 88 | return constraintsSet 89 | 90 | } 91 | 92 | } 93 | private var constraintsKey: UInt8 = 0 94 | -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/Libs/SnapKit/SnapKit.h: -------------------------------------------------------------------------------- 1 | // 2 | // SnapKit 3 | // 4 | // Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | 24 | #import 25 | 26 | FOUNDATION_EXPORT double SnapKitVersionNumber; 27 | FOUNDATION_EXPORT const unsigned char SnapKitVersionString[]; -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/Libs/SnapKit/UILayoutSupport+Extensions.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SnapKit 3 | // 4 | // Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | 24 | #if os(iOS) || os(tvOS) 25 | import UIKit 26 | #endif 27 | 28 | 29 | @available(iOS 8.0, *) 30 | public extension ConstraintLayoutSupport { 31 | 32 | public var snp: ConstraintLayoutSupportDSL { 33 | return ConstraintLayoutSupportDSL(support: self) 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/Libs/YYWebImage/Categories/_YYWebImageSetter.h: -------------------------------------------------------------------------------- 1 | // 2 | // _YYWebImageSetter.h 3 | // YYWebImage 4 | // 5 | // Created by ibireme on 15/7/15. 6 | // Copyright (c) 2015 ibireme. 7 | // 8 | // This source code is licensed under the MIT-style license found in the 9 | // LICENSE file in the root directory of this source tree. 10 | // 11 | #import 12 | #import 13 | 14 | #if __has_include() 15 | #import 16 | #else 17 | #import "YYWebImageManager.h" 18 | #endif 19 | 20 | NS_ASSUME_NONNULL_BEGIN 21 | 22 | /** 23 | Submits a block for execution on a main queue and waits until the block completes. 24 | */ 25 | static inline void _yy_dispatch_sync_on_main_queue(void (^block)()) { 26 | if (pthread_main_np()) { 27 | block(); 28 | } else { 29 | dispatch_sync(dispatch_get_main_queue(), block); 30 | } 31 | } 32 | 33 | extern NSString *const _YYWebImageFadeAnimationKey; 34 | extern const NSTimeInterval _YYWebImageFadeTime; 35 | extern const NSTimeInterval _YYWebImageProgressiveFadeTime; 36 | 37 | /** 38 | Private class used by web image categories. 39 | Typically, you should not use this class directly. 40 | */ 41 | @interface _YYWebImageSetter : NSObject 42 | /// Current image url. 43 | @property (nullable, nonatomic, readonly) NSURL *imageURL; 44 | /// Current sentinel. 45 | @property (nonatomic, readonly) int32_t sentinel; 46 | 47 | /// Create new operation for web image and return a sentinel value. 48 | - (int32_t)setOperationWithSentinel:(int32_t)sentinel 49 | url:(nullable NSURL *)imageURL 50 | options:(YYWebImageOptions)options 51 | manager:(YYWebImageManager *)manager 52 | progress:(nullable YYWebImageProgressBlock)progress 53 | transform:(nullable YYWebImageTransformBlock)transform 54 | transformKey:(nullable NSString *)transformKey 55 | completion:(nullable YYWebImageCompletionBlock)completion; 56 | 57 | /// Cancel and return a sentinel value. The imageURL will be set to nil. 58 | - (int32_t)cancel; 59 | 60 | /// Cancel and return a sentinel value. The imageURL will be set to new value. 61 | - (int32_t)cancelWithNewURL:(nullable NSURL *)imageURL; 62 | 63 | /// A queue to set operation. 64 | + (dispatch_queue_t)setterQueue; 65 | 66 | @end 67 | 68 | NS_ASSUME_NONNULL_END 69 | -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/Libs/YYWebImage/Categories/_YYWebImageSetter.m: -------------------------------------------------------------------------------- 1 | // 2 | // _YYWebImageSetter.m 3 | // YYWebImage 4 | // 5 | // Created by ibireme on 15/7/15. 6 | // Copyright (c) 2015 ibireme. 7 | // 8 | // This source code is licensed under the MIT-style license found in the 9 | // LICENSE file in the root directory of this source tree. 10 | // 11 | 12 | #import "_YYWebImageSetter.h" 13 | #import "YYWebImageOperation.h" 14 | #import 15 | 16 | NSString *const _YYWebImageFadeAnimationKey = @"YYWebImageFade"; 17 | const NSTimeInterval _YYWebImageFadeTime = 0.2; 18 | const NSTimeInterval _YYWebImageProgressiveFadeTime = 0.4; 19 | 20 | 21 | @implementation _YYWebImageSetter { 22 | dispatch_semaphore_t _lock; 23 | NSURL *_imageURL; 24 | NSOperation *_operation; 25 | int32_t _sentinel; 26 | } 27 | 28 | - (instancetype)init { 29 | self = [super init]; 30 | _lock = dispatch_semaphore_create(1); 31 | return self; 32 | } 33 | 34 | - (NSURL *)imageURL { 35 | dispatch_semaphore_wait(_lock, DISPATCH_TIME_FOREVER); 36 | NSURL *imageURL = _imageURL; 37 | dispatch_semaphore_signal(_lock); 38 | return imageURL; 39 | } 40 | 41 | - (void)dealloc { 42 | OSAtomicIncrement32(&_sentinel); 43 | [_operation cancel]; 44 | } 45 | 46 | - (int32_t)setOperationWithSentinel:(int32_t)sentinel 47 | url:(NSURL *)imageURL 48 | options:(YYWebImageOptions)options 49 | manager:(YYWebImageManager *)manager 50 | progress:(YYWebImageProgressBlock)progress 51 | transform:(YYWebImageTransformBlock)transform 52 | transformKey:(nullable NSString *)transformKey 53 | completion:(YYWebImageCompletionBlock)completion { 54 | if (sentinel != _sentinel) { 55 | if (completion) completion(nil, imageURL, YYWebImageFromNone, YYWebImageStageCancelled, nil); 56 | return _sentinel; 57 | } 58 | 59 | NSOperation *operation = [manager requestImageWithURL:imageURL options:options progress:progress transform:transform transformKey:transformKey completion:completion]; 60 | if (!operation && completion) { 61 | NSDictionary *userInfo = @{ NSLocalizedDescriptionKey : @"YYWebImageOperation create failed." }; 62 | completion(nil, imageURL, YYWebImageFromNone, YYWebImageStageFinished, [NSError errorWithDomain:@"com.ibireme.webimage" code:-1 userInfo:userInfo]); 63 | } 64 | 65 | dispatch_semaphore_wait(_lock, DISPATCH_TIME_FOREVER); 66 | if (sentinel == _sentinel) { 67 | if (_operation) [_operation cancel]; 68 | _operation = operation; 69 | sentinel = OSAtomicIncrement32(&_sentinel); 70 | } else { 71 | [operation cancel]; 72 | } 73 | dispatch_semaphore_signal(_lock); 74 | return sentinel; 75 | } 76 | 77 | - (int32_t)cancel { 78 | return [self cancelWithNewURL:nil]; 79 | } 80 | 81 | - (int32_t)cancelWithNewURL:(NSURL *)imageURL { 82 | int32_t sentinel; 83 | dispatch_semaphore_wait(_lock, DISPATCH_TIME_FOREVER); 84 | if (_operation) { 85 | [_operation cancel]; 86 | _operation = nil; 87 | } 88 | _imageURL = imageURL; 89 | sentinel = OSAtomicIncrement32(&_sentinel); 90 | dispatch_semaphore_signal(_lock); 91 | return sentinel; 92 | } 93 | 94 | + (dispatch_queue_t)setterQueue { 95 | static dispatch_queue_t queue; 96 | static dispatch_once_t onceToken; 97 | dispatch_once(&onceToken, ^{ 98 | queue = dispatch_queue_create("com.ibireme.webimage.setter", DISPATCH_QUEUE_SERIAL); 99 | dispatch_set_target_queue(queue, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)); 100 | }); 101 | return queue; 102 | } 103 | 104 | @end 105 | -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/Libs/YYWebImage/Image/YYImage.h: -------------------------------------------------------------------------------- 1 | // 2 | // YYImage.h 3 | // YYImage 4 | // 5 | // Created by ibireme on 14/10/20. 6 | // Copyright (c) 2015 ibireme. 7 | // 8 | // This source code is licensed under the MIT-style license found in the 9 | // LICENSE file in the root directory of this source tree. 10 | // 11 | 12 | #import 13 | 14 | #if __has_include() 15 | FOUNDATION_EXPORT double YYImageVersionNumber; 16 | FOUNDATION_EXPORT const unsigned char YYImageVersionString[]; 17 | #import 18 | #import 19 | #import 20 | #import 21 | #elif __has_include() 22 | #import 23 | #import 24 | #import 25 | #import 26 | #else 27 | #import "YYFrameImage.h" 28 | #import "YYSpriteSheetImage.h" 29 | #import "YYImageCoder.h" 30 | #import "YYAnimatedImageView.h" 31 | #endif 32 | 33 | NS_ASSUME_NONNULL_BEGIN 34 | 35 | 36 | /** 37 | A YYImage object is a high-level way to display animated image data. 38 | 39 | @discussion It is a fully compatible `UIImage` subclass. It extends the UIImage 40 | to support animated WebP, APNG and GIF format image data decoding. It also 41 | support NSCoding protocol to archive and unarchive multi-frame image data. 42 | 43 | If the image is created from multi-frame image data, and you want to play the 44 | animation, try replace UIImageView with `YYAnimatedImageView`. 45 | 46 | Sample Code: 47 | 48 | // animation@3x.webp 49 | YYImage *image = [YYImage imageNamed:@"animation.webp"]; 50 | YYAnimatedImageView *imageView = [YYAnimatedImageView alloc] initWithImage:image]; 51 | [view addSubView:imageView]; 52 | 53 | */ 54 | @interface YYImage : UIImage 55 | 56 | + (nullable YYImage *)imageNamed:(NSString *)name; // no cache! 57 | + (nullable YYImage *)imageWithContentsOfFile:(NSString *)path; 58 | + (nullable YYImage *)imageWithData:(NSData *)data; 59 | + (nullable YYImage *)imageWithData:(NSData *)data scale:(CGFloat)scale; 60 | 61 | /** 62 | If the image is created from data or file, then the value indicates the data type. 63 | */ 64 | @property (nonatomic, readonly) YYImageType animatedImageType; 65 | 66 | /** 67 | If the image is created from animated image data (multi-frame GIF/APNG/WebP), 68 | this property stores the original image data. 69 | */ 70 | @property (nullable, nonatomic, readonly) NSData *animatedImageData; 71 | 72 | /** 73 | The total memory usage (in bytes) if all frame images was loaded into memory. 74 | The value is 0 if the image is not created from a multi-frame image data. 75 | */ 76 | @property (nonatomic, readonly) NSUInteger animatedImageMemorySize; 77 | 78 | /** 79 | Preload all frame image to memory. 80 | 81 | @discussion Set this property to `YES` will block the calling thread to decode 82 | all animation frame image to memory, set to `NO` will release the preloaded frames. 83 | If the image is shared by lots of image views (such as emoticon), preload all 84 | frames will reduce the CPU cost. 85 | 86 | See `animatedImageMemorySize` for memory cost. 87 | */ 88 | @property (nonatomic) BOOL preloadAllAnimatedImageFrames; 89 | 90 | @end 91 | 92 | NS_ASSUME_NONNULL_END 93 | -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/Libs/YYWebImage/Image/YYSpriteSheetImage.h: -------------------------------------------------------------------------------- 1 | // 2 | // YYSpriteImage.h 3 | // YYImage 4 | // 5 | // Created by ibireme on 15/4/21. 6 | // Copyright (c) 2015 ibireme. 7 | // 8 | // This source code is licensed under the MIT-style license found in the 9 | // LICENSE file in the root directory of this source tree. 10 | // 11 | 12 | #import 13 | 14 | #if __has_include() 15 | #import 16 | #elif __has_include() 17 | #import 18 | #else 19 | #import "YYAnimatedImageView.h" 20 | #endif 21 | 22 | NS_ASSUME_NONNULL_BEGIN 23 | 24 | /** 25 | An image to display sprite sheet animation. 26 | 27 | @discussion It is a fully compatible `UIImage` subclass. 28 | The animation can be played by YYAnimatedImageView. 29 | 30 | Sample Code: 31 | 32 | // 8 * 12 sprites in a single sheet image 33 | UIImage *spriteSheet = [UIImage imageNamed:@"sprite-sheet"]; 34 | NSMutableArray *contentRects = [NSMutableArray new]; 35 | NSMutableArray *durations = [NSMutableArray new]; 36 | for (int j = 0; j < 12; j++) { 37 | for (int i = 0; i < 8; i++) { 38 | CGRect rect; 39 | rect.size = CGSizeMake(img.size.width / 8, img.size.height / 12); 40 | rect.origin.x = img.size.width / 8 * i; 41 | rect.origin.y = img.size.height / 12 * j; 42 | [contentRects addObject:[NSValue valueWithCGRect:rect]]; 43 | [durations addObject:@(1 / 60.0)]; 44 | } 45 | } 46 | YYSpriteSheetImage *sprite; 47 | sprite = [[YYSpriteSheetImage alloc] initWithSpriteSheetImage:img 48 | contentRects:contentRects 49 | frameDurations:durations 50 | loopCount:0]; 51 | YYAnimatedImageView *imgView = [YYAnimatedImageView new]; 52 | imgView.size = CGSizeMake(img.size.width / 8, img.size.height / 12); 53 | imgView.image = sprite; 54 | 55 | 56 | 57 | @discussion It can also be used to display single frame in sprite sheet image. 58 | Sample Code: 59 | 60 | YYSpriteSheetImage *sheet = ...; 61 | UIImageView *imageView = ...; 62 | imageView.image = sheet; 63 | imageView.layer.contentsRect = [sheet contentsRectForCALayerAtIndex:6]; 64 | 65 | */ 66 | @interface YYSpriteSheetImage : UIImage 67 | 68 | /** 69 | Creates and returns an image object. 70 | 71 | @param image The sprite sheet image (contains all frames). 72 | 73 | @param contentRects The sprite sheet image frame rects in the image coordinates. 74 | The rectangle should not outside the image's bounds. The objects in this array 75 | should be created with [NSValue valueWithCGRect:]. 76 | 77 | @param frameDurations The sprite sheet image frame's durations in seconds. 78 | The objects in this array should be NSNumber. 79 | 80 | @param loopCount Animation loop count, 0 means infinite looping. 81 | 82 | @return An image object, or nil if an error occurs. 83 | */ 84 | - (nullable instancetype)initWithSpriteSheetImage:(UIImage *)image 85 | contentRects:(NSArray *)contentRects 86 | frameDurations:(NSArray *)frameDurations 87 | loopCount:(NSUInteger)loopCount; 88 | 89 | @property (nonatomic, readonly) NSArray *contentRects; 90 | @property (nonatomic, readonly) NSArray *frameDurations; 91 | @property (nonatomic, readonly) NSUInteger loopCount; 92 | 93 | /** 94 | Get the contents rect for CALayer. 95 | See "contentsRect" property in CALayer for more information. 96 | 97 | @param index Index of frame. 98 | @return Contents Rect. 99 | */ 100 | - (CGRect)contentsRectForCALayerAtIndex:(NSUInteger)index; 101 | 102 | @end 103 | 104 | NS_ASSUME_NONNULL_END 105 | -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/Libs/YYWebImage/Image/YYSpriteSheetImage.m: -------------------------------------------------------------------------------- 1 | // 2 | // YYSpriteImage.m 3 | // YYImage 4 | // 5 | // Created by ibireme on 15/4/21. 6 | // Copyright (c) 2015 ibireme. 7 | // 8 | // This source code is licensed under the MIT-style license found in the 9 | // LICENSE file in the root directory of this source tree. 10 | // 11 | 12 | #import "YYSpriteSheetImage.h" 13 | 14 | @implementation YYSpriteSheetImage 15 | 16 | - (instancetype)initWithSpriteSheetImage:(UIImage *)image 17 | contentRects:(NSArray *)contentRects 18 | frameDurations:(NSArray *)frameDurations 19 | loopCount:(NSUInteger)loopCount { 20 | if (!image.CGImage) return nil; 21 | if (contentRects.count < 1 || frameDurations.count < 1) return nil; 22 | if (contentRects.count != frameDurations.count) return nil; 23 | 24 | self = [super initWithCGImage:image.CGImage scale:image.scale orientation:image.imageOrientation]; 25 | if (!self) return nil; 26 | 27 | _contentRects = contentRects.copy; 28 | _frameDurations = frameDurations.copy; 29 | _loopCount = loopCount; 30 | return self; 31 | } 32 | 33 | - (CGRect)contentsRectForCALayerAtIndex:(NSUInteger)index { 34 | CGRect layerRect = CGRectMake(0, 0, 1, 1); 35 | if (index >= _contentRects.count) return layerRect; 36 | 37 | CGSize imageSize = self.size; 38 | CGRect rect = [self animatedImageContentsRectAtIndex:index]; 39 | if (imageSize.width > 0.01 && imageSize.height > 0.01) { 40 | layerRect.origin.x = rect.origin.x / imageSize.width; 41 | layerRect.origin.y = rect.origin.y / imageSize.height; 42 | layerRect.size.width = rect.size.width / imageSize.width; 43 | layerRect.size.height = rect.size.height / imageSize.height; 44 | layerRect = CGRectIntersection(layerRect, CGRectMake(0, 0, 1, 1)); 45 | if (CGRectIsNull(layerRect) || CGRectIsEmpty(layerRect)) { 46 | layerRect = CGRectMake(0, 0, 1, 1); 47 | } 48 | } 49 | return layerRect; 50 | } 51 | 52 | #pragma mark @protocol YYAnimatedImage 53 | 54 | - (NSUInteger)animatedImageFrameCount { 55 | return _contentRects.count; 56 | } 57 | 58 | - (NSUInteger)animatedImageLoopCount { 59 | return _loopCount; 60 | } 61 | 62 | - (NSUInteger)animatedImageBytesPerFrame { 63 | return 0; 64 | } 65 | 66 | - (UIImage *)animatedImageFrameAtIndex:(NSUInteger)index { 67 | return self; 68 | } 69 | 70 | - (NSTimeInterval)animatedImageDurationAtIndex:(NSUInteger)index { 71 | if (index >= _frameDurations.count) return 0; 72 | return ((NSNumber *)_frameDurations[index]).doubleValue; 73 | } 74 | 75 | - (CGRect)animatedImageContentsRectAtIndex:(NSUInteger)index { 76 | if (index >= _contentRects.count) return CGRectZero; 77 | return ((NSValue *)_contentRects[index]).CGRectValue; 78 | } 79 | 80 | @end 81 | -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/Libs/YYWebImage/YYWebImage.h: -------------------------------------------------------------------------------- 1 | // 2 | // YYWebImage.h 3 | // YYWebImage 4 | // 5 | // Created by ibireme on 15/2/23. 6 | // Copyright (c) 2015 ibireme. 7 | // 8 | // This source code is licensed under the MIT-style license found in the 9 | // LICENSE file in the root directory of this source tree. 10 | // 11 | 12 | #import 13 | 14 | #if __has_include() 15 | FOUNDATION_EXPORT double YYWebImageVersionNumber; 16 | FOUNDATION_EXPORT const unsigned char YYWebImageVersionString[]; 17 | #import 18 | #import 19 | #import 20 | #import 21 | #import 22 | #import 23 | #import 24 | #import 25 | #else 26 | #import "YYImageCache.h" 27 | #import "YYWebImageOperation.h" 28 | #import "YYWebImageManager.h" 29 | #import "UIImage+YYWebImage.h" 30 | #import "UIImageView+YYWebImage.h" 31 | #import "UIButton+YYWebImage.h" 32 | #import "CALayer+YYWebImage.h" 33 | #import "MKAnnotationView+YYWebImage.h" 34 | #endif 35 | 36 | #if __has_include() 37 | #import 38 | #elif __has_include() 39 | #import 40 | #import 41 | #import 42 | #import 43 | #import 44 | #else 45 | #import "YYImage.h" 46 | #import "YYFrameImage.h" 47 | #import "YYSpriteSheetImage.h" 48 | #import "YYImageCoder.h" 49 | #import "YYAnimatedImageView.h" 50 | #endif 51 | 52 | #if __has_include() 53 | #import 54 | #elif __has_include() 55 | #import 56 | #import 57 | #import 58 | #import 59 | #else 60 | #import "YYCache.h" 61 | #import "YYMemoryCache.h" 62 | #import "YYDiskCache.h" 63 | #import "YYKVStorage.h" 64 | #endif 65 | 66 | -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/Model/YZDemoVideo.swift: -------------------------------------------------------------------------------- 1 | // 2 | // YZDemoVideo.swift 3 | // YZPlayerDemo 4 | // 5 | // Created by heyuze on 2017/5/12. 6 | // Copyright © 2017年 heyuze. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class YZDemoVideo: YZVideo { 12 | 13 | // var play_address: String? 14 | 15 | // var title: String? 16 | 17 | var video_id: Int = 0 18 | 19 | var poster: String = "" 20 | 21 | var detail: String = "" 22 | 23 | var director: String = "" 24 | 25 | var actor: String = "" 26 | 27 | var comment_number: Int = 0 28 | 29 | var like_number: Int = 0 30 | 31 | var share_number: Int = 0 32 | 33 | var status: Int = 0 34 | 35 | var time: Int = 0 36 | 37 | var charge: Int = 0 38 | 39 | var user_id: Int = 0 40 | 41 | var view_number: Int = 0 42 | 43 | var length: Int = 0 44 | 45 | var play_id: Int = 0 46 | 47 | var chapter: Int = 0 48 | 49 | var type: Int = 0 // 0:其他, 1:剧集, 2:MV, 3:影视, 4:自制, 5:创作, 6:搞笑 50 | 51 | 52 | // MARK: - 处理数据 53 | 54 | var typeString: String { 55 | get { 56 | switch type { 57 | case 1: 58 | return "剧集" 59 | case 2: 60 | return "MV" 61 | case 3: 62 | return "影视" 63 | case 4: 64 | return "自制" 65 | case 5: 66 | return "创作" 67 | case 6: 68 | return "搞笑" 69 | default: 70 | return "其他" 71 | } 72 | } 73 | } 74 | 75 | 76 | // MARK: - init 77 | 78 | override init(dict: [String : Any]) { 79 | super.init(dict: dict) 80 | 81 | setValuesForKeys(dict) 82 | } 83 | 84 | override func setValue(_ value: Any?, forUndefinedKey key: String) { 85 | 86 | } 87 | 88 | } 89 | -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/Tools/CommonTools.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CommonTools.swift 3 | // MU 4 | // 5 | // Created by heyuze on 16/7/8. 6 | // Copyright © 2016年 HYZ. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | // MARK: - 随机字符串 12 | func randomSmallCaseString(length: Int) -> String { 13 | var output = "" 14 | for _ in 0.. UIColor { 26 | return UIColor(red: CGFloat(arc4random() % 256) / 255, green: CGFloat(arc4random() % 256) / 255, blue: CGFloat(arc4random() % 256) / 255, alpha: 1) 27 | } 28 | public extension UIColor { 29 | public convenience init(colorHex: UInt32, alpha: CGFloat = 1.0) { 30 | let red = CGFloat((colorHex & 0xFF0000) >> 16) / 255.0 31 | let green = CGFloat((colorHex & 0x00FF00) >> 8 ) / 255.0 32 | let blue = CGFloat((colorHex & 0x0000FF) ) / 255.0 33 | self.init(red: red, green: green, blue: blue, alpha: alpha) 34 | } 35 | } 36 | 37 | // MARK: - 时间 38 | // 秒数转换为时间 39 | func secondsConverToTimeStr(seconds: Int) -> String { 40 | if seconds >= 3600 { 41 | let hour = seconds / 3600 42 | let minute = (seconds - 3600*hour) / 60 43 | let second = seconds % 60 44 | return String.init(format: "%02d:%02d:%02d", hour, minute, second) 45 | } else { 46 | let minute = seconds / 60 47 | let second = seconds % 60 48 | return String.init(format: "%02d:%02d", minute, second) 49 | } 50 | } 51 | 52 | // 把时间戳和当前时间做比较,转换为xxx天前 53 | func compareNowTimeToStr(time: Int) -> String { 54 | let nowTime = Int(Date().timeIntervalSince1970) 55 | let diffSecond = nowTime - time 56 | 57 | if diffSecond < 60 { 58 | return "\(diffSecond)秒前" 59 | } else if diffSecond < 3600 { 60 | let minute = diffSecond / 60 61 | return "\(minute)分钟前" 62 | } else if diffSecond < 3600*24 { 63 | let hour = diffSecond / 3600 64 | return "\(hour)小时前" 65 | } else { 66 | let day = diffSecond / (3600*24) 67 | return "\(day)天前" 68 | } 69 | } 70 | 71 | func convertToDate(time: Int) -> String { 72 | let timeDouble = Double(time) 73 | // 时间转换 74 | let dateFormatter = DateFormatter() 75 | dateFormatter.dateFormat="yyyy/MM/dd" 76 | let date = Date.init(timeIntervalSince1970: timeDouble) 77 | let dateStr = dateFormatter.string(from: date) 78 | return dateStr 79 | } 80 | 81 | // 获取时间长度 82 | func getTimeLengthStr(length: Int) -> String { 83 | let minute = length / 60 84 | let second = length % 60 85 | let lengthStr = String.init(format: "%02d′%02d″", minute, second) 86 | return lengthStr 87 | } 88 | 89 | 90 | /* 91 | // MARK: - 自定义Log 92 | func printLog(_ message: Any, file: String = #file, line: Int = #line, function: String = #function) 93 | { 94 | #if DEBUG 95 | print("\((file as NSString).lastPathComponent)[\(line)], \(function): \(message)\n") 96 | #endif 97 | } 98 | */ 99 | 100 | -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/Tools/UIBarButtonItem+Extension.swift: -------------------------------------------------------------------------------- 1 | // 2 | // UIBarButtonItem+Extension.swift 3 | // MU 4 | // 5 | // Created by heyuze on 16/7/11. 6 | // Copyright © 2016年 HYZ. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | extension UIBarButtonItem { 12 | 13 | // 分类里 使用遍历构造器 14 | convenience init(imageName: String? = nil, title: String? = nil, target: AnyObject?, action: Selector) { 15 | self.init() //遍历构造器必须调用自己的init 16 | 17 | let button = UIButton() 18 | 19 | if imageName != nil 20 | { 21 | button.setImage(UIImage(named: imageName!), for: .normal) 22 | // button.setImage(UIImage(named: "\(imageName!)_highlighted"), forState: UIControlState.Highlighted) 23 | button.imageEdgeInsets = UIEdgeInsets(top: 0, left: -10, bottom: 0, right: 0) 24 | } 25 | 26 | if title != nil 27 | { 28 | button.setTitle(title!, for: .normal) 29 | // 设置字体的大小颜色 30 | button.titleLabel?.font = UIFont.systemFont(ofSize: 13) 31 | button.setTitleColor(BLACK, for: .normal) 32 | button.setTitleColor(BLUE, for: .highlighted) 33 | button.setTitleColor(RGB(r: 0x66, g: 0x66, b: 0x66, alpha: 0.3), for: .disabled) 34 | } 35 | 36 | button.addTarget(target, action: action, for: UIControlEvents.touchUpInside) 37 | 38 | button.sizeToFit() 39 | 40 | customView = button 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/Tools/UIViewController+Extension.swift: -------------------------------------------------------------------------------- 1 | // 2 | // UIViewController+Extension.swift 3 | // MU 4 | // 5 | // Created by heyuze on 16/7/28. 6 | // Copyright © 2016年 HYZ. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | extension UIViewController { 12 | 13 | func naviTitleLabel(title: String) -> UILabel { 14 | let titleLabel = UILabel(text: title, textColor: BLACK_26, fontSize: 16) 15 | titleLabel.font = UIFont.systemFont(ofSize: 16, weight: UIFontWeightSemibold) 16 | titleLabel.sizeToFit() 17 | return titleLabel 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/View/Others/YZVideoAllCommentCell.swift: -------------------------------------------------------------------------------- 1 | // 2 | // YZVideoAllCommentCell.swift 3 | // Mov 4 | // 5 | // Created by heyuze on 2016/11/28. 6 | // Copyright © 2016年 heyuze. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class YZVideoAllCommentCell: UITableViewCell { 12 | 13 | // MARK: - init 14 | 15 | override init(style: UITableViewCellStyle, reuseIdentifier: String?) { 16 | super.init(style: style, reuseIdentifier: reuseIdentifier) 17 | 18 | setupUI() 19 | } 20 | 21 | required init?(coder aDecoder: NSCoder) { 22 | fatalError("init(coder:) has not been implemented") 23 | } 24 | 25 | 26 | // MARK: - Set up 27 | 28 | private func setupUI() { 29 | backgroundColor = WHITE 30 | contentView.backgroundColor = WHITE 31 | selectionStyle = .none 32 | 33 | contentView.addSubview(titleLabel) 34 | titleLabel.snp.makeConstraints { (make) in 35 | make.center.equalTo(contentView) 36 | } 37 | } 38 | 39 | 40 | // MARK: - Lazy Load 41 | 42 | private lazy var titleLabel = UILabel(text: "查看全部评论 >", textColor: BLUE, fontSize: 13) 43 | 44 | } 45 | -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/View/Others/YZVideoAuthorInfoCell.swift: -------------------------------------------------------------------------------- 1 | // 2 | // YZVideoAuthorInfoCell.swift 3 | // Mov 4 | // 5 | // Created by heyuze on 2016/11/24. 6 | // Copyright © 2016年 heyuze. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class YZVideoAuthorInfoCell: UITableViewCell { 12 | 13 | // MARK: - init 14 | 15 | override init(style: UITableViewCellStyle, reuseIdentifier: String?) { 16 | super.init(style: style, reuseIdentifier: reuseIdentifier) 17 | 18 | setupUI() 19 | } 20 | 21 | required init?(coder aDecoder: NSCoder) { 22 | fatalError("init(coder:) has not been implemented") 23 | } 24 | 25 | 26 | // MARK: - Set up 27 | 28 | private func setupUI() { 29 | backgroundColor = WHITE 30 | contentView.backgroundColor = WHITE 31 | selectionStyle = .none 32 | 33 | let lineView = UIView() 34 | lineView.backgroundColor = BACKGROUND_COLOR 35 | contentView.addSubview(lineView) 36 | lineView.snp.makeConstraints { (make) in 37 | make.leading.top.trailing.equalTo(contentView) 38 | make.height.equalTo(5) 39 | } 40 | 41 | contentView.addSubview(iconView) 42 | contentView.addSubview(nameLabel) 43 | contentView.addSubview(followBtn) 44 | 45 | iconView.snp.makeConstraints { (make) in 46 | make.centerY.equalTo(contentView).offset(5) 47 | make.leading.equalTo(contentView).offset(15) 48 | make.width.height.equalTo(36) 49 | } 50 | nameLabel.snp.makeConstraints { (make) in 51 | make.centerY.equalTo(contentView).offset(5) 52 | make.leading.equalTo(iconView.snp.trailing).offset(10) 53 | } 54 | followBtn.snp.makeConstraints { (make) in 55 | make.centerY.equalTo(contentView).offset(5) 56 | make.trailing.equalTo(contentView).offset(-15) 57 | make.width.equalTo(50) 58 | make.height.equalTo(30) 59 | } 60 | } 61 | 62 | 63 | // MARK: - Action 64 | 65 | @objc private func clickFollowBtn() { 66 | print("follow") 67 | } 68 | 69 | 70 | // MARK: - Lazy Load 71 | 72 | private lazy var iconView: UIImageView = { 73 | let iconView = UIImageView(image: UIImage(named: "jinx")) 74 | return iconView 75 | }() 76 | 77 | private lazy var nameLabel = UILabel(text: "Name", textColor: BLACK, fontSize: 14) 78 | 79 | private lazy var followBtn: UIButton = { 80 | let followBtn = UIButton() 81 | followBtn.frame = CGRect(x: 0, y: 0, width: 50, height: 30) 82 | followBtn.layer.cornerRadius = 15 83 | followBtn.layer.masksToBounds = true 84 | followBtn.titleLabel?.font = UIFont.systemFont(ofSize: 14) 85 | followBtn.setTitle("关注", for: .normal) 86 | followBtn.setTitleColor(WHITE, for: .normal) 87 | followBtn.setBackgroundImage(UIImage.colorImage(color: BLUE, size: followBtn.size), for: .normal) 88 | followBtn.setBackgroundImage(UIImage.colorImage(color: RGB(r: 0x00, g: 0x56, b: 0xff, alpha: 0.8), size: followBtn.size), for: .highlighted) 89 | followBtn.addTarget(self, action: #selector(self.clickFollowBtn), for: .touchUpInside) 90 | return followBtn 91 | }() 92 | 93 | } 94 | -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/View/Others/YZVideoCommentCell.swift: -------------------------------------------------------------------------------- 1 | // 2 | // YZVideoCommentCell.swift 3 | // Mov 4 | // 5 | // Created by heyuze on 2016/11/26. 6 | // Copyright © 2016年 heyuze. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class YZVideoCommentCell: UITableViewCell { 12 | 13 | // MARK: - init 14 | 15 | override init(style: UITableViewCellStyle, reuseIdentifier: String?) { 16 | super.init(style: style, reuseIdentifier: reuseIdentifier) 17 | 18 | setupUI() 19 | } 20 | 21 | required init?(coder aDecoder: NSCoder) { 22 | fatalError("init(coder:) has not been implemented") 23 | } 24 | 25 | 26 | // MARK: - Set up 27 | 28 | private func setupUI() { 29 | backgroundColor = WHITE 30 | contentView.backgroundColor = WHITE 31 | selectionStyle = .none 32 | 33 | contentView.addSubview(iconView) 34 | contentView.addSubview(nameLabel) 35 | contentView.addSubview(timeLabel) 36 | contentView.addSubview(likeNumberLabel) 37 | contentView.addSubview(likeBtn) 38 | contentView.addSubview(commentLabel) 39 | 40 | iconView.snp.makeConstraints { (make) in 41 | make.top.equalTo(contentView).offset(10) 42 | make.leading.equalTo(contentView).offset(15) 43 | make.width.height.equalTo(36) 44 | } 45 | nameLabel.snp.makeConstraints { (make) in 46 | make.top.equalTo(contentView).offset(15) 47 | make.leading.equalTo(iconView.snp.trailing).offset(10) 48 | make.height.equalTo(13) 49 | } 50 | timeLabel.snp.makeConstraints { (make) in 51 | make.leading.equalTo(nameLabel) 52 | make.top.equalTo(nameLabel.snp.bottom).offset(7) 53 | make.height.equalTo(11) 54 | } 55 | likeNumberLabel.snp.makeConstraints { (make) in 56 | make.trailing.equalTo(contentView).offset(-15) 57 | make.centerY.equalTo(nameLabel) 58 | } 59 | likeBtn.snp.makeConstraints { (make) in 60 | make.trailing.equalTo(likeNumberLabel.snp.leading).offset(-5) 61 | make.centerY.equalTo(likeNumberLabel) 62 | } 63 | commentLabel.snp.makeConstraints { (make) in 64 | make.top.equalTo(timeLabel.snp.bottom).offset(12) 65 | make.leading.equalTo(nameLabel) 66 | make.trailing.equalTo(contentView).offset(-15) 67 | } 68 | 69 | let lineView = UIView() 70 | lineView.backgroundColor = BACKGROUND_COLOR 71 | contentView.addSubview(lineView) 72 | lineView.snp.makeConstraints { (make) in 73 | make.leading.trailing.bottom.equalTo(contentView) 74 | make.height.equalTo(1) 75 | } 76 | } 77 | 78 | 79 | // MARK: - Action 80 | 81 | @objc private func like() { 82 | print("like") 83 | } 84 | 85 | 86 | // MARK: - Lazy Load 87 | 88 | private lazy var iconView: UIImageView = { 89 | let iconView = UIImageView() 90 | iconView.image = UIImage(named: "jinx") 91 | return iconView 92 | }() 93 | 94 | private lazy var nameLabel = UILabel(text: "Name", textColor: BLACK, fontSize: 13) 95 | 96 | private lazy var timeLabel = UILabel(text: "1分钟前", textColor: GRAY_99, fontSize: 11) 97 | 98 | private lazy var likeNumberLabel = UILabel(text: "0", textColor: GRAY_99, fontSize: 11) 99 | 100 | private lazy var likeBtn: UIButton = { 101 | let likeBtn = UIButton() 102 | likeBtn.setImage(UIImage(named: "video_comment_like"), for: .normal) 103 | likeBtn.addTarget(self, action: #selector(self.like), for: .touchUpInside) 104 | return likeBtn 105 | }() 106 | 107 | private lazy var commentLabel: UILabel = { 108 | let commentLabel = UILabel(text: "Comment...", textColor: BLACK, fontSize: 13) 109 | commentLabel.numberOfLines = 0 110 | return commentLabel 111 | }() 112 | 113 | } 114 | -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/View/Others/YZVideoInfoCell.swift: -------------------------------------------------------------------------------- 1 | // 2 | // YZVideoInfoCell.swift 3 | // Mov 4 | // 5 | // Created by heyuze on 2016/11/24. 6 | // Copyright © 2016年 heyuze. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class YZVideoInfoCell: UITableViewCell { 12 | 13 | // MARK: - init 14 | 15 | override init(style: UITableViewCellStyle, reuseIdentifier: String?) { 16 | super.init(style: style, reuseIdentifier: reuseIdentifier) 17 | 18 | setupUI() 19 | } 20 | 21 | required init?(coder aDecoder: NSCoder) { 22 | fatalError("init(coder:) has not been implemented") 23 | } 24 | 25 | 26 | // MARK: - Set up 27 | 28 | private func setupUI() { 29 | backgroundColor = WHITE 30 | contentView.backgroundColor = WHITE 31 | selectionStyle = .none 32 | 33 | let lineView = UIView() 34 | lineView.backgroundColor = BACKGROUND_COLOR 35 | contentView.addSubview(lineView) 36 | lineView.snp.makeConstraints { (make) in 37 | make.leading.top.trailing.equalTo(contentView) 38 | make.height.equalTo(5) 39 | } 40 | 41 | contentView.addSubview(titleLabel) 42 | contentView.addSubview(detailLabel) 43 | contentView.addSubview(nextView) 44 | 45 | titleLabel.snp.makeConstraints { (make) in 46 | make.leading.equalTo(contentView).offset(15) 47 | make.top.equalTo(lineView.snp.bottom).offset(18) 48 | } 49 | detailLabel.snp.makeConstraints { (make) in 50 | make.leading.equalTo(contentView).offset(15) 51 | make.bottom.equalTo(contentView).offset(-18) 52 | make.trailing.equalTo(nextView.snp.leading).offset(-10) 53 | } 54 | nextView.snp.makeConstraints { (make) in 55 | make.trailing.equalTo(contentView).offset(-15) 56 | make.centerY.equalTo(contentView).offset(5) 57 | } 58 | } 59 | 60 | 61 | // MARK: - Lazy Load 62 | 63 | private lazy var titleLabel = UILabel(text: "Title", textColor: BLACK, fontSize: 14) 64 | 65 | private lazy var detailLabel = UILabel(text: "Details...", textColor: GRAY_99, fontSize: 12) 66 | 67 | private lazy var nextView = UIImageView(image: UIImage(named: "video_next")) 68 | 69 | } 70 | -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/View/Others/YZVideoUserInputCell.swift: -------------------------------------------------------------------------------- 1 | // 2 | // YZVideoUserInputCell.swift 3 | // Mov 4 | // 5 | // Created by heyuze on 2016/11/25. 6 | // Copyright © 2016年 heyuze. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class YZVideoUserInputCell: UITableViewCell { 12 | 13 | var commentCallBack: (()->())? 14 | 15 | 16 | // MARK: - init 17 | 18 | override init(style: UITableViewCellStyle, reuseIdentifier: String?) { 19 | super.init(style: style, reuseIdentifier: reuseIdentifier) 20 | 21 | setupUI() 22 | } 23 | 24 | required init?(coder aDecoder: NSCoder) { 25 | fatalError("init(coder:) has not been implemented") 26 | } 27 | 28 | 29 | // MARK: - Set up 30 | 31 | private func setupUI() { 32 | backgroundColor = WHITE 33 | contentView.backgroundColor = WHITE 34 | selectionStyle = .none 35 | 36 | let toplineView = UIView() 37 | toplineView.backgroundColor = BACKGROUND_COLOR 38 | contentView.addSubview(toplineView) 39 | toplineView.snp.makeConstraints { (make) in 40 | make.leading.top.trailing.equalTo(contentView) 41 | make.height.equalTo(5) 42 | } 43 | 44 | contentView.addSubview(commentLabel) 45 | contentView.addSubview(commentNumberLabel) 46 | contentView.addSubview(iconView) 47 | contentView.addSubview(commentInputBackView) 48 | contentView.addSubview(placeholderLabel) 49 | 50 | commentLabel.snp.makeConstraints { (make) in 51 | make.top.equalTo(contentView).offset(15) 52 | make.leading.equalTo(contentView).offset(15) 53 | make.height.equalTo(15) 54 | } 55 | commentNumberLabel.snp.makeConstraints { (make) in 56 | make.leading.equalTo(commentLabel.snp.trailing).offset(10) 57 | make.centerY.equalTo(commentLabel) 58 | } 59 | iconView.snp.makeConstraints { (make) in 60 | make.top.equalTo(commentLabel.snp.bottom).offset(18) 61 | make.leading.equalTo(contentView).offset(15) 62 | make.width.height.equalTo(36) 63 | } 64 | commentInputBackView.snp.makeConstraints { (make) in 65 | make.centerY.equalTo(iconView) 66 | make.leading.equalTo(iconView.snp.trailing).offset(10) 67 | make.trailing.equalTo(contentView).offset(-15) 68 | make.height.equalTo(36) 69 | } 70 | placeholderLabel.snp.makeConstraints { (make) in 71 | make.centerY.equalTo(commentInputBackView) 72 | make.leading.equalTo(commentInputBackView).offset(20) 73 | } 74 | 75 | let bottomLineView = UIView() 76 | bottomLineView.backgroundColor = BACKGROUND_COLOR 77 | contentView.addSubview(bottomLineView) 78 | bottomLineView.snp.makeConstraints { (make) in 79 | make.leading.trailing.bottom.equalTo(contentView) 80 | make.height.equalTo(5) 81 | } 82 | } 83 | 84 | 85 | // MARK: - Action 86 | 87 | @objc private func comment() { 88 | if commentCallBack != nil { 89 | commentCallBack!() 90 | } 91 | } 92 | 93 | 94 | // MARK: - Lazy Load 95 | 96 | private lazy var commentLabel = UILabel(text: "评论", textColor: GRAY, fontSize: 13) 97 | 98 | private lazy var commentNumberLabel = UILabel(text: "0", textColor: GRAY_99, fontSize: 11) 99 | 100 | private lazy var iconView: UIImageView = { 101 | let iconView = UIImageView() 102 | iconView.image = UIImage(named: "cat") 103 | return iconView 104 | }() 105 | 106 | private lazy var commentInputBackView: UIView = { 107 | let commentInputBackView = UIView() 108 | commentInputBackView.backgroundColor = RGB(r: 0xf1, g: 0xf2, b: 0xfd, alpha: 1) 109 | commentInputBackView.layer.cornerRadius = 18 110 | let tap = UITapGestureRecognizer(target: self, action: #selector(self.comment)) 111 | commentInputBackView.addGestureRecognizer(tap) 112 | return commentInputBackView 113 | }() 114 | 115 | private lazy var placeholderLabel = UILabel(text: "说点什么吧!", textColor: GRAY_99, fontSize: 13) 116 | 117 | } 118 | -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/View/YZVideoToolBar.swift: -------------------------------------------------------------------------------- 1 | // 2 | // YZVideoToolBar.swift 3 | // Mov 4 | // 5 | // Created by heyuze on 2016/11/24. 6 | // Copyright © 2016年 heyuze. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class YZVideoToolBar: UIView { 12 | 13 | // MARK: - init 14 | 15 | override init(frame: CGRect) { 16 | super.init(frame: frame) 17 | 18 | setupUI() 19 | } 20 | 21 | required init?(coder aDecoder: NSCoder) { 22 | fatalError("init(coder:) has not been implemented") 23 | } 24 | 25 | 26 | // MARK: - Set up 27 | 28 | private func setupUI() { 29 | backgroundColor = WHITE 30 | 31 | addSubview(likeBtn) 32 | addSubview(commentBtn) 33 | addSubview(shareBtn) 34 | addSubview(reportBtn) 35 | 36 | likeBtn.snp.makeConstraints { (make) in 37 | make.leading.equalTo(self).offset(5) 38 | make.centerY.equalTo(self) 39 | make.width.height.equalTo(40) 40 | } 41 | commentBtn.snp.makeConstraints { (make) in 42 | make.leading.equalTo(likeBtn.snp.trailing).offset(5) 43 | make.centerY.equalTo(self) 44 | make.width.height.equalTo(40) 45 | } 46 | shareBtn.snp.makeConstraints { (make) in 47 | make.leading.equalTo(commentBtn.snp.trailing).offset(5) 48 | make.centerY.equalTo(self) 49 | make.width.height.equalTo(40) 50 | } 51 | reportBtn.snp.makeConstraints { (make) in 52 | make.trailing.equalTo(self).offset(-5) 53 | make.centerY.equalTo(self) 54 | make.width.height.equalTo(40) 55 | } 56 | 57 | let lineView = UIView() 58 | lineView.backgroundColor = BACKGROUND_COLOR 59 | addSubview(lineView) 60 | lineView.snp.makeConstraints { (make) in 61 | make.leading.bottom.trailing.equalTo(self) 62 | make.height.equalTo(0.5) 63 | } 64 | } 65 | 66 | 67 | // MARK: - Action 68 | 69 | @objc private func clickLikeBtn() { 70 | 71 | } 72 | 73 | @objc private func clickCommentBtn() { 74 | 75 | } 76 | 77 | @objc private func clickShareBtn() { 78 | 79 | } 80 | 81 | @objc private func clickReportBtn() { 82 | 83 | } 84 | 85 | 86 | // MARK: - Lazy load 87 | 88 | private lazy var likeBtn: UIButton = { 89 | let likeBtn = UIButton() 90 | likeBtn.setImage(UIImage(named: "video_like"), for: .normal) 91 | likeBtn.addTarget(self, action: #selector(self.clickLikeBtn), for: .touchUpInside) 92 | return likeBtn 93 | }() 94 | 95 | private lazy var commentBtn: UIButton = { 96 | let commentBtn = UIButton() 97 | commentBtn.setImage(UIImage(named: "video_comment1"), for: .normal) 98 | commentBtn.addTarget(self, action: #selector(self.clickCommentBtn), for: .touchUpInside) 99 | return commentBtn 100 | }() 101 | 102 | private lazy var shareBtn: UIButton = { 103 | let shareBtn = UIButton() 104 | shareBtn.setImage(UIImage(named: "video_share"), for: .normal) 105 | shareBtn.addTarget(self, action: #selector(self.clickShareBtn), for: .touchUpInside) 106 | return shareBtn 107 | }() 108 | 109 | private lazy var reportBtn: UIButton = { 110 | let reportBtn = UIButton() 111 | reportBtn.setImage(UIImage(named: "video_report"), for: .normal) 112 | reportBtn.addTarget(self, action: #selector(self.clickReportBtn), for: .touchUpInside) 113 | return reportBtn 114 | }() 115 | 116 | } 117 | -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/ViewModel/YZVideoListViewModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // YZVideoListViewModel.swift 3 | // YZPlayerDemo 4 | // 5 | // Created by heyuze on 2017/5/12. 6 | // Copyright © 2017年 heyuze. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class YZVideoListViewModel: NSObject { 12 | 13 | // video 数组 14 | var videoArr = [YZDemoVideo]() 15 | 16 | // 初始化数据 17 | func setupData(success: ()->Void) { 18 | let path = Bundle.main.bundlePath 19 | let filePath = path+"/video" 20 | 21 | do { 22 | let data = try! Data(contentsOf: URL(fileURLWithPath: filePath)) 23 | let dataDict = try JSONSerialization.jsonObject(with: data, options: .mutableContainers) as! [String : Any] 24 | // print(dataDict) 25 | 26 | let dataArray = dataDict["data"] as! Array<[String : Any]> 27 | for dict in dataArray { 28 | let video = YZDemoVideo(dict: dict) 29 | videoArr.append(video) 30 | } 31 | success() 32 | } catch { 33 | print(error) 34 | } 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemo/YZPlayerDemo-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | // 2 | // YYPlayerDemo-Bridging-Header.h 3 | // YZPlayerDemo 4 | // 5 | // Created by heyuze on 2017/5/12. 6 | // Copyright © 2017年 heyuze. All rights reserved. 7 | // 8 | 9 | #import "YYWebImage.h" 10 | #import "MJRefresh.h" 11 | -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemoTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /YZPlayerDemo/YZPlayerDemoTests/YZPlayerDemoTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // YZPlayerDemoTests.swift 3 | // YZPlayerDemoTests 4 | // 5 | // Created by heyuze on 2017/5/12. 6 | // Copyright © 2017年 heyuze. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | @testable import YZPlayerDemo 11 | 12 | class YZPlayerDemoTests: XCTestCase { 13 | 14 | override func setUp() { 15 | super.setUp() 16 | // Put setup code here. This method is called before the invocation of each test method in the class. 17 | } 18 | 19 | override func tearDown() { 20 | // Put teardown code here. This method is called after the invocation of each test method in the class. 21 | super.tearDown() 22 | } 23 | 24 | func testExample() { 25 | // This is an example of a functional test case. 26 | // Use XCTAssert and related functions to verify your tests produce the correct results. 27 | } 28 | 29 | func testPerformanceExample() { 30 | // This is an example of a performance test case. 31 | self.measure { 32 | // Put the code you want to measure the time of here. 33 | } 34 | } 35 | 36 | } 37 | --------------------------------------------------------------------------------