flutter封裝阿里云播放器,已經(jīng)發(fā)布pub.dev:hsp_aliplayer



版本0.2.1:

? ? 實(shí)現(xiàn)功能:

? ? ? ? ? ? ? ? ? ? 1、支持mp4、m3u8和直播

? ? ? ? ? ? ? ? ? ? 2、全屏、倍速、滑屏設(shè)置亮度和音量

? ? ? ? ? ? ? ? ? ? 3、支持自動(dòng)播放,海報(bào)圖,宣傳圖設(shè)置

????用到的權(quán)限:

????????????????<uses-permission android:name="android.permission.INTERNET" />?

????????????????<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />??

????????????????<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />

????????????????<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />

????????????????<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />

????????????????<uses-permission android:name="android.permission.CHANGE_WIFI_MULTICAST_STATE" />

????????????????<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

????????????????<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

????????????????<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>

????????????????<uses-permission android:name="android.permission.WAKE_LOCK" />?????????????

效果視頻:


hsp_aliplayer_騰訊視頻

使用方法:

? ? 1、安裝:

?????hsp_aliplayer:? ^0.2.1

? ? 2、引入

import 'package:hsp_aliplayer/hsp_aliplayer.dart';

3、參數(shù)說明

playMode:默認(rèn)ModeType.URLplayType: HspPlayType.Demand,(設(shè)置當(dāng)前是點(diǎn)播還是直播)

orientation:屏幕方向(參考代碼如上)

isAutoPaly:是否自動(dòng)播放thumbnail:海報(bào)圖

xuanChuanImg:暫?;蚣虞d時(shí)候的宣傳圖

dataSourceMaps:視頻鏈接(直播時(shí)候傳字符串,點(diǎn)播時(shí)候傳數(shù)組,格式如上)

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,//點(diǎn)播或者直播

//? ? ? ? ? ? ? ? ? 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(

"簡介:一個(gè)聲稱能“看見未來”的患癌男孩韋一航(易烊千璽飾),遇見了一個(gè)相信“平行世界”的患癌女孩馬小遠(yuǎn)(劉浩存飾),在深夜的露臺(tái)上,兩人遙望夜空,展開了對各自所向往的美好世界的描述。 影片圍繞兩個(gè)抗癌家庭的兩組生活軌跡展開,講述了一個(gè)溫情的現(xiàn)實(shí)故事,思考和直面了每一個(gè)普通人都會(huì)面臨的終極問題——想象死亡隨時(shí)可能到來,我們唯一要做的就是愛和珍惜"

? ? ? ? ? ? ? ? ? ? ? ? ? ? ,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)),),

),

//集數(shù)

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? Container(

child:Wrap(

children: [

worksPanel()

],

),

)

],

),

)

],

),

),

)

//視頻信息

? ? ? ? ? ? ? ],

),

),

);

},

);

}

}

//單集weigets

class worksPanelextends StatelessWidget {

@override

? Widget build(BuildContext context) {

return Container(

width: HspSize.set(60),

height: HspSize.set(60),

);

}

}

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容