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