gpt4 book ai didi

dart - 如何集成/显示 facebook 视频以 flutter

转载 作者:IT王子 更新时间:2023-10-29 06:45:59 26 4
gpt4 key购买 nike

我在下面有这段代码,我喜欢将来自 facebook 的视频显示到 flutter 应用程序。 但它只显示视频链接,当我单击链接时,它会将我带到 facebook 视频。我想只显示视频而不显示链接,请帮忙。

import 'package:flutter/material.dart';
import 'package:flutter_html_view/flutter_html_view.dart';
//import 'package:html2md/html2md.dart';
//import 'package:flutter_markdown/flutter_markdown.dart';

void main() => runApp(new MyApp());

class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
String html = '<div class="fb-video" data-href="https://www.facebook.com/FacebookAU/videos/10152167660372415/" data-width="500" data-show-text="true"><blockquote cite="https://www.facebook.com/FacebookAU/videos/10152167660372415/" class="fb-xfbml-parse-ignore"><a href="https://www.facebook.com/FacebookAU/videos/10152167660372415/">Happy New You</a><p>Here’s to a healthier, dancier, artier, funner New You in 2014.</p>Posted by <a href="https://www.facebook.com/FacebookAU/">Facebook</a> on Wednesday, January 8, 2014</blockquote></div>';

return new MaterialApp(
home: new Scaffold(
appBar: new AppBar(
title: new Text('Plugin example app'),
),
body: new SingleChildScrollView(
child: new Center(
child: new HtmlView(data: html),
),
),
),
);
}
}

Displaying Link Video is shown

最佳答案

你可以试试这个版本
https://pub.dev/packages/flutter_widget_from_html
构建如下 HTML 内容:

import 'package:flutter/material.dart';
import 'package:flutter_widget_from_html/flutter_widget_from_html.dart';


void main() => runApp(new MyApp());

class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
String html = '''
<iframe width="200" height='200'
src="https://www.facebook.com/v2.3/plugins/video.php?
allowfullscreen=false&autoplay=true&href=${FB_VIDEO_URL}" </iframe>
''';

return new MaterialApp(
home: new Scaffold(
appBar: new AppBar(
title: new Text('Plugin example app'),
),
body: new SingleChildScrollView(
child: HtmlWidget(
html,
webView: true,
),
),
),
);
}
}

用您的链接替换 ​​FB_VIDEO_URL
它对我有用
facebook 和 youtube(youtube:在标签中替换属性 src)视频。
希望这可以帮助。

关于dart - 如何集成/显示 facebook 视频以 flutter,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52329783/

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