提交 fc750bf3 authored 作者: kongdywang's avatar kongdywang

1. Adjust the layout of the player component demo page.

2. The Picture-in-Picture button icon in Android can be hidden by passing an empty string. 3. Fix an issue with the player component where the player listener remained on the portrait page after entering full-screen mode. Also, optimize the interaction logic of the player component.
上级 3dd282ba
......@@ -17,13 +17,20 @@ buildLog "config success on flutter lib pubspec version"
buildLog "start config flutter lib code version"
sed -i "" "s/PLAYER_VERSION = \"[0-9.]*\"/PLAYER_VERSION = \"$VERSION_NAME\"/" ../lib/Core/common/common_config.dart
buildLog "config success on flutter lib code version"
buildLog "start config flutter superplayer_widget pubspec version"
sed -i "" "s/version:.*$/version: $VERSION_NAME/" ../superplayer_widget/pubspec.yaml
buildLog "config success on superplayer_widget pubspec version"
buildLog "start config plugin android version"
sed -i "" "s/playerVersion = \"[0-9.]*\"/playerVersion = \"$VERSION_NAME\"/" ../android/config.gradle
buildLog "config success on plugin android version"
buildLog "start config plugin ios version"
sed -i "" "s/s.version = '[0-9.]*'/s.version = '$VERSION_NAME'/" ../ios/super_player.podspec
buildLog "config success on plugin ios version"
buildLog "config Version=${VERSION_NAME} done"
\ No newline at end of file
#buildLog "start config flutter superplayer_widget pubspec version"
#sed -i "" "s/version:.*$/version: $VERSION_NAME/" ../superplayer_widget/pubspec.yaml
#buildLog "config success on superplayer_widget pubspec version"
buildLog "start config playerWidget pubspec version"
sed -i "" "s/version:.*$/version: $VERSION_NAME/" ../../FlutterWidget/superplayer_widget/pubspec.yaml
buildLog "config success on playerWidget pubspec version"
buildLog "start config playerWidget config version"
sed -i "" "s/PLAYER_WIDGET_VERSION = \"[0-9.]*\"/PLAYER_WIDGET_VERSION = \"$VERSION_NAME\"/" ../../FlutterWidget/superplayer_widget/lib/common/player_constants.dart
buildLog "config success on playerWidget config version"
buildLog "config Version=${VERSION_NAME} done"
......@@ -4,7 +4,7 @@ rootProject.ext {
supportSdkVersion = "26.0.1"
minSdkVersion = 19
targetSdkVersion = 28
playerVersion = '12.3.2'
playerVersion = "12.3.2"
compat = "androidx.appcompat:appcompat:1.6.1"
/**
......
......@@ -325,9 +325,12 @@ public class FTXPIPManager implements TXSimpleEventBus.EventSubscriber, FtxMessa
* 播放器id
*/
public PipParams(String mPlayBackAssetPath, String mPlayResumeAssetPath, String mPlayPauseAssetPath,
String mPlayForwardAssetPath, int mCurrentPlayerId) {
String mPlayForwardAssetPath, int mCurrentPlayerId) {
this(mPlayBackAssetPath, mPlayResumeAssetPath, mPlayPauseAssetPath, mPlayForwardAssetPath,
mCurrentPlayerId, true, true, true);
mCurrentPlayerId, !TXCommonUtil.isBlankStr(mPlayBackAssetPath),
!TXCommonUtil.isBlankStr(mPlayForwardAssetPath)
, !TXCommonUtil.isBlankStr(mPlayResumeAssetPath)
&& !TXCommonUtil.isBlankStr(mPlayPauseAssetPath));
}
public PipParams(String mPlayBackAssetPath, String mPlayResumeAssetPath, String mPlayPauseAssetPath,
......@@ -403,7 +406,7 @@ public class FTXPIPManager implements TXSimpleEventBus.EventSubscriber, FtxMessa
return mViewHeight;
}
private AtomicInteger a = new AtomicInteger();
private final AtomicInteger mActionIdGenerator = new AtomicInteger();
/**
* Construct PIP parameters.
......@@ -435,7 +438,7 @@ public class FTXPIPManager implements TXSimpleEventBus.EventSubscriber, FtxMessa
.putExtras(playOrPauseData)
.setPackage(activity.getPackageName());
Icon playIcon = mIsPlaying ? getPauseIcon(activity) : getPlayIcon(activity);
PendingIntent playIntent = PendingIntent.getBroadcast(activity, a.incrementAndGet(),
PendingIntent playIntent = PendingIntent.getBroadcast(activity, mActionIdGenerator.incrementAndGet(),
playOrPauseIntent, PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_MUTABLE);
RemoteAction playOrPauseAction = new RemoteAction(playIcon, "playOrPause", "play Or Pause", playIntent);
actions.add(playOrPauseAction);
......
......@@ -167,4 +167,11 @@ public class TXCommonUtil {
msg.setValue(value);
return msg;
}
public static boolean isBlankStr(String value) {
if (null == value) {
return false;
}
return value.trim().isEmpty();
}
}
......@@ -172,17 +172,18 @@ class _DemoSuperPlayerState extends State<DemoSuperPlayer> with TXPipPlayerResto
}
Widget getBody() {
return SingleChildScrollView(
child: LayoutBuilder(builder: (context, constrains) {
return Container(
constraints: BoxConstraints(
maxHeight: MediaQuery.of(context).size.height
),
child: Column(
children: [_getPlayArea(), Expanded(flex: 1, child: _getListArea()), _getAddArea()],
),
);
}),
return Container(
constraints: BoxConstraints(maxHeight: MediaQuery.of(context).size.height),
child: Column(
children: [
_getPlayArea(),
Expanded(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [getTabRow(), _getListArea(), _getAddArea()],
))
],
),
);
}
......@@ -195,21 +196,14 @@ class _DemoSuperPlayerState extends State<DemoSuperPlayer> with TXPipPlayerResto
}
Widget _getListArea() {
return Container(
margin: EdgeInsets.only(top: 10),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
children: [
getTabRow(),
Expanded(
child: ListView.builder(
return Expanded(
child: Container(
margin: EdgeInsets.only(top: 10),
child: ListView.builder(
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
itemCount: videoModels.length,
itemBuilder: (context, i) => _buildVideoItem(videoModels[i]),
))
],
));
)));
}
Widget _buildVideoItem(SuperPlayerModel playModel) {
......
......@@ -4,7 +4,7 @@
#
Pod::Spec.new do |s|
s.name = 'super_player'
s.version = '12.3.2'
s.version = '12.3.2'
s.summary = 'The super_player Flutter plugin is one of the sub-product SDKs of the audio/video terminal SDK (Tencent Cloud Video on Demand).'
s.description = <<-DESC
player plugin.
......
......@@ -3,4 +3,5 @@ part of demo_super_player_lib;
class PlayerConstants {
static const PKG_NAME = "superplayer_widget";
static const String PLAYER_WIDGET_VERSION = "12.3.2";
}
......@@ -30,8 +30,8 @@ class SuperPlayerController {
TXSubtitleRenderModel? _currentSubtitleRenderModel;
SuperPlayerState playerState = SuperPlayerState.INIT;
SuperPlayerType playerType = SuperPlayerType.VOD;
FTXVodPlayConfig _vodConfig = FTXVodPlayConfig();
FTXLivePlayConfig _liveConfig = FTXLivePlayConfig();
FTXVodPlayConfig vodConfig = FTXVodPlayConfig();
FTXLivePlayConfig liveConfig = FTXLivePlayConfig();
StreamSubscription? _vodPlayEventListener;
StreamSubscription? _vodNetEventListener;
StreamSubscription? _livePlayEventListener;
......@@ -53,6 +53,7 @@ class SuperPlayerController {
bool _isOpenHWAcceleration = true;
int _playerUIStatus = SuperPlayerUIStatus.WINDOW_MODE;
final BuildContext _context;
FullScreenController fullScreenController = FullScreenController();
double currentDuration = 0;
double videoDuration = 0;
......@@ -345,6 +346,7 @@ class SuperPlayerController {
/// 正式版 License 需[购买]
/// (https://cloud.tencent.com/document/product/881/74588#.E8.B4.AD.E4.B9.B0.E5.B9.B6.E6.96.B0.E5.BB.BA.E6.AD.A3.E5.BC.8F.E7.89.88-license)。
Future<void> playWithModelNeedLicence(SuperPlayerModel videoModel) async {
LogUtils.i(TAG, "widget version:${PlayerConstants.PLAYER_WIDGET_VERSION}");
this.videoModel = videoModel;
_playAction = videoModel.playAction;
await stopPlay();
......@@ -790,14 +792,14 @@ class SuperPlayerController {
/// Configure the VOD player.
/// 配置点播播放器
Future<void> setPlayConfig(FTXVodPlayConfig config) async {
_vodConfig = config;
vodConfig = config;
await _vodPlayerController.setConfig(config);
}
/// Configure the Live player.
/// 配置直播播放器
Future<void> setLiveConfig(FTXLivePlayConfig config) async {
_liveConfig = config;
liveConfig = config;
await _livePlayerController.setConfig(config);
}
......@@ -902,3 +904,56 @@ class SuperPlayerController {
return playerState;
}
}
class FullScreenController {
bool _isInFullScreenUI = false;
int currentOrientation = TXVodPlayEvent.ORIENTATION_PORTRAIT_UP;
Function? onEnterFullScreenUI;
Function? onExitFullScreenUI;
FullScreenController();
void switchToOrientation(int orientationDirection) {
if (currentOrientation != orientationDirection) {
forceSwitchOrientation(orientationDirection);
}
}
void forceSwitchOrientation(int orientationDirection) {
currentOrientation = orientationDirection;
if (orientationDirection == TXVodPlayEvent.ORIENTATION_PORTRAIT_UP) {
exitFullScreen();
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: SystemUiOverlay.values);
} else if (orientationDirection == TXVodPlayEvent.ORIENTATION_LANDSCAPE_RIGHT) {
enterFullScreen();
SystemChrome.setPreferredOrientations(Platform.isIOS ? [DeviceOrientation.landscapeRight] : [DeviceOrientation.landscapeLeft]);
SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersive);
} else if (orientationDirection == TXVodPlayEvent.ORIENTATION_PORTRAIT_DOWN) {
} else if (orientationDirection == TXVodPlayEvent.ORIENTATION_LANDSCAPE_LEFT) {
SystemChrome.setPreferredOrientations(Platform.isIOS ? [DeviceOrientation.landscapeLeft] : [DeviceOrientation.landscapeRight]);
SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersive);
enterFullScreen();
}
}
void enterFullScreen() {
if (!_isInFullScreenUI) {
_isInFullScreenUI = true;
onEnterFullScreenUI?.call();
}
}
void exitFullScreen() {
if (_isInFullScreenUI) {
_isInFullScreenUI = false;
onExitFullScreenUI?.call();
}
}
void setListener(Function enterFullScreen, Function exitFullScreen) {
onExitFullScreenUI = exitFullScreen;
onEnterFullScreenUI = enterFullScreen;
}
}
......@@ -3,7 +3,6 @@ part of demo_super_player_lib;
const topBottomOffset = 0.0;
int manualOrientationDirection = TXVodPlayEvent.ORIENTATION_LANDSCAPE_RIGHT;
FullScreenController _fullScreenController = FullScreenController();
/// superPlayer view widget
class SuperPlayerView extends StatefulWidget {
......@@ -159,9 +158,10 @@ class SuperPlayerViewState extends State<SuperPlayerView> with WidgetsBindingObs
// Do not rotate the screen in picture-in-picture mode.
if (eventCode == TXVodPlayEvent.EVENT_ORIENTATION_CHANGED && !_isFloatingMode) {
int orientation = event[TXVodPlayEvent.EXTRA_NAME_ORIENTATION];
_fullScreenController.switchToOrientation(orientation);
_playController.fullScreenController.switchToOrientation(orientation);
}
});
_registerObserver();
_initPlayerState();
connectPlayerView();
}
......@@ -268,7 +268,7 @@ class SuperPlayerViewState extends State<SuperPlayerView> with WidgetsBindingObs
// onDispose
_playController._observer = null; // close observer
});
_fullScreenController.setListener(() async {
_playController.fullScreenController.setListener(() async {
// enter full screen
if (null != downloadListener) {
DownloadHelper.instance.removeDownloadListener(downloadListener!);
......@@ -285,11 +285,6 @@ class SuperPlayerViewState extends State<SuperPlayerView> with WidgetsBindingObs
// exit full screen
// refresh render view
Navigator.of(context).pop();
_playController._updatePlayerUIStatus(SuperPlayerUIStatus.WINDOW_MODE);
_videoBottomKey.currentState?.updateUIStatus(SuperPlayerUIStatus.WINDOW_MODE);
_videoTitleKey.currentState?.updateUIStatus(SuperPlayerUIStatus.WINDOW_MODE);
hideControlView();
_videoKey.currentState?.resetController();
});
WidgetsBinding.instance.removeObserver(this);
WidgetsBinding.instance.addObserver(this);
......@@ -366,16 +361,21 @@ class SuperPlayerViewState extends State<SuperPlayerView> with WidgetsBindingObs
void _refreshUI() async {
WidgetsBinding.instance.addPostFrameCallback((_) {
_updateState();
connectPlayerView();
_restoreToWindowMode();
_registerObserver();
setState(() {
connectPlayerView();
_initPlayerState();
});
});
}
void _updateState() {
// Refresh the binding of the observer.
_registerObserver();
_initPlayerState();
_calculateSize(_playController.videoWidth, _playController.videoHeight);
void _restoreToWindowMode() {
_playController._updatePlayerUIStatus(SuperPlayerUIStatus.WINDOW_MODE);
_videoBottomKey.currentState?.updateUIStatus(SuperPlayerUIStatus.WINDOW_MODE);
_videoTitleKey.currentState?.updateUIStatus(SuperPlayerUIStatus.WINDOW_MODE);
hideControlView();
_videoKey.currentState?.resetController();
}
void _refreshDownloadStatus() async {
......@@ -395,7 +395,7 @@ class SuperPlayerViewState extends State<SuperPlayerView> with WidgetsBindingObs
Orientation currentOrientation = MediaQuery.of(context).orientation;
bool isLandscape = currentOrientation == Orientation.landscape;
if (!isLandscape) {
_fullScreenController.forceSwitchOrientation(manualOrientationDirection);
_playController.fullScreenController.forceSwitchOrientation(manualOrientationDirection);
}
}
} else if (state == AppLifecycleState.inactive) {
......@@ -466,7 +466,7 @@ class SuperPlayerViewState extends State<SuperPlayerView> with WidgetsBindingObs
@override
Widget build(BuildContext context) {
_updateState();
_calculateSize(_playController.videoWidth, _playController.videoHeight);
return Center(
child: widget.renderMode == SuperPlayerRenderMode.ADJUST_RESOLUTION ?
IntrinsicHeight(
......@@ -736,9 +736,9 @@ class SuperPlayerViewState extends State<SuperPlayerView> with WidgetsBindingObs
void _handleFullScreen(bool toSwitchFullScreen) {
if (toSwitchFullScreen) {
_fullScreenController.switchToOrientation(manualOrientationDirection);
_playController.fullScreenController.switchToOrientation(manualOrientationDirection);
} else {
_fullScreenController.switchToOrientation(TXVodPlayEvent.ORIENTATION_PORTRAIT_UP);
_playController.fullScreenController.switchToOrientation(TXVodPlayEvent.ORIENTATION_PORTRAIT_UP);
}
}
......@@ -901,6 +901,7 @@ class SuperPlayerFullScreenState extends State<SuperPlayerFullScreenView> {
@override
void dispose() {
widget._playController.fullScreenController._isInFullScreenUI = false;
widget.controller.onExitFullScreen();
super.dispose();
}
......@@ -911,55 +912,3 @@ class SuperPlayerFullScreenController {
SuperPlayerFullScreenController(this.onExitFullScreen);
}
class FullScreenController {
bool _isInFullScreenUI = false;
int currentOrientation = TXVodPlayEvent.ORIENTATION_PORTRAIT_UP;
Function? onEnterFullScreenUI;
Function? onExitFullScreenUI;
FullScreenController();
void switchToOrientation(int orientationDirection) {
if (currentOrientation != orientationDirection) {
forceSwitchOrientation(orientationDirection);
}
}
void forceSwitchOrientation(int orientationDirection) {
currentOrientation = orientationDirection;
if (orientationDirection == TXVodPlayEvent.ORIENTATION_PORTRAIT_UP) {
exitFullScreen();
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: SystemUiOverlay.values);
} else if (orientationDirection == TXVodPlayEvent.ORIENTATION_LANDSCAPE_RIGHT) {
enterFullScreen();
SystemChrome.setPreferredOrientations(Platform.isIOS ? [DeviceOrientation.landscapeRight] : [DeviceOrientation.landscapeLeft]);
SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersive);
} else if (orientationDirection == TXVodPlayEvent.ORIENTATION_PORTRAIT_DOWN) {
} else if (orientationDirection == TXVodPlayEvent.ORIENTATION_LANDSCAPE_LEFT) {
SystemChrome.setPreferredOrientations(Platform.isIOS ? [DeviceOrientation.landscapeLeft] : [DeviceOrientation.landscapeRight]);
SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersive);
enterFullScreen();
}
}
void enterFullScreen() {
if (!_isInFullScreenUI) {
_isInFullScreenUI = true;
onEnterFullScreenUI?.call();
}
}
void exitFullScreen() {
if (_isInFullScreenUI) {
_isInFullScreenUI = false;
onExitFullScreenUI?.call();
}
}
void setListener(Function enterFullScreen, Function exitFullScreen) {
onExitFullScreenUI = exitFullScreen;
onEnterFullScreenUI = enterFullScreen;
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论