我下面有这段代码,我想将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),
),
),
),
);
}
}
答案 0 :(得分:1)
您可以尝试此版本
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:标记中的repace属性src)视频。
希望这可以帮助。