gwp_alpha_player 0.0.6 gwp_alpha_player: ^0.0.6 copied to clipboard
一个透明播放器(适配Android, iOS平台).
import 'package:flutter/material.dart';
import 'package:gwp_alpha_player/gwp_alpha_player.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: const MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key, required this.title});
final String title;
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
final _gwpAlphaPlayerPlugin = GwpAlphaPlayer();
@override
void initState() {
super.initState();
}
void _incrementCounter() {
setState(() {
_gwpAlphaPlayerPlugin.play(
"https://oss.xingyaozhibo.com/xyapp/svga/v2/taikong.mp4", (url) {
print("播放完成:${url}");
});
});
}
@override
Widget build(BuildContext context) {
double height = MediaQuery.of(context).size.height * 0.8;
return Scaffold(
appBar: AppBar(
// Here we take the value from the MyHomePage object that was created by
// the App.build method, and use it to set our appbar title.
title: Text(widget.title),
),
body: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Container(
height: height,
width: MediaQuery.of(context).size.width,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage("lib/back.png"),
fit: BoxFit.fitHeight)),
child: _gwpAlphaPlayerPlugin.getVideoWidget(
top: 10, height: height)),
],
),
floatingActionButton: FloatingActionButton(
onPressed: _incrementCounter,
tooltip: 'Increment',
child: const Icon(Icons.add),
), // This trailing comma makes auto-formatting nicer for build methods.
);
}
}