hsp_aliplayer 0.0.1 hsp_aliplayer: ^0.0.1 copied to clipboard
基于阿里云播放器封装.
目前支持的视频格式有播放mp4,m3u8和直播; 功能:支持全屏、清晰度、播放速率,选集功能 使用方法: 1、引入 import 'package:hsp_aliplayer/hsp_aliplayer.dart'; 2、要使用OrientationBuilder这个widget监听屏幕方向并传入HspAliPlayer
HspAliPlayer(
//具体参照阿里云播放器文档,一般不用改变
playMode: ModeType.URL,
//视频链接
dataSourceMap:{DataSourceRelated.URL_KEY:'https://b.mhqiyi.com/20201120/bV8stIAo/index.m3u8'},
//OrientationBuilder的参数
orientation: _orientation,
),
3、建议播放器以外的内容用屏幕方向判断一下,横屏时候隐藏
4、完整代码
import 'package:flutter/material.dart';
import 'package:flutterapp/pages/home/videoDetail/widgets/small_video_page.dart';
import 'package:flutter_tencentplayer/flutter_tencentplayer.dart';
import 'package:flutterapp/util/index.dart';
import 'package:flutterapp/pages/home/videoDetail/widgets/smallWindow.dart';
import 'package:hsp_aliplayer/hsp_aliplayer.dart';
class VideoDetailPage extends StatefulWidget {
@override
_VideoDetailPageState createState() => _VideoDetailPageState();
}
class _VideoDetailPageState extends State<VideoDetailPage> {
@override
Widget build(BuildContext context) {
Orientation _orientation = MediaQuery.of(context).orientation;//获取屏幕方向
return OrientationBuilder(
builder: (BuildContext context,Orientation orientation){
return Scaffold(
body: Container(
color: HspColor.themeColor,
child: Column(
children: [
//小窗视频
HspAliPlayer(
playMode: ModeType.URL,
dataSourceMap:{DataSourceRelated.URL_KEY: 'https://b.mhqiyi.com/20201120/bV8stIAo/index.m3u8'},
orientation: _orientation,
),
// SmallVideoPage(),
Offstage(
offstage: _orientation==Orientation.landscape,
child: Container(
padding: EdgeInsets.all(HspSize.set(10)),
child: Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Container(
child: Text("送你一朵小红花",style: TextStyle(color: HspColor.fontColor,fontWeight: FontWeight.w600,fontSize: HspSize.set(18)),),
),
Container(
child: Text("简介》",style: TextStyle(color: HspColor.fontColor),),
)
],
),
//演员
Container(
margin: EdgeInsets.only(top: HspSize.set(5),bottom: HspSize.set(5)),
alignment: Alignment.centerLeft,
child: Text("演员韩延",style: TextStyle(color: HspColor.fontLightColor),),
),
//简介
Container(
child: Text(
"简介:一个声称能“看见未来”的患癌男孩韦一航(易烊千玺饰),遇见了一个相信“平行世界”的患癌女孩马小远(刘浩存饰),在深夜的露台上,两人遥望夜空,展开了对各自所向往的美好世界的描述。 影片围绕两个抗癌家庭的两组生活轨迹展开,讲述了一个温情的现实故事,思考和直面了每一个普通人都会面临的终极问题——想象死亡随时可能到来,我们唯一要做的就是爱和珍惜"
,style: TextStyle(color: HspColor.fontLightColor)
,maxLines: 4,overflow: TextOverflow.ellipsis,),
),
//选集
Container(
child: Column(
children: [
Container(
margin: EdgeInsets.only(top: HspSize.set(5),bottom: HspSize.set(5)),
alignment: Alignment.centerLeft,
child: Text("选集",style: TextStyle(color: HspColor.fontColor,fontWeight: FontWeight.w600,fontSize: HspSize.set(18)),),
),
//集数
Container(
child: Wrap(
children: [
worksPanel()
],
),
)
],
),
)
],
),
),
)
//视频信息
],
),
),
);
},
);
}
}
//单集weigets
class worksPanel extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container(
width: HspSize.set(60),
height: HspSize.set(60),
);
}
}