diff --git a/lib/src/replaced_element.dart b/lib/src/replaced_element.dart index 141b242c0d..1b9e56df47 100644 --- a/lib/src/replaced_element.dart +++ b/lib/src/replaced_element.dart @@ -1,7 +1,5 @@ import 'dart:math'; -import 'package:chewie/chewie.dart'; -import 'package:chewie_audio/chewie_audio.dart'; import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; import 'package:flutter_html/html_parser.dart'; @@ -15,7 +13,6 @@ import 'package:flutter_html/style.dart'; import 'package:flutter_math_fork/flutter_math.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:html/dom.dart' as dom; -import 'package:video_player/video_player.dart'; import 'package:webview_flutter/webview_flutter.dart'; /// A [ReplacedElement] is a type of [StyledElement] that does not require its [children] to be rendered. @@ -103,98 +100,6 @@ class ImageContentElement extends ReplacedElement { } } -/// [AudioContentElement] is a [ContentElement] with an audio file as its content. -class AudioContentElement extends ReplacedElement { - final List src; - final bool showControls; - final bool autoplay; - final bool loop; - final bool muted; - - AudioContentElement({ - required String name, - required this.src, - required this.showControls, - required this.autoplay, - required this.loop, - required this.muted, - required dom.Element node, - }) : super(name: name, style: Style(), node: node, elementId: node.id); - - @override - Widget toWidget(RenderContext context) { - return Container( - key: AnchorKey.of(context.parser.key, this), - width: context.style.width ?? 300, - height: Theme.of(context.buildContext).platform == TargetPlatform.android - ? 48 : 75, - child: ChewieAudio( - controller: ChewieAudioController( - videoPlayerController: VideoPlayerController.network( - src.first ?? "", - ), - autoPlay: autoplay, - looping: loop, - showControls: showControls, - autoInitialize: true, - ), - ), - ); - } -} - -/// [VideoContentElement] is a [ContentElement] with a video file as its content. -class VideoContentElement extends ReplacedElement { - final List src; - final String? poster; - final bool showControls; - final bool autoplay; - final bool loop; - final bool muted; - final double? width; - final double? height; - - VideoContentElement({ - required String name, - required this.src, - required this.poster, - required this.showControls, - required this.autoplay, - required this.loop, - required this.muted, - required this.width, - required this.height, - required dom.Element node, - }) : super(name: name, style: Style(), node: node, elementId: node.id); - - @override - Widget toWidget(RenderContext context) { - final double _width = width ?? (height ?? 150) * 2; - final double _height = height ?? (width ?? 300) / 2; - return AspectRatio( - aspectRatio: _width / _height, - child: Container( - key: AnchorKey.of(context.parser.key, this), - child: Chewie( - controller: ChewieController( - videoPlayerController: VideoPlayerController.network( - src.first ?? "", - ), - placeholder: poster != null - ? Image.network(poster!) - : Container(color: Colors.black), - autoPlay: autoplay, - looping: loop, - showControls: showControls, - autoInitialize: true, - aspectRatio: _width / _height, - ), - ), - ), - ); - } -} - /// [SvgContentElement] is a [ReplacedElement] with an SVG as its contents. class SvgContentElement extends ReplacedElement { final String data; @@ -364,23 +269,6 @@ ReplacedElement parseReplacedElement( NavigationDelegate? navigationDelegateForIframe, ) { switch (element.localName) { - case "audio": - final sources = [ - if (element.attributes['src'] != null) element.attributes['src'], - ...ReplacedElement.parseMediaSources(element.children), - ]; - if (sources.isEmpty || sources.first == null) { - return EmptyContentElement(); - } - return AudioContentElement( - name: "audio", - src: sources, - showControls: element.attributes['controls'] != null, - loop: element.attributes['loop'] != null, - autoplay: element.attributes['autoplay'] != null, - muted: element.attributes['muted'] != null, - node: element, - ); case "br": return TextContentElement( text: "\n", @@ -404,26 +292,6 @@ ReplacedElement parseReplacedElement( alt: element.attributes['alt'], node: element, ); - case "video": - final sources = [ - if (element.attributes['src'] != null) element.attributes['src'], - ...ReplacedElement.parseMediaSources(element.children), - ]; - if (sources.isEmpty || sources.first == null) { - return EmptyContentElement(); - } - return VideoContentElement( - name: "video", - src: sources, - poster: element.attributes['poster'], - showControls: element.attributes['controls'] != null, - loop: element.attributes['loop'] != null, - autoplay: element.attributes['autoplay'] != null, - muted: element.attributes['muted'] != null, - width: double.tryParse(element.attributes['width'] ?? ""), - height: double.tryParse(element.attributes['height'] ?? ""), - node: element, - ); case "svg": return SvgContentElement( name: "svg", diff --git a/pubspec.yaml b/pubspec.yaml index cde6832288..4ab3d8e73e 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -9,7 +9,7 @@ environment: dependencies: # Plugin for parsing html - html: '>=0.15.0 <1.0.0' + html: ^0.15.0 # Plugins for parsing css csslib: '>=0.17.0 <1.0.0' @@ -17,16 +17,9 @@ dependencies: # Plugins for rendering the tag. flutter_layout_grid: '>=1.0.1 <2.0.0' - # Plugins for rendering the