Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iOS 13 updates & AVKit #210

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 35 additions & 9 deletions MobilePlayer.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
objects = {

/* Begin PBXBuildFile section */
5028568F23C1E16A00AFFFD5 /* PlayerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5028568E23C1E16A00AFFFD5 /* PlayerView.swift */; };
5F31B7B91BBAE39900EF50C4 /* MobilePlayerNotification.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5F31B7B81BBAE39900EF50C4 /* MobilePlayerNotification.swift */; };
5F3F03C31C18E73200EF50C4 /* PrerollExampleViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5F3F03C21C18E73200EF50C4 /* PrerollExampleViewController.swift */; };
5F3F03C51C18E74000EF50C4 /* PauseOverlayExampleViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5F3F03C41C18E74000EF50C4 /* PauseOverlayExampleViewController.swift */; };
Expand Down Expand Up @@ -138,6 +139,7 @@
/* Begin PBXFileReference section */
0A3D625F8D46F7B3823A9927 /* Pods-MobilePlayerTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-MobilePlayerTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-MobilePlayerTests/Pods-MobilePlayerTests.debug.xcconfig"; sourceTree = "<group>"; };
460022C3A2D4FC80A1D57D18 /* Pods-MobilePlayerTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-MobilePlayerTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-MobilePlayerTests/Pods-MobilePlayerTests.release.xcconfig"; sourceTree = "<group>"; };
5028568E23C1E16A00AFFFD5 /* PlayerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlayerView.swift; sourceTree = "<group>"; };
505CCD80FF878F8F17EC4627 /* Pods_MobilePlayerTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_MobilePlayerTests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
5F31B7B81BBAE39900EF50C4 /* MobilePlayerNotification.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MobilePlayerNotification.swift; sourceTree = "<group>"; };
5F3F03C21C18E73200EF50C4 /* PrerollExampleViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PrerollExampleViewController.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -362,6 +364,7 @@
5FA92EA21BA9896300EF50C4 /* ToggleButton.swift */,
5FA92EA61BA9919D00EF50C4 /* Slider.swift */,
5F7CDF4A1BBEB6F900EF50C4 /* VolumeView.swift */,
5028568E23C1E16A00AFFFD5 /* PlayerView.swift */,
);
name = Views;
sourceTree = "<group>";
Expand Down Expand Up @@ -653,7 +656,7 @@
attributes = {
LastSwiftMigration = 0700;
LastSwiftUpdateCheck = 0710;
LastUpgradeCheck = 0800;
LastUpgradeCheck = 1120;
ORGANIZATIONNAME = MovieLaLa;
TargetAttributes = {
5F56CB6E1C0407F200EF50C4 = {
Expand All @@ -663,6 +666,7 @@
};
5F56CB801C040E8D00EF50C4 = {
CreatedOnToolsVersion = 7.1.1;
DevelopmentTeam = K3XQNT3L95;
LastSwiftMigration = 1010;
};
5F56CB951C040E8E00EF50C4 = {
Expand All @@ -686,6 +690,7 @@
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
English,
en,
Base,
);
Expand Down Expand Up @@ -821,6 +826,7 @@
5F8272741BFA9F0600EF50C4 /* UIImage+CocoaPods.swift in Sources */,
5F7CDF471BBEB6C400EF50C4 /* YoutubeParser.swift in Sources */,
5FD756961BAC4AE700EF50C4 /* WatermarkViewController.swift in Sources */,
5028568F23C1E16A00AFFFD5 /* PlayerView.swift in Sources */,
5FBFEA321BA8ACC500EF50C4 /* LabelConfig.swift in Sources */,
5F6AF3701BA96EF000EF50C4 /* Button.swift in Sources */,
5FBFEA341BA8ACDE00EF50C4 /* ToggleButtonConfig.swift in Sources */,
Expand Down Expand Up @@ -935,12 +941,13 @@
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
DEBUG_INFORMATION_FORMAT = dwarf;
DEVELOPMENT_TEAM = K3XQNT3L95;
INFOPLIST_FILE = MobilePlayerExamples/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 9.1;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.movielala.MobilePlayerExamples;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
};
name = Debug;
};
Expand All @@ -950,12 +957,13 @@
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
DEVELOPMENT_TEAM = K3XQNT3L95;
INFOPLIST_FILE = MobilePlayerExamples/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 9.1;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.movielala.MobilePlayerExamples;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
};
name = Release;
};
Expand Down Expand Up @@ -993,18 +1001,27 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
Expand Down Expand Up @@ -1045,18 +1062,27 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
Expand Down Expand Up @@ -1096,13 +1122,13 @@
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
INFOPLIST_FILE = "MobilePlayer/Supporting Files/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.movielala.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
};
name = Debug;
};
Expand All @@ -1116,12 +1142,12 @@
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
INFOPLIST_FILE = "MobilePlayer/Supporting Files/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.movielala.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
};
name = Release;
};
Expand Down
24 changes: 10 additions & 14 deletions MobilePlayer.xcodeproj/xcshareddata/xcschemes/MobilePlayer.xcscheme
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0800"
LastUpgradeVersion = "1120"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down Expand Up @@ -41,6 +41,15 @@
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "CE554D4E1AFE6CCD00DAC7E9"
BuildableName = "MobilePlayer.framework"
BlueprintName = "MobilePlayer"
ReferencedContainer = "container:MobilePlayer.xcodeproj">
</BuildableReference>
</MacroExpansion>
<Testables>
<TestableReference
skipped = "NO">
Expand All @@ -58,17 +67,6 @@
</SkippedTests>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "CE554D4E1AFE6CCD00DAC7E9"
BuildableName = "MobilePlayer.framework"
BlueprintName = "MobilePlayer"
ReferencedContainer = "container:MobilePlayer.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
Expand All @@ -89,8 +87,6 @@
ReferencedContainer = "container:MobilePlayer.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0800"
LastUpgradeVersion = "1120"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down Expand Up @@ -29,8 +29,6 @@
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
Expand All @@ -51,8 +49,6 @@
ReferencedContainer = "container:MobilePlayer.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0800"
LastUpgradeVersion = "1120"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand All @@ -27,6 +27,15 @@
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "5F56CB801C040E8D00EF50C4"
BuildableName = "MobilePlayerExamples.app"
BlueprintName = "MobilePlayerExamples"
ReferencedContainer = "container:MobilePlayer.xcodeproj">
</BuildableReference>
</MacroExpansion>
<Testables>
<TestableReference
skipped = "NO">
Expand All @@ -39,17 +48,6 @@
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "5F56CB801C040E8D00EF50C4"
BuildableName = "MobilePlayerExamples.app"
BlueprintName = "MobilePlayerExamples"
ReferencedContainer = "container:MobilePlayer.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
Expand Down Expand Up @@ -78,8 +76,6 @@
isEnabled = "YES">
</EnvironmentVariable>
</EnvironmentVariables>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
Expand Down
40 changes: 23 additions & 17 deletions MobilePlayer/Helpers/StateHelper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,29 @@

