gpt4 book ai didi

嵌入 Flutter YouTube 视频

转载 作者:行者123 更新时间:2023-12-05 05:03:24 32 4
gpt4 key购买 nike

我想在我的应用程序中添加嵌入的 YouTube 视频:我该怎么做?我有这个

import 'package:youtube_player/youtube_player.dart';
import 'package:flutube/flutube.dart';

class Videos extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Canal Youtube'),
),
body: YoutubePlayer(source: "https://www.youtube.com/channel/UCuBxtXWWheiQAs-uiJfU5tQ", quality: YoutubeQuality.HD),
);
}
}

最佳答案

Neeko是一个基于 video_player 的简单视频播放器小部件。 Neek 支持时间轴控制、切换全屏等更多操作。

class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);

final String title;

@override
_MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {

// static const String beeUri = 'https://media.w3.org/2010/05/sintel/trailer.mp4';
static const String beeUri =
'http://vfx.mtime.cn/Video/2019/03/09/mp4/190309153658147087.mp4';


final VideoControllerWrapper videoControllerWrapper = VideoControllerWrapper(
DataSource.network(
'http://vfx.mtime.cn/Video/2019/03/09/mp4/190309153658147087.mp4',
displayName: "displayName"));

@override
void initState() {
super.initState();
SystemChrome.setEnabledSystemUIOverlays([SystemUiOverlay.top]);
}

@override
void dispose() {
SystemChrome.restoreSystemUIOverlays();
super.dispose();
}



@override
Widget build(BuildContext context) {

return Scaffold(
body: NeekoPlayerWidget(
onSkipPrevious: () {
print("skip");
videoControllerWrapper.prepareDataSource(DataSource.network(
"http://vfx.mtime.cn/Video/2019/03/12/mp4/190312083533415853.mp4",
displayName: "This house is not for sale"));
},
videoControllerWrapper: videoControllerWrapper,
actions: <Widget>[
IconButton(
icon: Icon(
Icons.share,
color: Colors.white,
),
onPressed: () {
print("share");
})
],
),
);
}
}

关于嵌入 Flutter YouTube 视频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61709302/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com