| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- //
- // ScreenStreamPlugin.m
- // Runner
- //
- // Created by Drew on 2019/5/9.
- // Copyright © 2019 The Chromium Authors. All rights reserved.
- //
- #import "ScreenStreamPlugin.h"
- #import <ReplayKit/ReplayKit.h>
- #import <NotificationCenter/NotificationCenter.h>
- @interface ScreenStreamPlugin() <FlutterPlugin>
- @property (nonatomic) UIViewController *viewController;
- @end
- @implementation ScreenStreamPlugin
- + (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar>*)registrar {
-
- FlutterMethodChannel* channel = [FlutterMethodChannel
- methodChannelWithName:@"screen_stream"
- binaryMessenger:[registrar messenger]];
- UIViewController *viewController = [UIApplication sharedApplication].delegate.window.rootViewController;
- ScreenStreamPlugin* instance = [[ScreenStreamPlugin alloc] initWithViewController:viewController];
- [registrar addMethodCallDelegate:instance channel:channel];
- }
- - (instancetype)initWithViewController:(UIViewController *)viewController {
- self = [super init];
- if(self) {
- self.viewController = viewController;
- }
- return self;
- }
- - (void)handleMethodCall:(FlutterMethodCall *)call result:(FlutterResult)result {
- if ([@"start" isEqualToString:call.method]) {
- NSString *playerInfoId = [call.arguments[@"playerInfoId"] stringValue];
- NSString *rtmpUrl = [NSString stringWithFormat:@"rtmp://47.96.141.102:1935/myapp/%@", playerInfoId];
- NSUserDefaults *userDefaults = [[NSUserDefaults alloc] initWithSuiteName:@"group.com.izouma.wnnaBattle"];
- [userDefaults setValue:rtmpUrl forKey:@"rtmpUrl"];
- [userDefaults synchronize];
- CFNotificationCenterPostNotification(CFNotificationCenterGetDarwinNotifyCenter(), CFSTR("PUSH_START"), NULL, nil, YES);
-
- if (@available(iOS 12.0, *) ) {
-
- }
- result(@"success");
- } else if ([@"stop" isEqualToString:call.method]) {
- NSUserDefaults *userDefaults = [[NSUserDefaults alloc] initWithSuiteName:@"group.com.izouma.wnnaBattle"];
- [userDefaults removeObjectForKey:@"rtmpUrl"];
- CFNotificationCenterPostNotification(CFNotificationCenterGetDarwinNotifyCenter(), CFSTR("PUSH_STOP"), NULL, nil, YES);
- result(@"success");
- } else if ([@"prepare" isEqualToString:call.method]) {
- result(@"success");
- }
- }
- @end
|