diff --git a/Swift/VideoStitcherExample/Podfile b/Swift/VideoStitcherExample/Podfile new file mode 100755 index 0000000..3fd4600 --- /dev/null +++ b/Swift/VideoStitcherExample/Podfile @@ -0,0 +1,8 @@ +source 'https://github.com/CocoaPods/Specs.git' + +platform :tvos, '17' +project 'VideoStitcherExample.xcodeproj' + +target "VideoStitcherExample" do + pod 'GoogleAds-IMA-tvOS-SDK' +end diff --git a/Swift/VideoStitcherExample/VideoStitcherExample.xcodeproj/project.pbxproj b/Swift/VideoStitcherExample/VideoStitcherExample.xcodeproj/project.pbxproj new file mode 100644 index 0000000..51463cb --- /dev/null +++ b/Swift/VideoStitcherExample/VideoStitcherExample.xcodeproj/project.pbxproj @@ -0,0 +1,385 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 51; + objects = { + +/* Begin PBXBuildFile section */ + C7B0262FB6644A3ABE00B648 /* libPods-VideoStitcherExample.a in Frameworks */ = {isa = PBXBuildFile; fileRef = A7EDE97B02BE38F086895B4E /* libPods-VideoStitcherExample.a */; }; + D21414D725755FA90019940F /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = D21414D625755FA90019940F /* AppDelegate.swift */; }; + D21414D925755FA90019940F /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D21414D825755FA90019940F /* ViewController.swift */; }; + D21414DE25755FAA0019940F /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = D21414DD25755FAA0019940F /* Assets.xcassets */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + A7EDE97B02BE38F086895B4E /* libPods-VideoStitcherExample.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-VideoStitcherExample.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + B8F57A6FE0CFC97F17FEE6EB /* Pods-VideoStitcherExample.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-VideoStitcherExample.debug.xcconfig"; path = "Target Support Files/Pods-VideoStitcherExample/Pods-VideoStitcherExample.debug.xcconfig"; sourceTree = ""; }; + D21414D325755FA90019940F /* VideoStitcherExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = VideoStitcherExample.app; sourceTree = BUILT_PRODUCTS_DIR; }; + D21414D625755FA90019940F /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + D21414D825755FA90019940F /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; + D21414DD25755FAA0019940F /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + D21414E225755FAA0019940F /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + F84B0FECEAECB1EC6B4E23A1 /* Pods-VideoStitcherExample.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-VideoStitcherExample.release.xcconfig"; path = "Target Support Files/Pods-VideoStitcherExample/Pods-VideoStitcherExample.release.xcconfig"; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + D21414D025755FA90019940F /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + C7B0262FB6644A3ABE00B648 /* libPods-VideoStitcherExample.a in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + A14D675221A1958C9A295DF7 /* Frameworks */ = { + isa = PBXGroup; + children = ( + A7EDE97B02BE38F086895B4E /* libPods-VideoStitcherExample.a */, + ); + name = Frameworks; + sourceTree = ""; + }; + B6E36F2E97DDFE384727AD6E /* Pods */ = { + isa = PBXGroup; + children = ( + B8F57A6FE0CFC97F17FEE6EB /* Pods-VideoStitcherExample.debug.xcconfig */, + F84B0FECEAECB1EC6B4E23A1 /* Pods-VideoStitcherExample.release.xcconfig */, + ); + path = Pods; + sourceTree = ""; + }; + D21414CA25755FA90019940F = { + isa = PBXGroup; + children = ( + D21414D525755FA90019940F /* app */, + D21414D425755FA90019940F /* Products */, + B6E36F2E97DDFE384727AD6E /* Pods */, + A14D675221A1958C9A295DF7 /* Frameworks */, + ); + sourceTree = ""; + }; + D21414D425755FA90019940F /* Products */ = { + isa = PBXGroup; + children = ( + D21414D325755FA90019940F /* VideoStitcherExample.app */, + ); + name = Products; + sourceTree = ""; + }; + D21414D525755FA90019940F /* app */ = { + isa = PBXGroup; + children = ( + D21414D625755FA90019940F /* AppDelegate.swift */, + D21414D825755FA90019940F /* ViewController.swift */, + D21414DD25755FAA0019940F /* Assets.xcassets */, + D21414E225755FAA0019940F /* Info.plist */, + ); + path = app; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + D21414D225755FA90019940F /* app */ = { + isa = PBXNativeTarget; + buildConfigurationList = D21414E525755FAA0019940F /* Build configuration list for PBXNativeTarget "VideoStitcherExample" */; + buildPhases = ( + CD20F832DC7FAB06A4894496 /* [CP] Check Pods Manifest.lock */, + D21414CF25755FA90019940F /* Sources */, + D21414D025755FA90019940F /* Frameworks */, + D21414D125755FA90019940F /* Resources */, + C091F66F6F07C83FD7CABF8A /* [CP] Embed Pods Frameworks */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = VideoStitcherExample; + productName = VideoStitcherExample; + productReference = D21414D325755FA90019940F /* VideoStitcherExample.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + D21414CB25755FA90019940F /* Project object */ = { + isa = PBXProject; + attributes = { + LastSwiftUpdateCheck = 1210; + LastUpgradeCheck = 1210; + TargetAttributes = { + D21414D225755FA90019940F = { + CreatedOnToolsVersion = 12.1; + }; + }; + }; + buildConfigurationList = D21414CE25755FA90019940F /* Build configuration list for PBXProject "app" */; + compatibilityVersion = "Xcode 9.3"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = D21414CA25755FA90019940F; + productRefGroup = D21414D425755FA90019940F /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + D21414D225755FA90019940F /* VideoStitcherExample */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + D21414D125755FA90019940F /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + D21414DE25755FAA0019940F /* Assets.xcassets in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + C091F66F6F07C83FD7CABF8A /* [CP] Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-VideoStitcherExample/Pods-VideoStitcherExample-frameworks-${CONFIGURATION}-input-files.xcfilelist", + ); + name = "[CP] Embed Pods Frameworks"; + outputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-VideoStitcherExample/Pods-VideoStitcherExample-frameworks-${CONFIGURATION}-output-files.xcfilelist", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-VideoStitcherExample/Pods-VideoStitcherExample-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; + CD20F832DC7FAB06A4894496 /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", + ); + name = "[CP] Check Pods Manifest.lock"; + outputFileListPaths = ( + ); + outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-VideoStitcherExample-checkManifestLockResult.txt", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + showEnvVarsInLog = 0; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + D21414CF25755FA90019940F /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + D21414D925755FA90019940F /* ViewController.swift in Sources */, + D21414D725755FA90019940F /* AppDelegate.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + D21414E325755FAA0019940F /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = appletvos; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + TVOS_DEPLOYMENT_TARGET = 14.0; + }; + name = Debug; + }; + D21414E425755FAA0019940F /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + SDKROOT = appletvos; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + TVOS_DEPLOYMENT_TARGET = 14.0; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + D21414E625755FAA0019940F /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = B8F57A6FE0CFC97F17FEE6EB /* Pods-VideoStitcherExample.debug.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = "App Icon & Top Shelf Image"; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = Z95L3YYF93; + INFOPLIST_FILE = app/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = google.example.VideoStitcherExample; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = 3; + }; + name = Debug; + }; + D21414E725755FAA0019940F /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = F84B0FECEAECB1EC6B4E23A1 /* Pods-VideoStitcherExample.release.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = "App Icon & Top Shelf Image"; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = Z95L3YYF93; + INFOPLIST_FILE = app/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = google.example.VideoStitcherExample; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = 3; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + D21414CE25755FA90019940F /* Build configuration list for PBXProject "VideoStitcherExample" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + D21414E325755FAA0019940F /* Debug */, + D21414E425755FAA0019940F /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + D21414E525755FAA0019940F /* Build configuration list for PBXNativeTarget "VideoStitcherExample" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + D21414E625755FAA0019940F /* Debug */, + D21414E725755FAA0019940F /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = D21414CB25755FA90019940F /* Project object */; +} diff --git a/Swift/VideoStitcherExample/app/AppDelegate.swift b/Swift/VideoStitcherExample/app/AppDelegate.swift new file mode 100644 index 0000000..83a45e7 --- /dev/null +++ b/Swift/VideoStitcherExample/app/AppDelegate.swift @@ -0,0 +1,30 @@ +// Copyright 2024 Google LLC. All rights reserved. +// +// +// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this +// file except in compliance with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software distributed under +// the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF +// ANY KIND, either express or implied. See the License for the specific language governing +// permissions and limitations under the License. + +import UIKit + +@UIApplicationMain +class AppDelegate: UIResponder, UIApplicationDelegate { + + var window: UIWindow? + + func application( + _ application: UIApplication, + didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? + ) -> Bool { + window = UIWindow(frame: UIScreen.main.bounds) + window?.rootViewController = ViewController() + window?.makeKeyAndVisible() + return true + } +} diff --git a/Swift/VideoStitcherExample/app/Assets.xcassets/AccentColor.colorset/Contents.json b/Swift/VideoStitcherExample/app/Assets.xcassets/AccentColor.colorset/Contents.json new file mode 100644 index 0000000..eb87897 --- /dev/null +++ b/Swift/VideoStitcherExample/app/Assets.xcassets/AccentColor.colorset/Contents.json @@ -0,0 +1,11 @@ +{ + "colors" : [ + { + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Swift/VideoStitcherExample/app/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - App Store.imagestack/Back.imagestacklayer/Content.imageset/Contents.json b/Swift/VideoStitcherExample/app/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - App Store.imagestack/Back.imagestacklayer/Content.imageset/Contents.json new file mode 100644 index 0000000..2e00335 --- /dev/null +++ b/Swift/VideoStitcherExample/app/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - App Store.imagestack/Back.imagestacklayer/Content.imageset/Contents.json @@ -0,0 +1,11 @@ +{ + "images" : [ + { + "idiom" : "tv" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Swift/VideoStitcherExample/app/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - App Store.imagestack/Back.imagestacklayer/Contents.json b/Swift/VideoStitcherExample/app/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - App Store.imagestack/Back.imagestacklayer/Contents.json new file mode 100644 index 0000000..73c0059 --- /dev/null +++ b/Swift/VideoStitcherExample/app/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - App Store.imagestack/Back.imagestacklayer/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Swift/VideoStitcherExample/app/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - App Store.imagestack/Contents.json b/Swift/VideoStitcherExample/app/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - App Store.imagestack/Contents.json new file mode 100644 index 0000000..de59d88 --- /dev/null +++ b/Swift/VideoStitcherExample/app/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - App Store.imagestack/Contents.json @@ -0,0 +1,17 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + }, + "layers" : [ + { + "filename" : "Front.imagestacklayer" + }, + { + "filename" : "Middle.imagestacklayer" + }, + { + "filename" : "Back.imagestacklayer" + } + ] +} diff --git a/Swift/VideoStitcherExample/app/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - App Store.imagestack/Front.imagestacklayer/Content.imageset/Contents.json b/Swift/VideoStitcherExample/app/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - App Store.imagestack/Front.imagestacklayer/Content.imageset/Contents.json new file mode 100644 index 0000000..2e00335 --- /dev/null +++ b/Swift/VideoStitcherExample/app/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - App Store.imagestack/Front.imagestacklayer/Content.imageset/Contents.json @@ -0,0 +1,11 @@ +{ + "images" : [ + { + "idiom" : "tv" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Swift/VideoStitcherExample/app/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - App Store.imagestack/Front.imagestacklayer/Contents.json b/Swift/VideoStitcherExample/app/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - App Store.imagestack/Front.imagestacklayer/Contents.json new file mode 100644 index 0000000..73c0059 --- /dev/null +++ b/Swift/VideoStitcherExample/app/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - App Store.imagestack/Front.imagestacklayer/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Swift/VideoStitcherExample/app/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - App Store.imagestack/Middle.imagestacklayer/Content.imageset/Contents.json b/Swift/VideoStitcherExample/app/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - App Store.imagestack/Middle.imagestacklayer/Content.imageset/Contents.json new file mode 100644 index 0000000..2e00335 --- /dev/null +++ b/Swift/VideoStitcherExample/app/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - App Store.imagestack/Middle.imagestacklayer/Content.imageset/Contents.json @@ -0,0 +1,11 @@ +{ + "images" : [ + { + "idiom" : "tv" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Swift/VideoStitcherExample/app/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - App Store.imagestack/Middle.imagestacklayer/Contents.json b/Swift/VideoStitcherExample/app/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - App Store.imagestack/Middle.imagestacklayer/Contents.json new file mode 100644 index 0000000..73c0059 --- /dev/null +++ b/Swift/VideoStitcherExample/app/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - App Store.imagestack/Middle.imagestacklayer/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Swift/VideoStitcherExample/app/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon.imagestack/Back.imagestacklayer/Content.imageset/Contents.json b/Swift/VideoStitcherExample/app/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon.imagestack/Back.imagestacklayer/Content.imageset/Contents.json new file mode 100644 index 0000000..795cce1 --- /dev/null +++ b/Swift/VideoStitcherExample/app/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon.imagestack/Back.imagestacklayer/Content.imageset/Contents.json @@ -0,0 +1,16 @@ +{ + "images" : [ + { + "idiom" : "tv", + "scale" : "1x" + }, + { + "idiom" : "tv", + "scale" : "2x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Swift/VideoStitcherExample/app/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon.imagestack/Back.imagestacklayer/Contents.json b/Swift/VideoStitcherExample/app/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon.imagestack/Back.imagestacklayer/Contents.json new file mode 100644 index 0000000..73c0059 --- /dev/null +++ b/Swift/VideoStitcherExample/app/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon.imagestack/Back.imagestacklayer/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Swift/VideoStitcherExample/app/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon.imagestack/Contents.json b/Swift/VideoStitcherExample/app/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon.imagestack/Contents.json new file mode 100644 index 0000000..de59d88 --- /dev/null +++ b/Swift/VideoStitcherExample/app/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon.imagestack/Contents.json @@ -0,0 +1,17 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + }, + "layers" : [ + { + "filename" : "Front.imagestacklayer" + }, + { + "filename" : "Middle.imagestacklayer" + }, + { + "filename" : "Back.imagestacklayer" + } + ] +} diff --git a/Swift/VideoStitcherExample/app/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon.imagestack/Front.imagestacklayer/Content.imageset/Contents.json b/Swift/VideoStitcherExample/app/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon.imagestack/Front.imagestacklayer/Content.imageset/Contents.json new file mode 100644 index 0000000..795cce1 --- /dev/null +++ b/Swift/VideoStitcherExample/app/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon.imagestack/Front.imagestacklayer/Content.imageset/Contents.json @@ -0,0 +1,16 @@ +{ + "images" : [ + { + "idiom" : "tv", + "scale" : "1x" + }, + { + "idiom" : "tv", + "scale" : "2x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Swift/VideoStitcherExample/app/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon.imagestack/Front.imagestacklayer/Contents.json b/Swift/VideoStitcherExample/app/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon.imagestack/Front.imagestacklayer/Contents.json new file mode 100644 index 0000000..73c0059 --- /dev/null +++ b/Swift/VideoStitcherExample/app/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon.imagestack/Front.imagestacklayer/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Swift/VideoStitcherExample/app/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon.imagestack/Middle.imagestacklayer/Content.imageset/Contents.json b/Swift/VideoStitcherExample/app/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon.imagestack/Middle.imagestacklayer/Content.imageset/Contents.json new file mode 100644 index 0000000..795cce1 --- /dev/null +++ b/Swift/VideoStitcherExample/app/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon.imagestack/Middle.imagestacklayer/Content.imageset/Contents.json @@ -0,0 +1,16 @@ +{ + "images" : [ + { + "idiom" : "tv", + "scale" : "1x" + }, + { + "idiom" : "tv", + "scale" : "2x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Swift/VideoStitcherExample/app/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon.imagestack/Middle.imagestacklayer/Contents.json b/Swift/VideoStitcherExample/app/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon.imagestack/Middle.imagestacklayer/Contents.json new file mode 100644 index 0000000..73c0059 --- /dev/null +++ b/Swift/VideoStitcherExample/app/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon.imagestack/Middle.imagestacklayer/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Swift/VideoStitcherExample/app/Assets.xcassets/App Icon & Top Shelf Image.brandassets/Contents.json b/Swift/VideoStitcherExample/app/Assets.xcassets/App Icon & Top Shelf Image.brandassets/Contents.json new file mode 100644 index 0000000..f47ba43 --- /dev/null +++ b/Swift/VideoStitcherExample/app/Assets.xcassets/App Icon & Top Shelf Image.brandassets/Contents.json @@ -0,0 +1,32 @@ +{ + "assets" : [ + { + "filename" : "App Icon - App Store.imagestack", + "idiom" : "tv", + "role" : "primary-app-icon", + "size" : "1280x768" + }, + { + "filename" : "App Icon.imagestack", + "idiom" : "tv", + "role" : "primary-app-icon", + "size" : "400x240" + }, + { + "filename" : "Top Shelf Image Wide.imageset", + "idiom" : "tv", + "role" : "top-shelf-image-wide", + "size" : "2320x720" + }, + { + "filename" : "Top Shelf Image.imageset", + "idiom" : "tv", + "role" : "top-shelf-image", + "size" : "1920x720" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Swift/VideoStitcherExample/app/Assets.xcassets/App Icon & Top Shelf Image.brandassets/Top Shelf Image Wide.imageset/Contents.json b/Swift/VideoStitcherExample/app/Assets.xcassets/App Icon & Top Shelf Image.brandassets/Top Shelf Image Wide.imageset/Contents.json new file mode 100644 index 0000000..b65f0cd --- /dev/null +++ b/Swift/VideoStitcherExample/app/Assets.xcassets/App Icon & Top Shelf Image.brandassets/Top Shelf Image Wide.imageset/Contents.json @@ -0,0 +1,24 @@ +{ + "images" : [ + { + "idiom" : "tv", + "scale" : "1x" + }, + { + "idiom" : "tv", + "scale" : "2x" + }, + { + "idiom" : "tv-marketing", + "scale" : "1x" + }, + { + "idiom" : "tv-marketing", + "scale" : "2x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Swift/VideoStitcherExample/app/Assets.xcassets/App Icon & Top Shelf Image.brandassets/Top Shelf Image.imageset/Contents.json b/Swift/VideoStitcherExample/app/Assets.xcassets/App Icon & Top Shelf Image.brandassets/Top Shelf Image.imageset/Contents.json new file mode 100644 index 0000000..b65f0cd --- /dev/null +++ b/Swift/VideoStitcherExample/app/Assets.xcassets/App Icon & Top Shelf Image.brandassets/Top Shelf Image.imageset/Contents.json @@ -0,0 +1,24 @@ +{ + "images" : [ + { + "idiom" : "tv", + "scale" : "1x" + }, + { + "idiom" : "tv", + "scale" : "2x" + }, + { + "idiom" : "tv-marketing", + "scale" : "1x" + }, + { + "idiom" : "tv-marketing", + "scale" : "2x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Swift/VideoStitcherExample/app/Assets.xcassets/Contents.json b/Swift/VideoStitcherExample/app/Assets.xcassets/Contents.json new file mode 100644 index 0000000..73c0059 --- /dev/null +++ b/Swift/VideoStitcherExample/app/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Swift/VideoStitcherExample/app/Info.plist b/Swift/VideoStitcherExample/app/Info.plist new file mode 100644 index 0000000..68d778a --- /dev/null +++ b/Swift/VideoStitcherExample/app/Info.plist @@ -0,0 +1,30 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + LSRequiresIPhoneOS + + UIRequiredDeviceCapabilities + + arm64 + + UIUserInterfaceStyle + Automatic + + diff --git a/Swift/VideoStitcherExample/app/ViewController.swift b/Swift/VideoStitcherExample/app/ViewController.swift new file mode 100644 index 0000000..6088d4a --- /dev/null +++ b/Swift/VideoStitcherExample/app/ViewController.swift @@ -0,0 +1,260 @@ +// Copyright 2024 Google LLC. All rights reserved. +// +// +// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this +// file except in compliance with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software distributed under +// the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF +// ANY KIND, either express or implied. See the License for the specific language governing +// permissions and limitations under the License. + +import AVFoundation +import GoogleInteractiveMediaAds +import UIKit + +class ViewController: + UIViewController, + IMAAdsLoaderDelegate, + IMAStreamManagerDelegate, + AVPlayerViewControllerDelegate +{ + enum StreamType { case liveStream, vodStream } + + /// Video Stitcher stream request type. Either `StreamType.liveStream` or `StreamType.vodStream`. + static let requestType = StreamType.liveStream + + /// The live stream event ID associated with this stream in your Google Cloud project. + static let liveStreamEventID = "" + /// The custom asset key associated with this stream in your Google Cloud project. + static let customAssetKey = "" + + /// The VOD config ID associated with this stream in your Google Cloud project. + static let vodConfigID = "" + + /// The network code of the Google Cloud account containing the Video Stitcher API project. + static let networkCode = "" + /// The project number associated with your Video Stitcher API project. + static let projectNumber = "" + /// The Google Cloud region where your Video Stitcher API project is located. + static let location = "" + /// A recently generated OAuth Token for a Google Cloud service worker account with the Video + /// Stitcher API enabled. + static let oAuthToken = "" + + /// Backup content URL + static let backupStreamURLString = """ + http://googleimadev-vh.akamaihd.net/i/big_buck_bunny/\ + bbb-,480p,720p,1080p,.mov.csmil/master.m3u8 + """ + + var adsLoader: IMAAdsLoader? + var videoDisplay: IMAAVPlayerVideoDisplay! + var adDisplayContainer: IMAAdDisplayContainer? + var adContainerView: UIView? + private var streamManager: IMAStreamManager? + private var contentPlayhead: IMAAVPlayerContentPlayhead? + private var playerViewController: AVPlayerViewController! + private var adBreakActive = false + + deinit { + NotificationCenter.default.removeObserver(self) + } + + override func viewDidLoad() { + super.viewDidLoad() + self.view.backgroundColor = UIColor.black + + setupAdsLoader() + setupPlayer() + setupAdContainer() + } + + override func viewDidAppear(_ animated: Bool) { + super.viewDidAppear(animated) + requestStream() + } + + func setupAdsLoader() { + let adsLoader = IMAAdsLoader(settings: nil) + adsLoader.delegate = self + self.adsLoader = adsLoader + } + + func setupPlayer() { + let player = AVPlayer() + let playerViewController = AVPlayerViewController() + playerViewController.delegate = self + playerViewController.player = player + + // Set up our content playhead and contentComplete callback. + contentPlayhead = IMAAVPlayerContentPlayhead(avPlayer: player) + NotificationCenter.default.addObserver( + self, + selector: #selector(ViewController.contentDidFinishPlaying(_:)), + name: NSNotification.Name.AVPlayerItemDidPlayToEndTime, + object: player.currentItem) + + self.addChild(playerViewController) + playerViewController.view.frame = self.view.bounds + self.view.insertSubview(playerViewController.view, at: 0) + playerViewController.didMove(toParent: self) + self.playerViewController = playerViewController + } + + func setupAdContainer() { + // Attach the ad container to the view hierarchy on top of the player. + let adContainerView = UIView() + self.view.addSubview(adContainerView) + adContainerView.frame = self.view.bounds + // Keep hidden initially, until an ad break. + adContainerView.isHidden = true + self.adContainerView = adContainerView + } + + func requestStream() { + guard let playerViewController = self.playerViewController else { return } + guard let adContainerView = self.adContainerView else { return } + guard let adsLoader = self.adsLoader else { return } + + self.videoDisplay = IMAAVPlayerVideoDisplay(avPlayer: playerViewController.player!) + adDisplayContainer = IMAAdDisplayContainer( + adContainer: adContainerView, viewController: self) + let streamRequest: IMAStreamRequest + if ViewController.requestType == StreamType.liveStream { + // Create a Livestream request. + streamRequest = IMAVideoStitcherLiveStreamRequest( + liveStreamEventID: ViewController.liveStreamEventID, + region: ViewController.location, + projectNumber: ViewController.projectNumber, + oAuthToken: ViewController.oAuthToken, + networkCode: ViewController.networkCode, + customAssetKey: ViewController.customAssetKey, + adDisplayContainer: adDisplayContainer!, + videoDisplay: self.videoDisplay, + userContext: nil, + videoStitcherSessionOptions: nil) + } else { + // Create a VOD stream request. + streamRequest = IMAVideoStitcherVODStreamRequest( + vodConfigID: ViewController.vodConfigID, + region: ViewController.location, + projectNumber: ViewController.projectNumber, + oAuthToken: ViewController.oAuthToken, + networkCode: ViewController.networkCode, + adDisplayContainer: adDisplayContainer!, + videoDisplay: self.videoDisplay, + userContext: nil, + videoStitcherSessionOptions: nil) + } + adsLoader.requestStream(with: streamRequest) + } + + @objc func contentDidFinishPlaying(_ notification: Notification) { + guard let adsLoader = self.adsLoader else { return } + adsLoader.contentComplete() + } + + func startMediaSession() { + try? AVAudioSession.sharedInstance().setActive(true, options: []) + try? AVAudioSession.sharedInstance().setCategory(.playback) + } + + // MARK: - UIFocusEnvironment + + override var preferredFocusEnvironments: [UIFocusEnvironment] { + if adBreakActive, let adFocusEnvironment = adDisplayContainer?.focusEnvironment { + // Send focus to the ad display container during an ad break. + return [adFocusEnvironment] + } else { + // Send focus to the content player otherwise. + return [playerViewController] + } + } + + // MARK: - IMAAdsLoaderDelegate + + func adsLoader(_ loader: IMAAdsLoader, adsLoadedWith adsLoadedData: IMAAdsLoadedData) { + let streamManager = adsLoadedData.streamManager! + streamManager.delegate = self + streamManager.initialize(with: nil) + self.streamManager = streamManager + } + + func adsLoader(_ loader: IMAAdsLoader, failedWith adErrorData: IMAAdLoadingErrorData) { + print("Error loading ads: \(String(describing: adErrorData.adError.message))") + let streamUrl = URL(string: ViewController.backupStreamURLString) + self.videoDisplay.loadStream(streamUrl!, withSubtitles: []) + self.videoDisplay.play() + playerViewController.player?.play() + } + + // MARK: - IMAStreamManagerDelegate + func streamManager(_ streamManager: IMAStreamManager, didReceive event: IMAAdEvent) { + print("StreamManager event \(event.typeString).") + switch event.type { + case IMAAdEventType.STREAM_STARTED: + self.startMediaSession() + case IMAAdEventType.STARTED: + // Log extended data. + if let ad = event.ad { + let extendedAdPodInfo = String( + format: "Showing ad %zd/%zd, bumper: %@, title: %@, " + + "description: %@, contentType:%@, pod index: %zd, " + + "time offset: %lf, max duration: %lf.", + ad.adPodInfo.adPosition, + ad.adPodInfo.totalAds, + ad.adPodInfo.isBumper ? "YES" : "NO", + ad.adTitle, + ad.adDescription, + ad.contentType, + ad.adPodInfo.podIndex, + ad.adPodInfo.timeOffset, + ad.adPodInfo.maxDuration) + + print("\(extendedAdPodInfo)") + } + break + case IMAAdEventType.AD_BREAK_STARTED: + if let adContainerView = self.adContainerView { + adContainerView.isHidden = false + } + // Trigger an update to send focus to the ad display container. + adBreakActive = true + setNeedsFocusUpdate() + break + case IMAAdEventType.AD_BREAK_ENDED: + if let adContainerView = self.adContainerView { + adContainerView.isHidden = true + } + // Trigger an update to send focus to the content player. + adBreakActive = false + setNeedsFocusUpdate() + break + case IMAAdEventType.ICON_FALLBACK_IMAGE_CLOSED: + // Resume playback after the user has closed the dialog. + self.videoDisplay.play() + break + default: + break + } + } + + func streamManager(_ streamManager: IMAStreamManager, didReceive error: IMAAdError) { + print("StreamManager error: \(error.message ?? "Unknown Error")") + } + + // MARK: - AVPlayerViewControllerDelegate + func playerViewController( + _ playerViewController: AVPlayerViewController, + timeToSeekAfterUserNavigatedFrom oldTime: CMTime, + to targetTime: CMTime + ) -> CMTime { + if adBreakActive { + return oldTime + } + return targetTime + } +}