提交 0e174025 authored 作者: kongdywang's avatar kongdywang

Merge branch 'main' of https://github.com/tencentyun/SuperPlayer into main

Conflicts: Flutter/android/src/main/java/com/example/super_player/SuperPlatformPlayerView.java Flutter/lib/Core/txplayer_define.dart
package com.example.super_player; package com.example.super_player;
import android.content.Context; import android.content.Context;
import android.os.Bundle;
import android.view.View; import android.view.View;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
...@@ -12,8 +13,10 @@ import com.tencent.liteav.demo.superplayer.SuperPlayerView; ...@@ -12,8 +13,10 @@ import com.tencent.liteav.demo.superplayer.SuperPlayerView;
import com.tencent.rtmp.TXLiveBase; import com.tencent.rtmp.TXLiveBase;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set;
import io.flutter.embedding.engine.plugins.FlutterPlugin; import io.flutter.embedding.engine.plugins.FlutterPlugin;
import io.flutter.plugin.common.EventChannel; import io.flutter.plugin.common.EventChannel;
...@@ -90,42 +93,42 @@ public class SuperPlatformPlayerView implements PlatformView, MethodChannel.Meth ...@@ -90,42 +93,42 @@ public class SuperPlatformPlayerView implements PlatformView, MethodChannel.Meth
@Override @Override
public void onStartFullScreenPlay() { public void onStartFullScreenPlay() {
mEventSink.success("onStartFullScreenPlay"); mEventSink.success(getParams("onStartFullScreenPlay", null));
} }
@Override @Override
public void onStopFullScreenPlay() { public void onStopFullScreenPlay() {
mEventSink.success("onStopFullScreenPlay"); mEventSink.success(getParams("onStopFullScreenPlay", null));
} }
@Override @Override
public void onClickFloatCloseBtn() { public void onClickFloatCloseBtn() {
mEventSink.success("onClickFloatCloseBtn"); mEventSink.success(getParams("onClickFloatCloseBtn",null));
} }
@Override @Override
public void onSuperPlayerBackAction() { public void onSuperPlayerBackAction() {
mEventSink.success("onSuperPlayerBackAction"); mEventSink.success(getParams("onSuperPlayerBackAction", null));
} }
@Override @Override
public void onStartFloatWindowPlay() { public void onStartFloatWindowPlay() {
mEventSink.success("onStartFloatWindowPlay"); mEventSink.success(getParams("onStartFloatWindowPlay",null));
} }
@Override @Override
public void onSuperPlayerDidStart() { public void onSuperPlayerDidStart() {
mEventSink.success("onSuperPlayerDidStart"); mEventSink.success(getParams("onSuperPlayerDidStart",null));
} }
@Override @Override
public void onSuperPlayerDidEnd() { public void onSuperPlayerDidEnd() {
mEventSink.success("onSuperPlayerDidEnd"); mEventSink.success(getParams("onSuperPlayerDidEnd",null));
} }
@Override @Override
public void onSuperPlayerError() { public void onSuperPlayerError() {
mEventSink.success("onSuperPlayerError"); mEventSink.success(getParams("onSuperPlayerError",null));
} }
@Override @Override
...@@ -259,4 +262,22 @@ public class SuperPlatformPlayerView implements PlatformView, MethodChannel.Meth ...@@ -259,4 +262,22 @@ public class SuperPlatformPlayerView implements PlatformView, MethodChannel.Meth
public void setLoop(boolean b) { public void setLoop(boolean b) {
mSuperPlayerView.setLoop(b); mSuperPlayerView.setLoop(b);
} }
private Map<String, Object> getParams(String event, Bundle bundle) {
Map<String, Object> param = new HashMap();
if (!event.isEmpty()) {
param.put("event", event);
}
if (bundle != null && !bundle.isEmpty()) {
Set<String> keySet = bundle.keySet();
for (String key : keySet) {
Object val = bundle.get(key);
param.put(key, val);
}
}
return param;
}
} }
...@@ -115,23 +115,35 @@ class _TestSuperPlayerState extends State<TestSuperPlayer> { ...@@ -115,23 +115,35 @@ class _TestSuperPlayerState extends State<TestSuperPlayer> {
_playerController.setPlayConfig(_playerConfig); _playerController.setPlayConfig(_playerConfig);
_playerController.onPlayerEventBroadcast.listen((event) { _playerController.onPlayerEventBroadcast.listen((event) {
setState(() { setState(() {
if (event == SuperPlayerViewEvent.onStartFullScreenPlay) { String evtName = event["event"];
_isFullSceen = true; if (evtName == SuperPlayerViewEvent.onStartFullScreenPlay) {
AutoOrientation.landscapeAutoMode(); if (defaultTargetPlatform == TargetPlatform.android) {
_isFullSceen = true;
///关闭状态栏,与底部虚拟操作按钮 AutoOrientation.landscapeAutoMode();
SystemChrome.setEnabledSystemUIOverlays([]);
} else { ///关闭状态栏,与底部虚拟操作按钮
_isFullSceen = false; SystemChrome.setEnabledSystemUIOverlays([]);
}
/// 如果是全屏就切换竖屏 print("onStartFullScreenPlay");
AutoOrientation.portraitAutoMode(); } else if (evtName == SuperPlayerViewEvent.onStopFullScreenPlay){
if (defaultTargetPlatform == TargetPlatform.android) {
///显示状态栏,与底部虚拟操作按钮 _isFullSceen = false;
SystemChrome.setEnabledSystemUIOverlays(
[SystemUiOverlay.top, SystemUiOverlay.bottom]); /// 如果是全屏就切换竖屏
AutoOrientation.portraitAutoMode();
///显示状态栏,与底部虚拟操作按钮
SystemChrome.setEnabledSystemUIOverlays(
[SystemUiOverlay.top, SystemUiOverlay.bottom]);
}
print("onStopFullScreenPlay");
} else if (evtName == SuperPlayerViewEvent.onSuperPlayerBackAction) {
print("onSuperPlayerBackAction");
} else {
print(evtName);
}
} }
}); );
}); });
_initPlayer.complete(true); _initPlayer.complete(true);
}, },
......
...@@ -286,40 +286,50 @@ ...@@ -286,40 +286,50 @@
/// 返回事件 /// 返回事件
- (void)superPlayerBackAction:(SuperPlayerView *)player - (void)superPlayerBackAction:(SuperPlayerView *)player
{ {
[_eventSink success:[self getParamsWithEvent:@"onSuperPlayerBackAction" withParams:@{}]];
} }
/// 全屏改变通知 /// 全屏改变通知
- (void)superPlayerFullScreenChanged:(SuperPlayerView *)player - (void)superPlayerFullScreenChanged:(SuperPlayerView *)player
{ {
UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation; if (!player.isFullScreen) {
[_eventSink success:[self getParamsWithEvent:@"onStopFullScreenPlay" withParams:@{}]];
if (orientation == UIInterfaceOrientationPortrait) {
[_eventSink success:@"onStopFullScreenPlay"];
}else { }else {
[_eventSink success:@"onStartFullScreenPlay"]; [_eventSink success:[self getParamsWithEvent:@"onStartFullScreenPlay" withParams:@{}]];
} }
} }
/// 播放开始通知 /// 播放开始通知
- (void)superPlayerDidStart:(SuperPlayerView *)player; - (void)superPlayerDidStart:(SuperPlayerView *)player;
{ {
[_eventSink success:[self getParamsWithEvent:@"onSuperPlayerDidStart" withParams:@{}]];
} }
/// 播放结束通知 /// 播放结束通知
- (void)superPlayerDidEnd:(SuperPlayerView *)player - (void)superPlayerDidEnd:(SuperPlayerView *)player
{ {
[_eventSink success:[self getParamsWithEvent:@"onSuperPlayerDidEnd" withParams:@{}]];
} }
/// 播放错误通知 /// 播放错误通知
- (void)superPlayerError:(SuperPlayerView *)player errCode:(int)code errMessage:(NSString *)why; - (void)superPlayerError:(SuperPlayerView *)player errCode:(int)code errMessage:(NSString *)why;
{ {
[_eventSink success:[self getParamsWithEvent:@"onSuperPlayerError" withParams:@{
@"errCode":@(code),
@"errMessage":why
}]];
} }
// 需要通知到父view的事件在此添加 // 需要通知到父view的事件在此添加
- (NSDictionary *)getParamsWithEvent:(NSString *)evtName withParams:(NSDictionary *)params
{
NSMutableDictionary<NSString*,NSObject*> *dict = [NSMutableDictionary dictionaryWithObject:evtName forKey:@"event"];
if (params != nil && params.count != 0) {
[dict addEntriesFromDictionary:params];
}
return dict;
}
+ (UINavigationController *)currentNavigationController + (UINavigationController *)currentNavigationController
{ {
......
...@@ -4,9 +4,9 @@ part of SuperPlayer; ...@@ -4,9 +4,9 @@ part of SuperPlayer;
class SuperPlayerPlatformViewController { class SuperPlayerPlatformViewController {
MethodChannel _channel; MethodChannel _channel;
StreamSubscription _eventSubscription; StreamSubscription _eventSubscription;
final StreamController<String> _eventStreamController = final StreamController<Map<dynamic, dynamic>> _eventStreamController =
StreamController.broadcast(); StreamController.broadcast();
Stream<String> get onPlayerEventBroadcast => _eventStreamController.stream; Stream<Map<dynamic, dynamic>> get onPlayerEventBroadcast => _eventStreamController.stream;
SuperPlayerPlatformViewController.init(int id) { SuperPlayerPlatformViewController.init(int id) {
_channel = new MethodChannel('cloud.tencent.com/superPlayer/$id'); _channel = new MethodChannel('cloud.tencent.com/superPlayer/$id');
...@@ -18,21 +18,6 @@ class SuperPlayerPlatformViewController { ...@@ -18,21 +18,6 @@ class SuperPlayerPlatformViewController {
_eventHandler(event) { _eventHandler(event) {
if(event == null) return; if(event == null) return;
if(event is String) {
print("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
print(event);
print("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
switch(event) {
case SuperPlayerViewEvent.onStartFullScreenPlay:
break;
case SuperPlayerViewEvent.onStopFullScreenPlay:
break;
case SuperPlayerViewEvent.onSuperPlayerBackAction:
break;
}
}
_eventStreamController.add(event); _eventStreamController.add(event);
} }
......
...@@ -53,14 +53,12 @@ enum TXPlayerEvent{ ...@@ -53,14 +53,12 @@ enum TXPlayerEvent{
} }
abstract class SuperPlayerViewEvent{ abstract class SuperPlayerViewEvent{
static const onStartFullScreenPlay = "onStartFullScreenPlay"; // 进入全屏播放 static const onStartFullScreenPlay = "onStartFullScreenPlay";//进入全屏播放
static const onStopFullScreenPlay = "onStopFullScreenPlay"; // 退出全屏播放 static const onStopFullScreenPlay = "onStopFullScreenPlay";//退出全屏播放
static const onSuperPlayerBackAction = "onSuperPlayerBackAction"; // 窗口模式触发左上角返回按钮 static const onSuperPlayerDidStart = "onSuperPlayerDidStart";//播放开始通知
static const onClickFloatCloseBtn = "onClickFloatCloseBtn"; // 浮窗模式触发关闭按钮 static const onSuperPlayerDidEnd = "onSuperPlayerDidEnd";//播放结束通知
static const onStartFloatWindowPlay = "onStartFloatWindowPlay"; // 开始进入浮窗模式 static const onSuperPlayerError = "onSuperPlayerError";//播放错误通知
static const onSuperPlayerDidStart = "onSuperPlayerDidStart"; // 播放开始通知 static const onSuperPlayerBackAction = "onSuperPlayerBackAction";//返回事件
static const onSuperPlayerDidEnd = "onSuperPlayerDidEnd"; // 播放结束通知
static const onSuperPlayerPause = "onSuperPlayerPause"; // 播放暂停通知
} }
class SuperPlayerUrl { class SuperPlayerUrl {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论