flutter封装阿里云播放器,已经发布pub.dev:hsp_aliplayer



版本0.2.1:

    实现功能:

                    1、支持mp4、m3u8和直播

                    2、全屏、倍速、滑屏设置亮度和音量

                    3、支持自动播放,海报图,宣传图设置

    用到的权限:

                 

                  

                

                

                

                

                

                

                

                             

效果视频:


hsp_aliplayer_腾讯视频

使用方法:

    1、安装:

     hsp_aliplayer:  ^0.2.1

    2、引入

import 'package:hsp_aliplayer/hsp_aliplayer.dart';

3、参数说明

playMode:默认ModeType.URLplayType: HspPlayType.Demand,(设置当前是点播还是直播)

orientation:屏幕方向(参考代码如上)

isAutoPaly:是否自动播放thumbnail:海报图

xuanChuanImg:暂停或加载时候的宣传图

dataSourceMaps:视频链接(直播时候传字符串,点播时候传数组,格式如上)

4、案例

import 'package:flutter/material.dart';

import 'package:flutterapp/util/index.dart';

import 'package:hsp_aliplayer/hsp_aliplayer.dart';

class VideoDetailPageextends StatefulWidget {

@override

  _VideoDetailPageState createState() =>_VideoDetailPageState();

}

class _VideoDetailPageStateextends State  {

final videoList=[{'url':'https://b.mhqiyi.com/20201105/gDbyygPG/index.m3u8','id':'0'},

{'url':'https://b.mhqiyi.com/20201111/GfT21Exh/index.m3u8','id':'1'},

{'url':'https://b.mhqiyi.com/20201105/gDbyygPG/index.m3u8','id':'2'},

{'url':'https://b.mhqiyi.com/20201111/GfT21Exh/index.m3u8','id':'3'},];

@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:videoList,

playType: HspPlayType.Demand,//点播或者直播

//                  dataSourceMap:'http://live.mtdevelop.cn/jiaoyu/2021.flv?auth_key=1613795919-0-0-21428155d89c0e0ef3cf4605e0741af2',

                  orientation: _orientation,

isAutoPaly:false,

thumbnail:'https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=4077016453,2135656356&fm=11&gp=0.jpg',

xuanChuanImg:'https://ss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=2219649508,3599350849&fm=11&gp=0.jpg',

),

//          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 worksPanelextends StatelessWidget {

@override

  Widget build(BuildContext context) {

return Container(

width: HspSize.set(60),

height: HspSize.set(60),

);

}

}

你可能感兴趣的:(flutter封装阿里云播放器,已经发布pub.dev:hsp_aliplayer)