Update
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'dart:ui';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:fijkplayer/fijkplayer.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
@@ -14,12 +13,13 @@ import 'package:hyzp_ybqx/components/dioFun.dart';
|
||||
import 'package:hyzp_ybqx/provider/player_ratio.dart';
|
||||
import 'package:hyzp_ybqx/provider/player_region.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:fijkplayer/fijkplayer.dart';
|
||||
|
||||
import '../components/commonFun.dart';
|
||||
import '../services/Storage.dart';
|
||||
import '../my_fijkPanel_fix/my_panel3.dart';
|
||||
|
||||
const _kControlViewTypes = [kControlViewTypeDefault, kControlViewTypeWithout];
|
||||
|
||||
class SuperPlayerPage extends StatefulWidget {
|
||||
SuperPlayerPage(
|
||||
{@required this.url,
|
||||
@@ -62,10 +62,6 @@ class _SuperPlayerPageState extends State<SuperPlayerPage>
|
||||
setSphericalCameraDio(id: widget.id, dwip: widget.dwip, cmdCode: 1);
|
||||
_playerController.release(); // 必须显示释放视频播放资源,否则即使退出视频播放页面后台还在获取视频流
|
||||
super.dispose();
|
||||
_ijkPlayer.release();
|
||||
_playerController.resetPlayer();
|
||||
_playerController.release();
|
||||
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -119,7 +115,6 @@ class _SuperPlayerPageState extends State<SuperPlayerPage>
|
||||
// await _playerController.setOption(FijkOption.hostCategory, "request-screen-on", 1);
|
||||
// await _playerController.setOption(FijkOption.hostCategory, "request-audio-focus", 1);
|
||||
}
|
||||
}
|
||||
|
||||
await _playerController.setDataSource(widget.url, autoPlay: true).catchError((e) {
|
||||
print("setDataSource error: $e");
|
||||
@@ -154,7 +149,15 @@ class _SuperPlayerPageState extends State<SuperPlayerPage>
|
||||
// }
|
||||
|
||||
SuperPlayerModel get testSuperPlayerModel {
|
||||
return SuperPlayerModel(url: widget.url);
|
||||
// int appId = 1252463788;
|
||||
// String fileId = "5285890781763144364";
|
||||
|
||||
SuperPlayerModel superPlayerModel = SuperPlayerModel(
|
||||
url: widget.url,
|
||||
// appId: appId,
|
||||
// videoId: SuperPlayerVideoId(fileId: fileId),
|
||||
);
|
||||
return superPlayerModel;
|
||||
}
|
||||
|
||||
// Platform messages are asynchronous, so we initialize in an async method.
|
||||
@@ -214,6 +217,7 @@ class _SuperPlayerPageState extends State<SuperPlayerPage>
|
||||
double _outerRadius = 270;
|
||||
double _innerRadius = _outerRadius / 2;
|
||||
|
||||
//double barHeight = bFullScreen ? 0 : MediaQueryData.fromWindow(window).padding.top;
|
||||
return Scaffold(
|
||||
appBar: bFullScreen
|
||||
? null
|
||||
@@ -224,9 +228,13 @@ class _SuperPlayerPageState extends State<SuperPlayerPage>
|
||||
automaticallyImplyLeading: false,
|
||||
centerTitle: true,
|
||||
titleSpacing: 0.0,
|
||||
//设置title的左边距
|
||||
flexibleSpace: Container(
|
||||
//SizedBox(height: ScreenUtil().statusBarHeight), //显示顶部状态栏
|
||||
// SizedBox(height: ScreenUtil().setHeight(10)), //显示顶部状态栏
|
||||
padding: EdgeInsets.only(top: ScreenUtil().statusBarHeight), //留出顶部状态栏高度
|
||||
child: Container(
|
||||
//height: ScreenUtil().setHeight(173),
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
begin: Alignment.centerLeft,
|
||||
@@ -237,6 +245,12 @@ class _SuperPlayerPageState extends State<SuperPlayerPage>
|
||||
],
|
||||
),
|
||||
),
|
||||
// decoration: BoxDecoration(
|
||||
// gradient: LinearGradient(colors: [
|
||||
// Color(0xFF0018EB),
|
||||
// Color(0xFF01C1D9),
|
||||
// ], begin: Alignment.bottomCenter, end: Alignment.topCenter),
|
||||
// ),
|
||||
),
|
||||
),
|
||||
title: Padding(
|
||||
@@ -249,7 +263,7 @@ class _SuperPlayerPageState extends State<SuperPlayerPage>
|
||||
iconData: Icons.chevron_left_outlined,
|
||||
onPress: () {
|
||||
getingDwVideo = false;
|
||||
pop();
|
||||
Navigator.pop(context);
|
||||
},
|
||||
),
|
||||
Expanded(
|
||||
@@ -266,12 +280,16 @@ class _SuperPlayerPageState extends State<SuperPlayerPage>
|
||||
),
|
||||
body: WillPopScope(
|
||||
child: Container(
|
||||
// height: ScreenUtil().screenHeight -
|
||||
// ScreenUtil().statusBarHeight -
|
||||
// ScreenUtil().bottomBarHeight,
|
||||
color: Color.fromRGBO(224, 224, 224, 1),
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
//第2行组件,视频播放区
|
||||
Center(
|
||||
child: Container(
|
||||
//padding: EdgeInsets.only(top: barHeight),
|
||||
alignment: Alignment(0, -1),
|
||||
width: MediaQuery.of(context).size.width,
|
||||
height: MediaQuery.of(context).size.width * (9 / 16),
|
||||
@@ -315,6 +333,7 @@ class _SuperPlayerPageState extends State<SuperPlayerPage>
|
||||
children: [
|
||||
SizedBox(width: ScreenUtil().setWidth(btn_left)),
|
||||
getRoundButton(
|
||||
//(bPlaying) ? '暂停' : '播放',
|
||||
text: playerRegionProvide.playerText,
|
||||
icon: playerRegionProvide.playerIcon,
|
||||
diameter: 130,
|
||||
@@ -467,27 +486,41 @@ class _SuperPlayerPageState extends State<SuperPlayerPage>
|
||||
}
|
||||
},
|
||||
),
|
||||
// child: GridView.custom(
|
||||
// // padding: EdgeInsets.only(
|
||||
// // left: ScreenUtil().setWidth(35), right: ScreenUtil().setWidth(35)),
|
||||
// gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
||||
// crossAxisCount: btnCount3,
|
||||
// mainAxisSpacing: 0,
|
||||
// crossAxisSpacing: 1,
|
||||
// childAspectRatio: ratio3,
|
||||
// ),
|
||||
// childrenDelegate: SliverChildBuilderDelegate((context, position) {
|
||||
// return getItemContainer(listData[position]);
|
||||
// }, childCount: btnCount3)),
|
||||
),
|
||||
//SizedBox(height: ScreenUtil().setHeight(49)),
|
||||
//Divider(color: Colors.blue),
|
||||
//第4行组件,分隔栏
|
||||
// Container(
|
||||
// //height: 11,
|
||||
// height: ScreenUtil().setHeight(28),
|
||||
// color: Color.fromRGBO(224, 224, 224, 1),
|
||||
// ),
|
||||
],
|
||||
),
|
||||
),
|
||||
onWillPop: () {
|
||||
Playing = false;
|
||||
getingDwVideo = false;
|
||||
// 云台控制代码:1:停止动作、3:启动雨刷、11:焦距变大、12:焦距变小
|
||||
setSphericalCameraDio(id: widget.id, dwip: widget.dwip, cmdCode: 1);
|
||||
pop();
|
||||
Navigator.pop(context); //关闭弹框,播放输入视频地址
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
pop() async {
|
||||
Playing = false;
|
||||
getingDwVideo = false;
|
||||
_ijkPlayer.removeListener(() {});
|
||||
await _playerController.removeListener(this);
|
||||
Navigator.pop(context);
|
||||
}
|
||||
|
||||
@override
|
||||
void onClickFloatCloseBtn() {
|
||||
_addLog('onClickFloatCloseBtn', {});
|
||||
@@ -496,14 +529,13 @@ class _SuperPlayerPageState extends State<SuperPlayerPage>
|
||||
@override
|
||||
void onClickSmallReturnBtn() {
|
||||
_addLog('onClickSmallReturnBtn', {});
|
||||
pop();
|
||||
Navigator.maybePop(context);
|
||||
}
|
||||
|
||||
@override
|
||||
void onFullScreenChange(bool isFullScreen) {
|
||||
_addLog('onFullScreenChange', {'isFullScreen': isFullScreen});
|
||||
if (bFullScreen == isFullScreen) return;
|
||||
bFullScreen = isFullScreen;
|
||||
bFullScreen = !bFullScreen;
|
||||
setState(() {});
|
||||
}
|
||||
|
||||
@@ -542,12 +574,6 @@ class _SuperPlayerPageState extends State<SuperPlayerPage>
|
||||
_addLog('onStartFloatWindowPlay', {});
|
||||
}
|
||||
|
||||
void _fijkValueListener() {
|
||||
FijkValue value = _ijkPlayer.value;
|
||||
onPlayStateChange(value.state == FijkState.started ? 1 : 2);
|
||||
onFullScreenChange(value.fullScreen);
|
||||
}
|
||||
|
||||
//生成圆形按钮部件,基于图标
|
||||
Widget getRoundButton(
|
||||
{double diameter = 144,
|
||||
@@ -606,7 +632,13 @@ class _SuperPlayerPageState extends State<SuperPlayerPage>
|
||||
child: Image.asset(image_path,
|
||||
fit: BoxFit.fitWidth,
|
||||
width: ScreenUtil().setWidth(imageSize),
|
||||
//height: ScreenUtil().setWidth(iconSize),
|
||||
color: Color.fromRGBO(52, 157, 237, 1)),
|
||||
// child: Icon(
|
||||
// icon,
|
||||
// size: ScreenUtil().setWidth(iconSize),
|
||||
// color: Color.fromRGBO(52, 157, 237, 1),
|
||||
// ),
|
||||
decoration: BoxDecoration(
|
||||
color: color_bkg,
|
||||
borderRadius: BorderRadius.all(Radius.circular(200)),
|
||||
|
||||
Reference in New Issue
Block a user