├── .gitignore ├── README.md ├── VideoPlayer.xcodeproj └── project.pbxproj ├── VideoPlayer ├── AppDelegate.swift ├── Base.lproj │ ├── LaunchScreen.xib │ └── Main.storyboard ├── FirstViewController.swift ├── Images.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json ├── Info.plist ├── SecondViewController.swift ├── ThirdViewController.swift └── hogevideo.mov └── VideoPlayerTests ├── Info.plist └── VideoPlayerTests.swift /.gitignore: -------------------------------------------------------------------------------- 1 | *.xcodeproj/* 2 | !*.xcodeproj/project.pbxproj 3 | *.xcworkspace 4 | .DS_Store 5 | VideoPlayer/Pods/* 6 | 7 | 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # VideoPlayerSample 2 | ## About 3 | Swiftビギナーズ勉強会 第7回 でのAVPlayerViewController説明用です。 4 | 5 | ## VideoPlayer project 6 | 1. 動画を全画面表示 (AVPlayerViewControllerをStoryboardで配置) 7 | 2. 動画を画面の中に埋め込んで表示 (AVPlayerViewControllerをコードで生成) 8 | 9 | -------------------------------------------------------------------------------- /VideoPlayer.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 421B525C1AFC4978008A4A1B /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 421B525B1AFC4978008A4A1B /* AppDelegate.swift */; }; 11 | 421B525E1AFC4978008A4A1B /* ThirdViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 421B525D1AFC4978008A4A1B /* ThirdViewController.swift */; }; 12 | 421B52611AFC4978008A4A1B /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 421B525F1AFC4978008A4A1B /* Main.storyboard */; }; 13 | 421B52631AFC4978008A4A1B /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 421B52621AFC4978008A4A1B /* Images.xcassets */; }; 14 | 421B52661AFC4978008A4A1B /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 421B52641AFC4978008A4A1B /* LaunchScreen.xib */; }; 15 | 421B52721AFC4978008A4A1B /* VideoPlayerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 421B52711AFC4978008A4A1B /* VideoPlayerTests.swift */; }; 16 | 4252BB9E1AFC6191008B7DA3 /* FirstViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4252BB9D1AFC6191008B7DA3 /* FirstViewController.swift */; }; 17 | 4252BBA01AFC622E008B7DA3 /* SecondViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4252BB9F1AFC622E008B7DA3 /* SecondViewController.swift */; }; 18 | 42C919B2206CBC770088893D /* hogevideo.mov in Resources */ = {isa = PBXBuildFile; fileRef = 42C919B1206CBC770088893D /* hogevideo.mov */; }; 19 | /* End PBXBuildFile section */ 20 | 21 | /* Begin PBXContainerItemProxy section */ 22 | 421B526C1AFC4978008A4A1B /* PBXContainerItemProxy */ = { 23 | isa = PBXContainerItemProxy; 24 | containerPortal = 421B524E1AFC4978008A4A1B /* Project object */; 25 | proxyType = 1; 26 | remoteGlobalIDString = 421B52551AFC4978008A4A1B; 27 | remoteInfo = VideoPlayer; 28 | }; 29 | /* End PBXContainerItemProxy section */ 30 | 31 | /* Begin PBXFileReference section */ 32 | 421B52561AFC4978008A4A1B /* VideoPlayer.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = VideoPlayer.app; sourceTree = BUILT_PRODUCTS_DIR; }; 33 | 421B525A1AFC4978008A4A1B /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 34 | 421B525B1AFC4978008A4A1B /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 35 | 421B525D1AFC4978008A4A1B /* ThirdViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThirdViewController.swift; sourceTree = ""; }; 36 | 421B52601AFC4978008A4A1B /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 37 | 421B52621AFC4978008A4A1B /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 38 | 421B52651AFC4978008A4A1B /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; }; 39 | 421B526B1AFC4978008A4A1B /* VideoPlayerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = VideoPlayerTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 40 | 421B52701AFC4978008A4A1B /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 41 | 421B52711AFC4978008A4A1B /* VideoPlayerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VideoPlayerTests.swift; sourceTree = ""; }; 42 | 4252BB9D1AFC6191008B7DA3 /* FirstViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FirstViewController.swift; sourceTree = ""; }; 43 | 4252BB9F1AFC622E008B7DA3 /* SecondViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SecondViewController.swift; sourceTree = ""; }; 44 | 42C919B1206CBC770088893D /* hogevideo.mov */ = {isa = PBXFileReference; lastKnownFileType = video.quicktime; path = hogevideo.mov; sourceTree = ""; }; 45 | /* End PBXFileReference section */ 46 | 47 | /* Begin PBXFrameworksBuildPhase section */ 48 | 421B52531AFC4978008A4A1B /* Frameworks */ = { 49 | isa = PBXFrameworksBuildPhase; 50 | buildActionMask = 2147483647; 51 | files = ( 52 | ); 53 | runOnlyForDeploymentPostprocessing = 0; 54 | }; 55 | 421B52681AFC4978008A4A1B /* Frameworks */ = { 56 | isa = PBXFrameworksBuildPhase; 57 | buildActionMask = 2147483647; 58 | files = ( 59 | ); 60 | runOnlyForDeploymentPostprocessing = 0; 61 | }; 62 | /* End PBXFrameworksBuildPhase section */ 63 | 64 | /* Begin PBXGroup section */ 65 | 421B524D1AFC4978008A4A1B = { 66 | isa = PBXGroup; 67 | children = ( 68 | 421B52581AFC4978008A4A1B /* VideoPlayer */, 69 | 421B526E1AFC4978008A4A1B /* VideoPlayerTests */, 70 | 421B52571AFC4978008A4A1B /* Products */, 71 | ); 72 | sourceTree = ""; 73 | }; 74 | 421B52571AFC4978008A4A1B /* Products */ = { 75 | isa = PBXGroup; 76 | children = ( 77 | 421B52561AFC4978008A4A1B /* VideoPlayer.app */, 78 | 421B526B1AFC4978008A4A1B /* VideoPlayerTests.xctest */, 79 | ); 80 | name = Products; 81 | sourceTree = ""; 82 | }; 83 | 421B52581AFC4978008A4A1B /* VideoPlayer */ = { 84 | isa = PBXGroup; 85 | children = ( 86 | 421B525B1AFC4978008A4A1B /* AppDelegate.swift */, 87 | 4252BB9D1AFC6191008B7DA3 /* FirstViewController.swift */, 88 | 4252BB9F1AFC622E008B7DA3 /* SecondViewController.swift */, 89 | 421B525D1AFC4978008A4A1B /* ThirdViewController.swift */, 90 | 421B525F1AFC4978008A4A1B /* Main.storyboard */, 91 | 421B52621AFC4978008A4A1B /* Images.xcassets */, 92 | 421B52641AFC4978008A4A1B /* LaunchScreen.xib */, 93 | 421B52591AFC4978008A4A1B /* Supporting Files */, 94 | ); 95 | path = VideoPlayer; 96 | sourceTree = ""; 97 | }; 98 | 421B52591AFC4978008A4A1B /* Supporting Files */ = { 99 | isa = PBXGroup; 100 | children = ( 101 | 42C919B1206CBC770088893D /* hogevideo.mov */, 102 | 421B525A1AFC4978008A4A1B /* Info.plist */, 103 | ); 104 | name = "Supporting Files"; 105 | sourceTree = ""; 106 | }; 107 | 421B526E1AFC4978008A4A1B /* VideoPlayerTests */ = { 108 | isa = PBXGroup; 109 | children = ( 110 | 421B52711AFC4978008A4A1B /* VideoPlayerTests.swift */, 111 | 421B526F1AFC4978008A4A1B /* Supporting Files */, 112 | ); 113 | path = VideoPlayerTests; 114 | sourceTree = ""; 115 | }; 116 | 421B526F1AFC4978008A4A1B /* Supporting Files */ = { 117 | isa = PBXGroup; 118 | children = ( 119 | 421B52701AFC4978008A4A1B /* Info.plist */, 120 | ); 121 | name = "Supporting Files"; 122 | sourceTree = ""; 123 | }; 124 | /* End PBXGroup section */ 125 | 126 | /* Begin PBXNativeTarget section */ 127 | 421B52551AFC4978008A4A1B /* VideoPlayer */ = { 128 | isa = PBXNativeTarget; 129 | buildConfigurationList = 421B52751AFC4978008A4A1B /* Build configuration list for PBXNativeTarget "VideoPlayer" */; 130 | buildPhases = ( 131 | 421B52521AFC4978008A4A1B /* Sources */, 132 | 421B52531AFC4978008A4A1B /* Frameworks */, 133 | 421B52541AFC4978008A4A1B /* Resources */, 134 | ); 135 | buildRules = ( 136 | ); 137 | dependencies = ( 138 | ); 139 | name = VideoPlayer; 140 | productName = VideoPlayer; 141 | productReference = 421B52561AFC4978008A4A1B /* VideoPlayer.app */; 142 | productType = "com.apple.product-type.application"; 143 | }; 144 | 421B526A1AFC4978008A4A1B /* VideoPlayerTests */ = { 145 | isa = PBXNativeTarget; 146 | buildConfigurationList = 421B52781AFC4978008A4A1B /* Build configuration list for PBXNativeTarget "VideoPlayerTests" */; 147 | buildPhases = ( 148 | 421B52671AFC4978008A4A1B /* Sources */, 149 | 421B52681AFC4978008A4A1B /* Frameworks */, 150 | 421B52691AFC4978008A4A1B /* Resources */, 151 | ); 152 | buildRules = ( 153 | ); 154 | dependencies = ( 155 | 421B526D1AFC4978008A4A1B /* PBXTargetDependency */, 156 | ); 157 | name = VideoPlayerTests; 158 | productName = VideoPlayerTests; 159 | productReference = 421B526B1AFC4978008A4A1B /* VideoPlayerTests.xctest */; 160 | productType = "com.apple.product-type.bundle.unit-test"; 161 | }; 162 | /* End PBXNativeTarget section */ 163 | 164 | /* Begin PBXProject section */ 165 | 421B524E1AFC4978008A4A1B /* Project object */ = { 166 | isa = PBXProject; 167 | attributes = { 168 | LastSwiftUpdateCheck = 0720; 169 | LastUpgradeCheck = 0920; 170 | ORGANIZATIONNAME = Trabal; 171 | TargetAttributes = { 172 | 421B52551AFC4978008A4A1B = { 173 | CreatedOnToolsVersion = 6.3.1; 174 | }; 175 | 421B526A1AFC4978008A4A1B = { 176 | CreatedOnToolsVersion = 6.3.1; 177 | TestTargetID = 421B52551AFC4978008A4A1B; 178 | }; 179 | }; 180 | }; 181 | buildConfigurationList = 421B52511AFC4978008A4A1B /* Build configuration list for PBXProject "VideoPlayer" */; 182 | compatibilityVersion = "Xcode 3.2"; 183 | developmentRegion = English; 184 | hasScannedForEncodings = 0; 185 | knownRegions = ( 186 | en, 187 | Base, 188 | ); 189 | mainGroup = 421B524D1AFC4978008A4A1B; 190 | productRefGroup = 421B52571AFC4978008A4A1B /* Products */; 191 | projectDirPath = ""; 192 | projectRoot = ""; 193 | targets = ( 194 | 421B52551AFC4978008A4A1B /* VideoPlayer */, 195 | 421B526A1AFC4978008A4A1B /* VideoPlayerTests */, 196 | ); 197 | }; 198 | /* End PBXProject section */ 199 | 200 | /* Begin PBXResourcesBuildPhase section */ 201 | 421B52541AFC4978008A4A1B /* Resources */ = { 202 | isa = PBXResourcesBuildPhase; 203 | buildActionMask = 2147483647; 204 | files = ( 205 | 421B52611AFC4978008A4A1B /* Main.storyboard in Resources */, 206 | 421B52661AFC4978008A4A1B /* LaunchScreen.xib in Resources */, 207 | 421B52631AFC4978008A4A1B /* Images.xcassets in Resources */, 208 | 42C919B2206CBC770088893D /* hogevideo.mov in Resources */, 209 | ); 210 | runOnlyForDeploymentPostprocessing = 0; 211 | }; 212 | 421B52691AFC4978008A4A1B /* Resources */ = { 213 | isa = PBXResourcesBuildPhase; 214 | buildActionMask = 2147483647; 215 | files = ( 216 | ); 217 | runOnlyForDeploymentPostprocessing = 0; 218 | }; 219 | /* End PBXResourcesBuildPhase section */ 220 | 221 | /* Begin PBXSourcesBuildPhase section */ 222 | 421B52521AFC4978008A4A1B /* Sources */ = { 223 | isa = PBXSourcesBuildPhase; 224 | buildActionMask = 2147483647; 225 | files = ( 226 | 4252BB9E1AFC6191008B7DA3 /* FirstViewController.swift in Sources */, 227 | 421B525E1AFC4978008A4A1B /* ThirdViewController.swift in Sources */, 228 | 4252BBA01AFC622E008B7DA3 /* SecondViewController.swift in Sources */, 229 | 421B525C1AFC4978008A4A1B /* AppDelegate.swift in Sources */, 230 | ); 231 | runOnlyForDeploymentPostprocessing = 0; 232 | }; 233 | 421B52671AFC4978008A4A1B /* Sources */ = { 234 | isa = PBXSourcesBuildPhase; 235 | buildActionMask = 2147483647; 236 | files = ( 237 | 421B52721AFC4978008A4A1B /* VideoPlayerTests.swift in Sources */, 238 | ); 239 | runOnlyForDeploymentPostprocessing = 0; 240 | }; 241 | /* End PBXSourcesBuildPhase section */ 242 | 243 | /* Begin PBXTargetDependency section */ 244 | 421B526D1AFC4978008A4A1B /* PBXTargetDependency */ = { 245 | isa = PBXTargetDependency; 246 | target = 421B52551AFC4978008A4A1B /* VideoPlayer */; 247 | targetProxy = 421B526C1AFC4978008A4A1B /* PBXContainerItemProxy */; 248 | }; 249 | /* End PBXTargetDependency section */ 250 | 251 | /* Begin PBXVariantGroup section */ 252 | 421B525F1AFC4978008A4A1B /* Main.storyboard */ = { 253 | isa = PBXVariantGroup; 254 | children = ( 255 | 421B52601AFC4978008A4A1B /* Base */, 256 | ); 257 | name = Main.storyboard; 258 | sourceTree = ""; 259 | }; 260 | 421B52641AFC4978008A4A1B /* LaunchScreen.xib */ = { 261 | isa = PBXVariantGroup; 262 | children = ( 263 | 421B52651AFC4978008A4A1B /* Base */, 264 | ); 265 | name = LaunchScreen.xib; 266 | sourceTree = ""; 267 | }; 268 | /* End PBXVariantGroup section */ 269 | 270 | /* Begin XCBuildConfiguration section */ 271 | 421B52731AFC4978008A4A1B /* Debug */ = { 272 | isa = XCBuildConfiguration; 273 | buildSettings = { 274 | ALWAYS_SEARCH_USER_PATHS = NO; 275 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 276 | CLANG_CXX_LIBRARY = "libc++"; 277 | CLANG_ENABLE_MODULES = YES; 278 | CLANG_ENABLE_OBJC_ARC = YES; 279 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 280 | CLANG_WARN_BOOL_CONVERSION = YES; 281 | CLANG_WARN_COMMA = YES; 282 | CLANG_WARN_CONSTANT_CONVERSION = YES; 283 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 284 | CLANG_WARN_EMPTY_BODY = YES; 285 | CLANG_WARN_ENUM_CONVERSION = YES; 286 | CLANG_WARN_INFINITE_RECURSION = YES; 287 | CLANG_WARN_INT_CONVERSION = YES; 288 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 289 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 290 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 291 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 292 | CLANG_WARN_STRICT_PROTOTYPES = YES; 293 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 294 | CLANG_WARN_UNREACHABLE_CODE = YES; 295 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 296 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 297 | COPY_PHASE_STRIP = NO; 298 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 299 | ENABLE_STRICT_OBJC_MSGSEND = YES; 300 | ENABLE_TESTABILITY = YES; 301 | GCC_C_LANGUAGE_STANDARD = gnu99; 302 | GCC_DYNAMIC_NO_PIC = NO; 303 | GCC_NO_COMMON_BLOCKS = YES; 304 | GCC_OPTIMIZATION_LEVEL = 0; 305 | GCC_PREPROCESSOR_DEFINITIONS = ( 306 | "DEBUG=1", 307 | "$(inherited)", 308 | ); 309 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 310 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 311 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 312 | GCC_WARN_UNDECLARED_SELECTOR = YES; 313 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 314 | GCC_WARN_UNUSED_FUNCTION = YES; 315 | GCC_WARN_UNUSED_VARIABLE = YES; 316 | IPHONEOS_DEPLOYMENT_TARGET = 8.3; 317 | MTL_ENABLE_DEBUG_INFO = YES; 318 | ONLY_ACTIVE_ARCH = YES; 319 | SDKROOT = iphoneos; 320 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 321 | TARGETED_DEVICE_FAMILY = "1,2"; 322 | }; 323 | name = Debug; 324 | }; 325 | 421B52741AFC4978008A4A1B /* Release */ = { 326 | isa = XCBuildConfiguration; 327 | buildSettings = { 328 | ALWAYS_SEARCH_USER_PATHS = NO; 329 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 330 | CLANG_CXX_LIBRARY = "libc++"; 331 | CLANG_ENABLE_MODULES = YES; 332 | CLANG_ENABLE_OBJC_ARC = YES; 333 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 334 | CLANG_WARN_BOOL_CONVERSION = YES; 335 | CLANG_WARN_COMMA = YES; 336 | CLANG_WARN_CONSTANT_CONVERSION = YES; 337 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 338 | CLANG_WARN_EMPTY_BODY = YES; 339 | CLANG_WARN_ENUM_CONVERSION = YES; 340 | CLANG_WARN_INFINITE_RECURSION = YES; 341 | CLANG_WARN_INT_CONVERSION = YES; 342 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 343 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 344 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 345 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 346 | CLANG_WARN_STRICT_PROTOTYPES = YES; 347 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 348 | CLANG_WARN_UNREACHABLE_CODE = YES; 349 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 350 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 351 | COPY_PHASE_STRIP = NO; 352 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 353 | ENABLE_NS_ASSERTIONS = NO; 354 | ENABLE_STRICT_OBJC_MSGSEND = YES; 355 | GCC_C_LANGUAGE_STANDARD = gnu99; 356 | GCC_NO_COMMON_BLOCKS = YES; 357 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 358 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 359 | GCC_WARN_UNDECLARED_SELECTOR = YES; 360 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 361 | GCC_WARN_UNUSED_FUNCTION = YES; 362 | GCC_WARN_UNUSED_VARIABLE = YES; 363 | IPHONEOS_DEPLOYMENT_TARGET = 8.3; 364 | MTL_ENABLE_DEBUG_INFO = NO; 365 | SDKROOT = iphoneos; 366 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 367 | TARGETED_DEVICE_FAMILY = "1,2"; 368 | VALIDATE_PRODUCT = YES; 369 | }; 370 | name = Release; 371 | }; 372 | 421B52761AFC4978008A4A1B /* Debug */ = { 373 | isa = XCBuildConfiguration; 374 | buildSettings = { 375 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 376 | DEVELOPMENT_TEAM = ""; 377 | INFOPLIST_FILE = VideoPlayer/Info.plist; 378 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 379 | PRODUCT_BUNDLE_IDENTIFIER = "Trabal.$(PRODUCT_NAME:rfc1034identifier)"; 380 | PRODUCT_NAME = "$(TARGET_NAME)"; 381 | SWIFT_VERSION = 4.0; 382 | }; 383 | name = Debug; 384 | }; 385 | 421B52771AFC4978008A4A1B /* Release */ = { 386 | isa = XCBuildConfiguration; 387 | buildSettings = { 388 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 389 | DEVELOPMENT_TEAM = ""; 390 | INFOPLIST_FILE = VideoPlayer/Info.plist; 391 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 392 | PRODUCT_BUNDLE_IDENTIFIER = "Trabal.$(PRODUCT_NAME:rfc1034identifier)"; 393 | PRODUCT_NAME = "$(TARGET_NAME)"; 394 | SWIFT_VERSION = 4.0; 395 | }; 396 | name = Release; 397 | }; 398 | 421B52791AFC4978008A4A1B /* Debug */ = { 399 | isa = XCBuildConfiguration; 400 | buildSettings = { 401 | BUNDLE_LOADER = "$(TEST_HOST)"; 402 | FRAMEWORK_SEARCH_PATHS = ( 403 | "$(SDKROOT)/Developer/Library/Frameworks", 404 | "$(inherited)", 405 | ); 406 | GCC_PREPROCESSOR_DEFINITIONS = ( 407 | "DEBUG=1", 408 | "$(inherited)", 409 | ); 410 | INFOPLIST_FILE = VideoPlayerTests/Info.plist; 411 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 412 | PRODUCT_BUNDLE_IDENTIFIER = "Trabal.$(PRODUCT_NAME:rfc1034identifier)"; 413 | PRODUCT_NAME = "$(TARGET_NAME)"; 414 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/VideoPlayer.app/VideoPlayer"; 415 | }; 416 | name = Debug; 417 | }; 418 | 421B527A1AFC4978008A4A1B /* Release */ = { 419 | isa = XCBuildConfiguration; 420 | buildSettings = { 421 | BUNDLE_LOADER = "$(TEST_HOST)"; 422 | FRAMEWORK_SEARCH_PATHS = ( 423 | "$(SDKROOT)/Developer/Library/Frameworks", 424 | "$(inherited)", 425 | ); 426 | INFOPLIST_FILE = VideoPlayerTests/Info.plist; 427 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 428 | PRODUCT_BUNDLE_IDENTIFIER = "Trabal.$(PRODUCT_NAME:rfc1034identifier)"; 429 | PRODUCT_NAME = "$(TARGET_NAME)"; 430 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/VideoPlayer.app/VideoPlayer"; 431 | }; 432 | name = Release; 433 | }; 434 | /* End XCBuildConfiguration section */ 435 | 436 | /* Begin XCConfigurationList section */ 437 | 421B52511AFC4978008A4A1B /* Build configuration list for PBXProject "VideoPlayer" */ = { 438 | isa = XCConfigurationList; 439 | buildConfigurations = ( 440 | 421B52731AFC4978008A4A1B /* Debug */, 441 | 421B52741AFC4978008A4A1B /* Release */, 442 | ); 443 | defaultConfigurationIsVisible = 0; 444 | defaultConfigurationName = Release; 445 | }; 446 | 421B52751AFC4978008A4A1B /* Build configuration list for PBXNativeTarget "VideoPlayer" */ = { 447 | isa = XCConfigurationList; 448 | buildConfigurations = ( 449 | 421B52761AFC4978008A4A1B /* Debug */, 450 | 421B52771AFC4978008A4A1B /* Release */, 451 | ); 452 | defaultConfigurationIsVisible = 0; 453 | defaultConfigurationName = Release; 454 | }; 455 | 421B52781AFC4978008A4A1B /* Build configuration list for PBXNativeTarget "VideoPlayerTests" */ = { 456 | isa = XCConfigurationList; 457 | buildConfigurations = ( 458 | 421B52791AFC4978008A4A1B /* Debug */, 459 | 421B527A1AFC4978008A4A1B /* Release */, 460 | ); 461 | defaultConfigurationIsVisible = 0; 462 | defaultConfigurationName = Release; 463 | }; 464 | /* End XCConfigurationList section */ 465 | }; 466 | rootObject = 421B524E1AFC4978008A4A1B /* Project object */; 467 | } 468 | -------------------------------------------------------------------------------- /VideoPlayer/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // VideoPlayer 4 | // 5 | // Created by Ary on 2015/05/08. 6 | // Copyright (c) 2015年 Trabal. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | 17 | private func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { 18 | // Override point for customization after application launch. 19 | return true 20 | } 21 | 22 | func applicationWillResignActive(_ application: UIApplication) { 23 | // 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. 24 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 25 | } 26 | 27 | func applicationDidEnterBackground(_ application: UIApplication) { 28 | // 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. 29 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 30 | } 31 | 32 | func applicationWillEnterForeground(_ application: UIApplication) { 33 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 34 | } 35 | 36 | func applicationDidBecomeActive(_ application: UIApplication) { 37 | // 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. 38 | } 39 | 40 | func applicationWillTerminate(_ application: UIApplication) { 41 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 42 | } 43 | 44 | 45 | } 46 | 47 | -------------------------------------------------------------------------------- /VideoPlayer/Base.lproj/LaunchScreen.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 20 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /VideoPlayer/Base.lproj/Main.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 | 34 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | -------------------------------------------------------------------------------- /VideoPlayer/FirstViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // FirstViewController.swift 3 | // VideoPlayer 4 | // 5 | // Created by Ary on 2015/05/08. 6 | // Copyright (c) 2015年 Trabal. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class FirstViewController: UIViewController { 12 | 13 | override func viewDidLoad() { 14 | super.viewDidLoad() 15 | 16 | // Do any additional setup after loading the view. 17 | } 18 | 19 | override func didReceiveMemoryWarning() { 20 | super.didReceiveMemoryWarning() 21 | // Dispose of any resources that can be recreated. 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /VideoPlayer/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "20x20", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "20x20", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "29x29", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "29x29", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "40x40", 66 | "scale" : "1x" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "size" : "40x40", 71 | "scale" : "2x" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "size" : "76x76", 76 | "scale" : "1x" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "size" : "76x76", 81 | "scale" : "2x" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "size" : "83.5x83.5", 86 | "scale" : "2x" 87 | }, 88 | { 89 | "idiom" : "ios-marketing", 90 | "size" : "1024x1024", 91 | "scale" : "1x" 92 | } 93 | ], 94 | "info" : { 95 | "version" : 1, 96 | "author" : "xcode" 97 | } 98 | } -------------------------------------------------------------------------------- /VideoPlayer/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 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | UISupportedInterfaceOrientations~ipad 40 | 41 | UIInterfaceOrientationPortrait 42 | UIInterfaceOrientationPortraitUpsideDown 43 | UIInterfaceOrientationLandscapeLeft 44 | UIInterfaceOrientationLandscapeRight 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /VideoPlayer/SecondViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SecondViewController.swift 3 | // VideoPlayer 4 | // 5 | // Created by Ary on 2015/05/08. 6 | // Copyright (c) 2015年 Trabal. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import AVFoundation 11 | import AVKit 12 | 13 | class SecondViewController: AVPlayerViewController { 14 | 15 | override func viewDidLoad() { 16 | super.viewDidLoad() 17 | 18 | // 動画ファイルのURLを取得 19 | let moviePath = Bundle.main.path(forResource: "hogevideo", ofType: "mov")! 20 | let url = URL(fileURLWithPath: moviePath) 21 | 22 | // アイテム取得 23 | let playerItem = AVPlayerItem.init(url: url) 24 | 25 | // 生成 26 | player = AVPlayer(playerItem: playerItem) 27 | 28 | // 再生 29 | player?.play() 30 | } 31 | 32 | override func didReceiveMemoryWarning() { 33 | super.didReceiveMemoryWarning() 34 | // Dispose of any resources that can be recreated. 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /VideoPlayer/ThirdViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ThirdViewController.swift 3 | // VideoPlayer 4 | // 5 | // Created by Ary on 2015/05/08. 6 | // Copyright (c) 2015年 Trabal. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import AVFoundation 11 | import AVKit 12 | 13 | class ThirdViewController: UIViewController { 14 | 15 | var playerViewController: AVPlayerViewController! 16 | 17 | override func viewDidLoad() { 18 | super.viewDidLoad() 19 | 20 | // 動画ファイルのURLを取得 21 | let bundle = Bundle.main 22 | let path = bundle.path(forResource: "hogevideo", ofType: "mov") 23 | let url = URL(fileURLWithPath: path!) 24 | 25 | // アイテム取得 26 | let playerItem = AVPlayerItem.init(url: url) 27 | 28 | // 生成 29 | let player = AVPlayer(playerItem: playerItem) 30 | playerViewController = AVPlayerViewController() 31 | playerViewController.player = player 32 | 33 | // 設定 34 | playerViewController.view.frame = CGRect(x: 54, y: 96, width: view.bounds.width - 108, height: view.bounds.height - 192) 35 | playerViewController.showsPlaybackControls = true // 操作パネルを非表示にする場合はfalse 36 | playerViewController.videoGravity = AVLayerVideoGravity.resizeAspect.rawValue // 矩形にフィット 37 | 38 | // 通知登録 39 | NotificationCenter.default.addObserver(self, selector: #selector(didPlayerItemReachEnd), name: NSNotification.Name.AVPlayerItemDidPlayToEndTime, object: nil) 40 | 41 | // 表示 42 | view.addSubview(playerViewController.view) 43 | 44 | // 再生 45 | player.play() 46 | } 47 | 48 | @objc func didPlayerItemReachEnd(notification: NSNotification) { 49 | guard let player = playerViewController.player else { 50 | return 51 | } 52 | // リピート再生 53 | player.seek(to: kCMTimeZero) 54 | player.play() 55 | } 56 | 57 | override func didReceiveMemoryWarning() { 58 | super.didReceiveMemoryWarning() 59 | // Dispose of any resources that can be recreated. 60 | } 61 | 62 | } 63 | 64 | -------------------------------------------------------------------------------- /VideoPlayer/hogevideo.mov: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ariiyu/VideoPlayerSample/4383122a2c227eb58526acdeb9ecf3c61c57ee6f/VideoPlayer/hogevideo.mov -------------------------------------------------------------------------------- /VideoPlayerTests/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 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /VideoPlayerTests/VideoPlayerTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // VideoPlayerTests.swift 3 | // VideoPlayerTests 4 | // 5 | // Created by Ary on 2015/05/08. 6 | // Copyright (c) 2015年 Trabal. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import XCTest 11 | 12 | class VideoPlayerTests: 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 | XCTAssert(true, "Pass") 27 | } 28 | 29 | func testPerformanceExample() { 30 | // This is an example of a performance test case. 31 | self.measureBlock() { 32 | // Put the code you want to measure the time of here. 33 | } 34 | } 35 | 36 | } 37 | --------------------------------------------------------------------------------