Initial commit: SimVision tvOS streaming app

Features:
- VOD library with movie grouping and version detection
- TV show library with season/episode organization
- TMDB integration for trending shows and recently aired episodes
- Recent releases section with TMDB release date sorting
- Watch history tracking with continue watching
- Playlist caching (12-hour TTL) for offline support
- M3U playlist parsing with XStream API support
- Authentication with credential storage

Technical:
- SwiftUI for tvOS
- Actor-based services for thread safety
- Persistent caching for playlists, TMDB data, and watch history
- KSPlayer integration for video playback

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-21 22:12:08 -06:00
commit 872354b834
283 changed files with 338296 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
disabled_rules:
- trailing_comma
included:
- ../../Sources
line_length: 200
function_body_length: 85
# cyclomatic_complexity: 25
file_length: 800
large_tuple: 8
identifier_name:
min_length: # 只有最小长度
error: 3 # 只有错误
excluded: # 排除某些名字
- id
- URL
- i
- j
- r
- x
- y
- z
- n
- l
- d
- usesExternalPlaybackWhileExternalScreenIsActive
type_name:
excluded: E # 排除某个名字

View File

@@ -0,0 +1,460 @@
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 54;
objects = {
/* Begin PBXBuildFile section */
5B4483D96DC416B6E2098D77 /* Pods_demo_iOS.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 652FADC7FD99912D1B883FB1 /* Pods_demo_iOS.framework */; };
AC08614F20B69A4500D801FC /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = AC08614E20B69A4500D801FC /* AppDelegate.swift */; };
AC08615620B69A4500D801FC /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = AC08615520B69A4500D801FC /* Assets.xcassets */; };
AC08619620B69AB400D801FC /* DetailViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = AC08619420B69AB400D801FC /* DetailViewController.swift */; };
AC08619720B69AB400D801FC /* MasterViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = AC08619520B69AB400D801FC /* MasterViewController.swift */; };
AC3E54AB24B9E810002B6B1B /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = AC3E498E24B9CB5E002B6B1B /* LaunchScreen.storyboard */; };
AC3E54AC24B9E815002B6B1B /* Localized.strings in Resources */ = {isa = PBXBuildFile; fileRef = AC3E491D24B98CEB002B6B1B /* Localized.strings */; };
AC458DE621DF830F00BD4CF9 /* AudioViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = AC458DE521DF830F00BD4CF9 /* AudioViewController.swift */; };
AC68AA322AD3FA320061A4CA /* MEPlayerViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = AC68AA312AD3FA310061A4CA /* MEPlayerViewController.swift */; };
AC78D5DA2B09056B00A28998 /* test.m3u in Resources */ = {isa = PBXBuildFile; fileRef = AC78D5D92B09056B00A28998 /* test.m3u */; };
ACE8052D2A83B92800690A9B /* RootViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = ACE8052C2A83B92800690A9B /* RootViewController.swift */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
38C991CC5CA01B5A94D57925 /* Pods-demo-iOS.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-demo-iOS.release.xcconfig"; path = "../Pods/Target Support Files/Pods-demo-iOS/Pods-demo-iOS.release.xcconfig"; sourceTree = "<group>"; };
50CE87CB5D349C9B4FC639C6 /* Pods-demo-iOS.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-demo-iOS.debug.xcconfig"; path = "../Pods/Target Support Files/Pods-demo-iOS/Pods-demo-iOS.debug.xcconfig"; sourceTree = "<group>"; };
652FADC7FD99912D1B883FB1 /* Pods_demo_iOS.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_demo_iOS.framework; sourceTree = BUILT_PRODUCTS_DIR; };
839B31E32B04D796647D7334 /* Pods_demo_iOSTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_demo_iOSTests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
AC08614B20B69A4500D801FC /* demo-iOS.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "demo-iOS.app"; sourceTree = BUILT_PRODUCTS_DIR; };
AC08614E20B69A4500D801FC /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
AC08615520B69A4500D801FC /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
AC08615A20B69A4500D801FC /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
AC08619420B69AB400D801FC /* DetailViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DetailViewController.swift; sourceTree = "<group>"; };
AC08619520B69AB400D801FC /* MasterViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MasterViewController.swift; sourceTree = "<group>"; };
AC155F1223AFA9F40092D004 /* demo-iOS.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = "demo-iOS.entitlements"; sourceTree = "<group>"; };
AC3E498C24B9CA67002B6B1B /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/Localized.strings"; sourceTree = "<group>"; };
AC3E498E24B9CB5E002B6B1B /* LaunchScreen.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = LaunchScreen.storyboard; sourceTree = "<group>"; };
AC458DE521DF830F00BD4CF9 /* AudioViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AudioViewController.swift; sourceTree = "<group>"; };
AC68AA312AD3FA310061A4CA /* MEPlayerViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MEPlayerViewController.swift; sourceTree = "<group>"; };
AC78D5D92B09056B00A28998 /* test.m3u */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = test.m3u; path = ../../../Tests/KSPlayerTests/Resources/test.m3u; sourceTree = "<group>"; };
AC7E04DB2414DA5E00B0F540 /* libxml2.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libxml2.tbd; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/lib/libxml2.tbd; sourceTree = DEVELOPER_DIR; };
ACE8052C2A83B92800690A9B /* RootViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RootViewController.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
AC08614820B69A4500D801FC /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
5B4483D96DC416B6E2098D77 /* Pods_demo_iOS.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
15F03ACE93ED6586BC17C60F /* Frameworks */ = {
isa = PBXGroup;
children = (
AC7E04DB2414DA5E00B0F540 /* libxml2.tbd */,
652FADC7FD99912D1B883FB1 /* Pods_demo_iOS.framework */,
839B31E32B04D796647D7334 /* Pods_demo_iOSTests.framework */,
);
name = Frameworks;
sourceTree = "<group>";
};
AC08614220B69A4500D801FC = {
isa = PBXGroup;
children = (
AC08614D20B69A4500D801FC /* demo-iOS */,
AC08614C20B69A4500D801FC /* Products */,
F16DE5BE42F78427E632B228 /* Pods */,
15F03ACE93ED6586BC17C60F /* Frameworks */,
);
sourceTree = "<group>";
};
AC08614C20B69A4500D801FC /* Products */ = {
isa = PBXGroup;
children = (
AC08614B20B69A4500D801FC /* demo-iOS.app */,
);
name = Products;
sourceTree = "<group>";
};
AC08614D20B69A4500D801FC /* demo-iOS */ = {
isa = PBXGroup;
children = (
AC155F1223AFA9F40092D004 /* demo-iOS.entitlements */,
AC08614E20B69A4500D801FC /* AppDelegate.swift */,
ACE8052C2A83B92800690A9B /* RootViewController.swift */,
AC08619420B69AB400D801FC /* DetailViewController.swift */,
AC08619520B69AB400D801FC /* MasterViewController.swift */,
AC458DE521DF830F00BD4CF9 /* AudioViewController.swift */,
AC78D5D92B09056B00A28998 /* test.m3u */,
AC3E498E24B9CB5E002B6B1B /* LaunchScreen.storyboard */,
AC08615520B69A4500D801FC /* Assets.xcassets */,
AC08615A20B69A4500D801FC /* Info.plist */,
AC3E491D24B98CEB002B6B1B /* Localized.strings */,
AC68AA312AD3FA310061A4CA /* MEPlayerViewController.swift */,
);
path = "demo-iOS";
sourceTree = "<group>";
};
F16DE5BE42F78427E632B228 /* Pods */ = {
isa = PBXGroup;
children = (
50CE87CB5D349C9B4FC639C6 /* Pods-demo-iOS.debug.xcconfig */,
38C991CC5CA01B5A94D57925 /* Pods-demo-iOS.release.xcconfig */,
);
name = Pods;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
AC08614A20B69A4500D801FC /* demo-iOS */ = {
isa = PBXNativeTarget;
buildConfigurationList = AC08617320B69A4500D801FC /* Build configuration list for PBXNativeTarget "demo-iOS" */;
buildPhases = (
E288B39642AA08D864D78A50 /* [CP] Check Pods Manifest.lock */,
AC08614720B69A4500D801FC /* Sources */,
AC08614820B69A4500D801FC /* Frameworks */,
AC08614920B69A4500D801FC /* Resources */,
E1EAA56A7C123B7DD400C005 /* [CP] Copy Pods Resources */,
);
buildRules = (
);
dependencies = (
);
name = "demo-iOS";
productName = "demo-iOS";
productReference = AC08614B20B69A4500D801FC /* demo-iOS.app */;
productType = "com.apple.product-type.application";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
AC08614320B69A4500D801FC /* Project object */ = {
isa = PBXProject;
attributes = {
BuildIndependentTargetsInParallel = YES;
LastSwiftUpdateCheck = 0930;
LastUpgradeCheck = 1500;
ORGANIZATIONNAME = kintan;
TargetAttributes = {
AC08614A20B69A4500D801FC = {
CreatedOnToolsVersion = 9.3.1;
LastSwiftMigration = 1000;
};
};
};
buildConfigurationList = AC08614620B69A4500D801FC /* Build configuration list for PBXProject "demo-iOS" */;
compatibilityVersion = "Xcode 11.0";
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
en,
Base,
"zh-Hans",
);
mainGroup = AC08614220B69A4500D801FC;
productRefGroup = AC08614C20B69A4500D801FC /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
AC08614A20B69A4500D801FC /* demo-iOS */,
);
};
/* End PBXProject section */
/* Begin PBXResourcesBuildPhase section */
AC08614920B69A4500D801FC /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
AC3E54AC24B9E815002B6B1B /* Localized.strings in Resources */,
AC3E54AB24B9E810002B6B1B /* LaunchScreen.storyboard in Resources */,
AC08615620B69A4500D801FC /* Assets.xcassets in Resources */,
AC78D5DA2B09056B00A28998 /* test.m3u in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXShellScriptBuildPhase section */
E1EAA56A7C123B7DD400C005 /* [CP] Copy Pods Resources */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-demo-iOS/Pods-demo-iOS-resources-${CONFIGURATION}-input-files.xcfilelist",
);
name = "[CP] Copy Pods Resources";
outputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-demo-iOS/Pods-demo-iOS-resources-${CONFIGURATION}-output-files.xcfilelist",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-demo-iOS/Pods-demo-iOS-resources.sh\"\n";
showEnvVarsInLog = 0;
};
E288B39642AA08D864D78A50 /* [CP] Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
"${PODS_PODFILE_DIR_PATH}/Podfile.lock",
"${PODS_ROOT}/Manifest.lock",
);
name = "[CP] Check Pods Manifest.lock";
outputPaths = (
"$(DERIVED_FILE_DIR)/Pods-demo-iOS-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 */
AC08614720B69A4500D801FC /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
ACE8052D2A83B92800690A9B /* RootViewController.swift in Sources */,
AC08619720B69AB400D801FC /* MasterViewController.swift in Sources */,
AC458DE621DF830F00BD4CF9 /* AudioViewController.swift in Sources */,
AC08619620B69AB400D801FC /* DetailViewController.swift in Sources */,
AC08614F20B69A4500D801FC /* AppDelegate.swift in Sources */,
AC68AA322AD3FA320061A4CA /* MEPlayerViewController.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin PBXVariantGroup section */
AC3E491D24B98CEB002B6B1B /* Localized.strings */ = {
isa = PBXVariantGroup;
children = (
AC3E498C24B9CA67002B6B1B /* zh-Hans */,
);
name = Localized.strings;
sourceTree = "<group>";
};
/* End PBXVariantGroup section */
/* Begin XCBuildConfiguration section */
AC08617120B69A4500D801FC /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
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_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_TREAT_WARNINGS_AS_ERRORS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
OTHER_CODE_SIGN_FLAGS = "--deep";
SDKROOT = iphoneos;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
};
name = Debug;
};
AC08617220B69A4500D801FC /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
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_TREAT_WARNINGS_AS_ERRORS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
MTL_ENABLE_DEBUG_INFO = NO;
OTHER_CODE_SIGN_FLAGS = "--deep";
SDKROOT = iphoneos;
SWIFT_COMPILATION_MODE = wholemodule;
SWIFT_OPTIMIZATION_LEVEL = "-O";
VALIDATE_PRODUCT = YES;
};
name = Release;
};
AC08617420B69A4500D801FC /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 50CE87CB5D349C9B4FC639C6 /* Pods-demo-iOS.debug.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = "demo-iOS/demo-iOS.entitlements";
CODE_SIGN_IDENTITY = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "-";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1.1.1.1;
DERIVE_MACCATALYST_PRODUCT_BUNDLE_IDENTIFIER = YES;
DEVELOPMENT_TEAM = 3RVHT92X9D;
"ENABLE_HARDENED_RUNTIME[sdk=macosx*]" = YES;
INFOPLIST_FILE = "demo-iOS/Info.plist";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.1.1;
PRODUCT_BUNDLE_IDENTIFIER = kintan.player.demo;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE = "";
PROVISIONING_PROFILE_SPECIFIER = "";
"PROVISIONING_PROFILE_SPECIFIER[sdk=macosx*]" = "";
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
SUPPORTS_MACCATALYST = YES;
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2,6";
};
name = Debug;
};
AC08617520B69A4500D801FC /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 38C991CC5CA01B5A94D57925 /* Pods-demo-iOS.release.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = "demo-iOS/demo-iOS.entitlements";
CODE_SIGN_IDENTITY = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "-";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1.1.1.1;
DERIVE_MACCATALYST_PRODUCT_BUNDLE_IDENTIFIER = YES;
DEVELOPMENT_TEAM = 3RVHT92X9D;
"ENABLE_HARDENED_RUNTIME[sdk=macosx*]" = YES;
INFOPLIST_FILE = "demo-iOS/Info.plist";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.1.1;
PRODUCT_BUNDLE_IDENTIFIER = kintan.player.demo;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE = "";
PROVISIONING_PROFILE_SPECIFIER = "";
"PROVISIONING_PROFILE_SPECIFIER[sdk=macosx*]" = "";
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
SUPPORTS_MACCATALYST = YES;
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2,6";
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
AC08614620B69A4500D801FC /* Build configuration list for PBXProject "demo-iOS" */ = {
isa = XCConfigurationList;
buildConfigurations = (
AC08617120B69A4500D801FC /* Debug */,
AC08617220B69A4500D801FC /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
AC08617320B69A4500D801FC /* Build configuration list for PBXNativeTarget "demo-iOS" */ = {
isa = XCConfigurationList;
buildConfigurations = (
AC08617420B69A4500D801FC /* Debug */,
AC08617520B69A4500D801FC /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = AC08614320B69A4500D801FC /* Project object */;
}

View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "self:demo-iOS.xcodeproj">
</FileRef>
</Workspace>

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>

View File

@@ -0,0 +1,77 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1500"
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "AC08614A20B69A4500D801FC"
BuildableName = "demo-iOS.app"
BlueprintName = "demo-iOS"
ReferencedContainer = "container:demo-iOS.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
shouldAutocreateTestPlan = "YES">
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "AC08614A20B69A4500D801FC"
BuildableName = "demo-iOS.app"
BlueprintName = "demo-iOS"
ReferencedContainer = "container:demo-iOS.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "AC08614A20B69A4500D801FC"
BuildableName = "demo-iOS.app"
BlueprintName = "demo-iOS"
ReferencedContainer = "container:demo-iOS.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

View File

@@ -0,0 +1,135 @@
//
// AppDelegate.swift
// Demo
//
// Created by kintan on 2018/4/15.
// Copyright © 2018 kintan. All rights reserved.
//
import AVFoundation
import KSPlayer
import UIKit
@main
class AppDelegate: UIResponder, UIApplicationDelegate, UISplitViewControllerDelegate {
var window: UIWindow?
func application(_: UIApplication, didFinishLaunchingWithOptions _: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
let window = UIWindow()
KSOptions.canBackgroundPlay = true
KSOptions.logLevel = .debug
KSOptions.firstPlayerType = KSMEPlayer.self
KSOptions.secondPlayerType = KSMEPlayer.self
// KSOptions.supportedInterfaceOrientations = .all
KSOptions.isAutoPlay = true
KSOptions.isSecondOpen = true
KSOptions.isAccurateSeek = true
// KSOptions.isLoopPlay = true
if UIDevice.current.userInterfaceIdiom == .phone {
window.rootViewController = UINavigationController(rootViewController: MasterViewController())
} else if UIDevice.current.userInterfaceIdiom == .tv {
window.rootViewController = UINavigationController(rootViewController: MasterViewController())
} else {
let splitViewController = UISplitViewController()
splitViewController.preferredDisplayMode = .primaryOverlay
splitViewController.delegate = self
let detailVC = DetailViewController()
splitViewController.viewControllers = [UINavigationController(rootViewController: MasterViewController()), UINavigationController(rootViewController: detailVC)]
#if os(iOS)
detailVC.navigationItem.leftBarButtonItem = splitViewController.displayModeButtonItem
detailVC.navigationItem.leftItemsSupplementBackButton = true
#endif
window.rootViewController = splitViewController
}
window.makeKeyAndVisible()
self.window = window
return true
}
#if os(iOS)
func application(_: UIApplication, supportedInterfaceOrientationsFor _: UIWindow?) -> UIInterfaceOrientationMask {
KSOptions.supportedInterfaceOrientations
}
private var menuController: MenuController!
override func buildMenu(with builder: UIMenuBuilder) {
if builder.system == .main {
menuController = MenuController(with: builder)
}
}
#endif
}
class CustomVideoPlayerView: VideoPlayerView {
override func customizeUIComponents() {
super.customizeUIComponents()
toolBar.isHidden = true
toolBar.timeSlider.isHidden = true
}
override open func player(layer: KSPlayerLayer, state: KSPlayerState) {
super.player(layer: layer, state: state)
if state == .readyToPlay {
print(layer.player.naturalSize)
// list the all subtitles
let subtitleInfos = srtControl.subtitleInfos
for subtitleInfo in subtitleInfos {
print(subtitleInfo.name)
}
srtControl.selectedSubtitleInfo = subtitleInfos.first
for track in layer.player.tracks(mediaType: .audio) {
print("audio name: \(track.name) language: \(track.language ?? "")")
}
for track in layer.player.tracks(mediaType: .video) {
print("video name: \(track.name) bitRate: \(track.bitRate) fps: \(track.nominalFrameRate) colorPrimaries: \(track.colorPrimaries ?? "") colorPrimaries: \(track.transferFunction ?? "") yCbCrMatrix: \(track.yCbCrMatrix ?? "") codecType: \(track.mediaSubType.rawValue.string)")
}
}
}
override func onButtonPressed(type: PlayerButtonType, button: UIButton) {
if type == .landscape {
// xx
} else {
super.onButtonPressed(type: type, button: button)
}
}
}
class MEOptions: KSOptions {}
var testObjects: [KSPlayerResource] = {
var objects = [KSPlayerResource]()
if let url = Bundle.main.url(forResource: "test", withExtension: "m3u"), let data = try? Data(contentsOf: url) {
let result = data.parsePlaylist()
for (name, url, _) in result {
objects.append(KSPlayerResource(url: url, options: MEOptions(), name: name))
}
}
for ext in ["mp4", "mkv", "mov", "h264", "flac", "webm"] {
guard let urls = Bundle.main.urls(forResourcesWithExtension: ext, subdirectory: nil) else {
continue
}
for url in urls {
let options = MEOptions()
if url.lastPathComponent == "h264.mp4" {
options.videoFilters = ["hflip", "vflip"]
options.hardwareDecode = false
options.startPlayTime = 13
#if os(macOS)
let moviesDirectory = try? FileManager.default.url(for: .moviesDirectory, in: .userDomainMask, appropriateFor: nil, create: false)
options.outputURL = moviesDirectory?.appendingPathComponent("recording.mov")
#endif
} else if url.lastPathComponent == "vr.mp4" {
options.display = .vr
} else if url.lastPathComponent == "mjpeg.flac" {
options.videoDisable = true
options.syncDecodeAudio = true
} else if url.lastPathComponent == "subrip.mkv" {
options.asynchronousDecompression = false
options.videoFilters.append("yadif_videotoolbox=mode=0:parity=-1:deint=1")
}
objects.append(KSPlayerResource(url: url, options: options, name: url.lastPathComponent))
}
}
return objects
}()

View File

@@ -0,0 +1,98 @@
{
"images" : [
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"scale" : "3x"
},
{
"idiom" : "ipad",
"size" : "20x20",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "20x20",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "29x29",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "29x29",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "40x40",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "40x40",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "76x76",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "76x76",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "83.5x83.5",
"scale" : "2x"
},
{
"idiom" : "ios-marketing",
"size" : "1024x1024",
"scale" : "1x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}

View File

@@ -0,0 +1,6 @@
{
"info" : {
"version" : 1,
"author" : "xcode"
}
}

View File

@@ -0,0 +1,38 @@
//
// AudioViewController.swift
// demo-iOS
//
// Created by kintan on 2019/1/4.
// Copyright © 2019 kintan. All rights reserved.
//
import KSPlayer
import UIKit
class AudioViewController: UIViewController, DetailProtocol {
var playerView = AudioPlayerView()
var resource: KSPlayerResource? {
didSet {
if let resource {
playerView.set(url: resource.definitions[0].url, options: KSOptions())
}
}
}
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = UIColor.lightGray
view.addSubview(playerView)
playerView.backgroundColor = UIColor.white
playerView.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
playerView.leadingAnchor.constraint(equalTo: view.leadingAnchor),
playerView.trailingAnchor.constraint(equalTo: view.trailingAnchor),
playerView.centerYAnchor.constraint(equalTo: view.centerYAnchor),
])
view.layoutIfNeeded()
if let resource {
playerView.set(url: resource.definitions[0].url, options: KSOptions())
}
}
}

View File

@@ -0,0 +1,107 @@
//
// DetailViewController.swift
// Demo
//
// Created by kintan on 2018/4/15.
// Copyright © 2018 kintan. All rights reserved.
//
import CoreServices
import KSPlayer
import UIKit
protocol DetailProtocol: UIViewController {
var resource: KSPlayerResource? { get set }
}
class DetailViewController: UIViewController, DetailProtocol {
#if os(iOS)
override var preferredStatusBarStyle: UIStatusBarStyle {
.lightContent
}
override var prefersStatusBarHidden: Bool {
!playerView.isMaskShow
}
private let playerView = IOSVideoPlayerView()
#elseif os(tvOS)
private let playerView = VideoPlayerView()
#else
private let playerView = CustomVideoPlayerView()
#endif
var resource: KSPlayerResource? {
didSet {
if let resource {
playerView.set(resource: resource)
}
}
}
override func viewDidLoad() {
super.viewDidLoad()
view.addSubview(playerView)
playerView.delegate = self
playerView.translatesAutoresizingMaskIntoConstraints = false
#if os(iOS)
NSLayoutConstraint.activate([
playerView.topAnchor.constraint(equalTo: view.readableContentGuide.topAnchor),
playerView.leadingAnchor.constraint(equalTo: view.leadingAnchor),
playerView.trailingAnchor.constraint(equalTo: view.trailingAnchor),
playerView.bottomAnchor.constraint(equalTo: view.bottomAnchor),
])
#else
NSLayoutConstraint.activate([
playerView.topAnchor.constraint(equalTo: view.topAnchor),
playerView.leadingAnchor.constraint(equalTo: view.leadingAnchor),
playerView.trailingAnchor.constraint(equalTo: view.trailingAnchor),
playerView.bottomAnchor.constraint(equalTo: view.bottomAnchor),
])
#endif
view.layoutIfNeeded()
playerView.backBlock = { [unowned self] in
#if os(iOS)
if UIApplication.shared.statusBarOrientation.isLandscape {
playerView.updateUI(isLandscape: false)
} else {
navigationController?.popViewController(animated: true)
}
#else
navigationController?.popViewController(animated: true)
#endif
}
playerView.becomeFirstResponder()
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
if UIDevice.current.userInterfaceIdiom == .phone {
navigationController?.setNavigationBarHidden(true, animated: true)
}
}
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
navigationController?.setNavigationBarHidden(false, animated: true)
}
}
extension DetailViewController: PlayerControllerDelegate {
func playerController(seek _: TimeInterval) {}
func playerController(state _: KSPlayerState) {}
func playerController(currentTime _: TimeInterval, totalTime _: TimeInterval) {}
func playerController(finish _: Error?) {}
func playerController(maskShow _: Bool) {
#if os(iOS)
setNeedsStatusBarAppearanceUpdate()
#endif
}
func playerController(action _: PlayerButtonType) {}
func playerController(bufferedCount _: Int, consumeTime _: TimeInterval) {}
}

View File

@@ -0,0 +1,86 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>$(MARKETING_VERSION)</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.video</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
<key>NSExceptionDomains</key>
<dict>
<key>tu.rrsub.com</key>
<dict>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSThirdPartyExceptionAllowsInsecureHTTPLoads</key>
<true/>
</dict>
</dict>
</dict>
<key>UIBackgroundModes</key>
<array>
<string>audio</string>
<string>processing</string>
<string>remote-notification</string>
</array>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UIStatusBarTintParameters</key>
<dict>
<key>UINavigationBar</key>
<dict>
<key>Style</key>
<string>UIBarStyleDefault</string>
<key>Translucent</key>
<false/>
</dict>
</dict>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<true/>
<key>defaultEnablement</key>
<string>enabled</string>
<key>requiredOnboarding</key>
<array>
<string>Tap</string>
<string>Tilt</string>
<string>Scroller drag</string>
<string>Arrow swipe</string>
<string>Trackpad capture</string>
</array>
</dict>
</plist>

View File

@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="15705" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15706"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="EHf-IW-A2E">
<objects>
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="53" y="375"/>
</scene>
</scenes>
</document>

View File

@@ -0,0 +1,40 @@
//
// MEPlayerViewController.swift
// demo-iOS
//
// Created by kintan on 2023/10/9.
// Copyright © 2023 kintan. All rights reserved.
//
import Foundation
import KSPlayer
import UIKit
class MEPlayerViewController: UIViewController {
private var player: MediaPlayerProtocol!
override func viewDidLoad() {
super.viewDidLoad()
let definition = testObjects[0].definitions[0]
player = KSMEPlayer(url: definition.url, options: definition.options)
player.delegate = self
player.view?.autoresizingMask = [.flexibleWidth, .flexibleHeight]
player.view?.frame = view.bounds
player.contentMode = .scaleAspectFill
player.prepareToPlay()
view.addSubview(player.view!)
}
}
extension MEPlayerViewController: MediaPlayerDelegate {
func readyToPlay(player: some KSPlayer.MediaPlayerProtocol) {
player.play()
}
func changeLoadState(player _: some KSPlayer.MediaPlayerProtocol) {}
func changeBuffering(player _: some KSPlayer.MediaPlayerProtocol, progress _: Int) {}
func playBack(player _: some KSPlayer.MediaPlayerProtocol, loopCount _: Int) {}
func finish(player _: some KSPlayer.MediaPlayerProtocol, error _: Error?) {}
}

View File

@@ -0,0 +1,131 @@
//
// MasterViewController.swift
// Demo
//
// Created by kintan on 2018/4/15.
// Copyright © 2018 kintan. All rights reserved.
//
import KSPlayer
import UIKit
private class TableViewCell: UITableViewCell {
var nameLabel: UILabel
override public init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
nameLabel = UILabel()
super.init(style: style, reuseIdentifier: reuseIdentifier)
contentView.addSubview(nameLabel)
nameLabel.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
nameLabel.topAnchor.constraint(equalTo: contentView.topAnchor),
nameLabel.leadingAnchor.constraint(equalTo: contentView.leadingAnchor, constant: 10),
nameLabel.trailingAnchor.constraint(equalTo: contentView.trailingAnchor),
nameLabel.bottomAnchor.constraint(equalTo: contentView.bottomAnchor),
])
}
@available(*, unavailable)
required init?(coder _: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
class MasterViewController: UIViewController {
var tableView = UITableView()
override func viewDidLoad() {
super.viewDidLoad()
navigationItem.setRightBarButton(UIBarButtonItem(barButtonSystemItem: .add, target: self, action: #selector(addURL)), animated: false)
view.addSubview(tableView)
tableView.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
tableView.topAnchor.constraint(equalTo: view.topAnchor),
tableView.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 0),
tableView.trailingAnchor.constraint(equalTo: view.trailingAnchor),
tableView.bottomAnchor.constraint(equalTo: view.bottomAnchor),
])
tableView.delegate = self
tableView.dataSource = self
tableView.rowHeight = 40
#if !os(tvOS)
tableView.separatorStyle = .singleLine
#endif
tableView.register(TableViewCell.self, forCellReuseIdentifier: "Cell")
tableView.reloadData()
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
extension MasterViewController: UITableViewDataSource {
// MARK: - Table View
func numberOfSections(in _: UITableView) -> Int {
1
}
func tableView(_: UITableView, numberOfRowsInSection _: Int) -> Int {
testObjects.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath)
if let cell = cell as? TableViewCell {
cell.nameLabel.text = testObjects[indexPath.row].name
}
return cell
}
}
extension MasterViewController: UITableViewDelegate {
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
tableView.deselectRow(at: indexPath, animated: true)
play(resource: testObjects[indexPath.row])
}
}
// MARK: - Actions
extension MasterViewController {
@objc func addURL() {
let alert = UIAlertController(title: "Enter movie URL", message: nil, preferredStyle: .alert)
alert.addTextField(configurationHandler: { testField in
testField.placeholder = "URL"
testField.text = "https://"
})
alert.addAction(UIAlertAction(title: "Play", style: .default, handler: { [weak self] _ in
guard let textFieldText = alert.textFields?.first?.text,
let url = URL(string: textFieldText)
else {
return
}
let resource = KSPlayerResource(url: url)
self?.play(resource: resource)
}))
alert.addAction(UIAlertAction(title: "Cancel", style: .cancel))
present(alert, animated: true)
}
func play(resource: KSPlayerResource?) {
if let split = splitViewController, let nav = split.viewControllers.last as? UINavigationController, let detail = nav.topViewController as? DetailProtocol {
detail.resource = resource
#if os(iOS)
detail.navigationItem.leftBarButtonItem = split.displayModeButtonItem
detail.navigationItem.leftItemsSupplementBackButton = true
#endif
split.preferredDisplayMode = .primaryHidden
return
}
let controller = DetailViewController()
controller.resource = resource
navigationController?.pushViewController(controller, animated: true)
}
}