import UIKit
import MediaPlayer
import AVKit

struct StateHelper {

static func calculateStateUsing(
previousState: MobilePlayerViewController.State,
andPlaybackState playbackState: MPMoviePlaybackState) -> MobilePlayerViewController.State {
switch playbackState {
case .stopped:
return .idle
case .playing:
return .playing
case .paused:
return .paused
case .interrupted:
return .buffering
case .seekingForward, .seekingBackward:
return previousState
}
}
static func calculateStateUsing(
previousState: MobilePlayerViewController.State,
andPlaybackState playbackState: AVPlayer.TimeControlStatus) -> MobilePlayerViewController.State {

switch playbackState {
case .paused:
return .paused
case .playing:
return .playing
case .waitingToPlayAtSpecifiedRate:
return .buffering

@unknown default:
#if DEBUG
fatalError("StateHelper: Handle all cases from AVPlayer.TimeControlStatus")
#else
print("IMPORTANT: Handle all cases from AVPlayer.TimeControlStatus")
return .idle
#endif

}
}
}
32 changes: 16 additions & 16 deletions MobilePlayer/MobilePlayerOverlayViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,27 @@
import UIKit

struct TimedOverlayInfo {
let startTime: TimeInterval
let duration: TimeInterval
let overlay: MobilePlayerOverlayViewController
let startTime: TimeInterval
let duration: TimeInterval
let overlay: MobilePlayerOverlayViewController
}

protocol MobilePlayerOverlayViewControllerDelegate: class {
func dismiss(mobilePlayerOverlayViewController: MobilePlayerOverlayViewController)
func dismiss(mobilePlayerOverlayViewController: MobilePlayerOverlayViewController)
}

/// A view controller used for presenting views on top of player content. Meant to be subclassed.
open class MobilePlayerOverlayViewController: UIViewController {
weak var delegate: MobilePlayerOverlayViewControllerDelegate?

/// The MobilePlayerViewController instance that the overlay is being shown by.
/// It's value is nil if the overlay is not being shown at the time this property is accessed.
public var mobilePlayer: MobilePlayerViewController? {
return delegate as? MobilePlayerViewController
}

/// Causes the view controller's view to be removed from on top of player content if it is being displayed.
public func dismiss() {
delegate?.dismiss(mobilePlayerOverlayViewController: self)
}
weak var delegate: MobilePlayerOverlayViewControllerDelegate?
/// The MobilePlayerViewController instance that the overlay is being shown by.
/// It's value is nil if the overlay is not being shown at the time this property is accessed.
public var mobilePlayer: MobilePlayerViewController? {
return delegate as? MobilePlayerViewController
}
/// Causes the view controller's view to be removed from on top of player content if it is being displayed.
public func dismiss() {
delegate?.dismiss(mobilePlayerOverlayViewController: self)
}
}
Loading