包含系统画中画 -- 如果不使用系统小窗 则不需要下面配置
1 Integration Preparation
Download the project demo in advance and prepare the viewing link for the Polyv live stream to experience the full functionality.
2 Project Configuration
2.1 Configure Supported System Version
Open the project's PROJECT - Deployment Target - iOS Deployment Target and change it to 9.0 or higher.
Open the project's TARGETS - General - Deployment Info and change the iOS system to 9.0 or higher.
2.2 Configure App Transport Security (ATS)
Open the project's info.plist file and add the following content:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
<key>NSAllowsArbitraryLoadsInWebContent</key>
<true/>
</dict>
2.3 Configure Device Rotation
The player supports full-screen playback. In TARGETS - General - Deployment Info, check the supported landscape rotation orientations.
2.4 Configure Background Playback and Picture-in-Picture
Open the project's TARGETS - Signings & Capabilities, click + Capability, select Background Modes, and check 'Audio, AirPlay, and Picture in Picture'.
3 Integrate SDK
3.1 Integrate via Pod
3.1.1 Integrate PLVWebViewSDK
Add the following content to the Podfile:
pod 'PLVWebViewSDK', '~> 3.2.4'
Execute pod install in the terminal.
3.1.2 Integrate System Picture-in-Picture
If the system Picture-in-Picture feature is needed, add the following content to the Podfile:
# 包含系统画中画 -- 如果不使用系统小窗 则不需要下面配置
pod 'PLVLiveScenesWebViewPIPModule', '1.10.6.3'
Then execute pod install in the terminal.
3.2 Integrate via Offline Package
3.2.1 Integrate PLVWebViewSDK
Add the PLVWebViewSDK.framework library to your project. If integrating via source code, add the entire PLVWebViewSDK folder to your project.
3.2.2 Integrate System Picture-in-Picture
- If the project uses the system Picture-in-Picture feature, add the following libraries to the project:
PLVAliHttpDNS、PLVBusinessSDK、PLVFoundationSDK、PLVIJKPlayer、PLVLiveScenesSDK
In General => Frameworks, Libraries, and Embedded Content, remove the already added PLVFoundationSDK.framework, PLVLiveScenesSDK.framework, and PLVBusinessSDK.framework libraries, and add the system library libresolv.tbd.
Set PLVIJKPlayer to Embed & Sign.
In Build Settings, add -ObjC to Other Linker Flags. If already configured, no need to add again.
Runtime Errors
If the simulator reports an error, set Excluded Architecture => Any iOS Simulator SDK to arm64 in Build Settings.
If a runtime error occurs:
Building for iOS Simulator, but the linked and embedded framework '***' was built for iOS + tvOS Simulator
Set VALIDATE_WORKSPACE to YES in Build Settings.
4 Code Invocation
Create a controller page DemoViewController that inherits from PLVWebViewBaseViewController to display the WebView, and use the initialization method -initWithConfig: to create the controller page. Example code is as follows:
// PLVWebViewDemoViewController.h
#import <PLVWebViewSDK/PLVWebViewSDK.h>
@interface PLVWebViewDemoViewController : PLVWebViewBaseViewController
@end
During initialization, custom configurations can be made by overriding initHandleForDemo, and Bridge events can be handled customarily. Example code is as follows:
// PLVWebViewDemoViewController.m
@implementation PLVWebViewDemoViewController
#pragma mark - [ Override ]
- (void)viewDidLoad {
[super viewDidLoad];
}
/// 初始化时,可以进行的自定义配置
//- (void)initHandleForDemo {
//
//}
#pragma mark - [ Delegate ]
#pragma mark PLVFloatableWebViewBridgeDelegate
/// 如需要监听 js 回调事件,可以通过Delegate事件进行相应的处理,例如webviewBridgeShare消息
//- (void)webviewBridgeShare:(PLVFloatableWebViewBridge *)bridge {
//
//}
@end
Create, configure, and open the live stream page controller:
PLVWebViewConfig *config = [[PLVWebViewConfig alloc] init];
config.urlString = urlString;
config.allowFloatingWindow = YES;
config.isSystemFloatingWindow = NO;
config.userAgent = self.uaTextView.text;
config.enableAutoFloatWindow = YES;
PLVWebViewDemoViewController *webVC = [[PLVWebViewDemoViewController alloc] initWithConfig:config];
[self.navigationController pushViewController:webVC animated:YES];