View File

@@ -0,0 +1,120 @@
//
// RootViewController.swift
// Demo
//
// Created by kintan on 2018/4/15.
// Copyright © 2018 kintan. All rights reserved.
//
import KSPlayer
import UIKit
private class TableViewCell: UITableViewCell {
#if os(iOS)
fileprivate let playerView = IOSVideoPlayerView()
#else
fileprivate let playerView = CustomVideoPlayerView()
#endif
override public init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
contentView.addSubview(playerView)
playerView.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
contentView.heightAnchor.constraint(equalTo: contentView.widthAnchor, multiplier: 0.65),
playerView.topAnchor.constraint(equalTo: contentView.topAnchor, constant: 5),
playerView.leadingAnchor.constraint(equalTo: contentView.leadingAnchor),
playerView.trailingAnchor.constraint(equalTo: contentView.trailingAnchor),
playerView.bottomAnchor.constraint(equalTo: contentView.bottomAnchor),
])
}
@available(*, unavailable)
required init?(coder _: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
class RootViewController: UIViewController {
var tableView = UITableView()
override func viewDidLoad() {
super.viewDidLoad()
navigationItem.setRightBarButton(UIBarButtonItem(barButtonSystemItem: .add, target: self, action: #selector(addURL)), animated: false)
KSOptions.isAutoPlay = false
view.addSubview(tableView)
tableView.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
tableView.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor),
tableView.leadingAnchor.constraint(equalTo: view.leadingAnchor),
tableView.trailingAnchor.constraint(equalTo: view.trailingAnchor),
tableView.bottomAnchor.constraint(equalTo: view.bottomAnchor),
])
tableView.contentInsetAdjustmentBehavior = .never
tableView.delegate = self
tableView.dataSource = self
tableView.register(TableViewCell.self, forCellReuseIdentifier: "Cell")
tableView.reloadData()
}
#if os(iOS)
override var preferredStatusBarStyle: UIStatusBarStyle {
.lightContent
}
override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
KSOptions.supportedInterfaceOrientations
}
#endif
@objc func addURL() {
let alert = UIAlertController(title: "Enter movie URL", message: nil, preferredStyle: .alert)
alert.addTextField(configurationHandler: { testField in
testField.placeholder = "URL"
testField.text = "https://"
})
alert.addAction(UIAlertAction(title: "Play", style: .default, handler: { [weak self] _ in
guard let textFieldText = alert.textFields?.first?.text,
let url = URL(string: textFieldText)
else {
return
}
let resource = KSPlayerResource(url: url)
let controller = DetailViewController()
controller.resource = resource
self?.navigationController?.pushViewController(controller, animated: true)
}))
alert.addAction(UIAlertAction(title: "Cancel", style: .cancel))
present(alert, animated: true)
}
}
extension RootViewController: UITableViewDataSource {
func numberOfSections(in _: UITableView) -> Int {
1
}
func tableView(_: UITableView, numberOfRowsInSection _: Int) -> Int {
testObjects.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath)
if let cell = cell as? TableViewCell {
let resource = testObjects[indexPath.row]
if cell.playerView.resource != resource {
cell.playerView.set(resource: resource)
}
}
return cell
}
}
extension RootViewController: UITableViewDelegate {
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
tableView.deselectRow(at: indexPath, animated: true)
guard let cell = tableView.cellForRow(at: indexPath) as? TableViewCell else {
return
}
cell.playerView.play()
}
}

View File

@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.assets.movies.read-write</key>
<true/>
<key>com.apple.security.device.audio-input</key>
<true/>
<key>com.apple.security.files.downloads.read-write</key>
<true/>
<key>com.apple.security.files.user-selected.read-write</key>
<true/>
<key>com.apple.security.network.client</key>
<true/>
</dict>
</plist>

View File

@@ -0,0 +1,16 @@
/*
Localized.strings
demo-iOS
Created by kintan on 2020/5/23.
Copyright © 2020 kintan. All rights reserved.
*/
"speed"="倍速";
"subtitle"="字幕";
"select speed"="选择倍速";
"cancel"="取消";
"built-in subtitles"="内置字幕";
"select video quality"="选择画质";
"brightness"="亮度";
"volume"="音量";
"no show subtitle"="不显示字幕";