From eddfc634148f2524ef8f692d5a0c449379724155 Mon Sep 17 00:00:00 2001 From: Jesus Acosta Date: Thu, 26 Aug 2021 18:18:24 -0400 Subject: [PATCH 1/3] strip down video playing functionality --- lib/src/replaced_element.dart | 72 ----------------------------------- pubspec.yaml | 4 -- test/html_parser_test.dart | 8 ---- 3 files changed, 84 deletions(-) diff --git a/lib/src/replaced_element.dart b/lib/src/replaced_element.dart index 141b242c0d..45bfa4a746 100644 --- a/lib/src/replaced_element.dart +++ b/lib/src/replaced_element.dart @@ -1,6 +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'; @@ -143,57 +142,6 @@ class AudioContentElement extends ReplacedElement { } } -/// [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 { @@ -404,26 +352,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..13aeb4c02e 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -17,10 +17,6 @@ dependencies: # Plugins for rendering the tag. flutter_layout_grid: '>=1.0.1 <2.0.0' - # Plugins for rendering the