flutter_video_view 2.1.2

SDKflutter
Platformandroidios

A view for video based on video_player and provides many basic functions.

Flutter VideoView

pub package GitHub license

Language: 中文 | English

flutter_video_view is a video player for flutter. The video_player plugin gives low level access for the video playback.

Installation

Please move to step video_player for specific configuration.

⚠️ PS: There is no need to add video_player dependency to the pubspec.yaml file.

Preparing for use

Version constraints

  sdk: ">=3.2.3 <4.0.0"
  flutter: ">=3.16.6"

Rely

  1. Add flutter_video_view to pubspec.yaml dependencies.
dependencies:
  flutter_video_view: ^latest_version
  1. Get the package by executing the flutter command.
flutter pub get
  1. Introduce
import 'package:flutter_video_view/flutter_video_view.dart';

Localized configuration

Add in MaterialApp.

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
        ...
        localizationsDelegates: const <LocalizationsDelegate<dynamic>>[
            ...
            VideoViewLocalizationsDelegate.delegate,
        ],
        ...
    );
  }
}

Usage

import 'package:flutter_video_view/flutter_video_view.dart';

final VideoPlayerController videoPlayerController = VideoPlayerController.xxx();

final view = VideoView(
  controller: VideoViewController(
    videoPlayerController: videoPlayerController,
    videoViewConfig: VideoViewConfig(),
  ),
);

Popups are implemented by using VideoViewConfig.

NameTypeDescriptionDefault
widthdouble?The width of videoMediaQuery.of(context).size.width
heightdouble?The height of videoMediaQuery.of(context).size.height
backgroundColorColorThe background color of videoColors.black
tooltipBackgroundColorColorThe background color of a widget that displays information about volume, brightness, speed, playback progress, and so onColors.black54
foregroundColorColorThe color for the video's ButtonandText` widget descendantsColors.white
textSizedoubleSize of all texts14
iconSizedoubleSize of all icons16
useSafeboolWhen it is at the top, whether to maintain a safe distance from the toptrue
maxScaledoubleThe maximum allowed scale2.5
minScaledoubleThe minimum allowed scale0.8
panEnabledboolWhether or not to allow panningfalse
scaleEnabledboolWhether or not to allow zoomingfalse
aspectRatiodouble?The Aspect Ratio of the Videonull
allowedScreenSleepboolDefines if the player will sleep in fullscreen or nottrue
autoInitializeboolInitialize the Video on Startup. This will prep the video for playbackfalse
autoPlayboolPlay the video as soon as it's displayedfalse
startAtDuration?Where does the video start playing when it first playsnull
volumedoubleThe volume of the video, not the device volume1.0
loopingboolWhether the video is loopedfalse
overlayPlaceholderBuilder?A widget which is placed between the video and the controlsnull
placeholderBuilderPlaceholderBuilder?Widgets in various initialized statesnull
fullScreenByDefaultboolWhether to play full screen when auto play is enabled, Valid only if [autoPlay] is truefalse
useRootNavigatorboolDefines if push/pop navigations use the rootNavigatortrue
deviceOrientationsEnterFullScreenList<DeviceOrientation>?Defines the set of allowed device orientations on entering fullscreennull
systemOverlaysExitFullScreenList<SystemUiOverlay>Defines the system overlays visible after exiting fullscreenSystemUiOverlay.values
deviceOrientationsExitFullScreenList<DeviceOrientation>Defines the set of allowed device orientations after exiting fullscreenDeviceOrientation.values
showControlsOnInitializeboolWhether controls are displayed when initializing the widgettrue
showControlsFullScreenBuilder<bool>?Whether to display controlstrue
hideControlsTimerDurationDefines the [Duration] before the video controls are hiddenDuration(seconds: 3)
controlsTypeControlsTypeTypes of controls.ControlsType.normal
showBufferingboolWhether to show placeholders in the buffertrue
bufferingBuilderWidget?The placeholder when buffered is displayed above the videonull
finishBuilderFullScreenBuilder<Widget>?Widget to display when video playback is completenull
controlsBackgroundColorList<Color>The background color of the controller[Color.fromRGBO(0, 0, 0, .7), Color.fromRGBO(0, 0, 0, .3), Color.fromRGBO(0, 0, 0, 0)]
showCenterPlayboolWhether to show the play button in the middle.true
centerPlayButtonBuilderCenterPlayButtonBuilder?Play button in the middle.null
canLongPressboolWhether the video can be played at double speed by long pressingtrue
canChangeVolumeOrBrightnessboolWhether the volume or brightness can be adjustedtrue
canChangeProgressboolWhether the video progress can be adjustedtrue
canBackboolWhether to show [BackButton].true
canCloseOnBackboolWhether [BackButton] directly closes the video in full screen mode.false
titleString?The title of videonull
titleTextStyleTextStyle?The textStyle of [title]null
topActionsBuilderFullScreenBuilder<List<Widget>>?Widgets placed at the top rightnull
canShowLockboolWhether the lockable button is displayedfalse
centerLeftActionsBuilderCenterActionsBuilder?Widgets on the middle leftnull
centerRightActionsBuilderCenterActionsBuilder?Widgets on the middle rightnull
bottomBuilderBottomBuilder?It is used to define the control buttons at the bottom and the layout of the display content.null
onTextPositionFullScreenBuilder<VideoTextPosition>?Enumeration value where the progress information is located on the progress barnull
onProgressBarGapFullScreenBuilder<double>?The interval width of the progress bar and time information widget.10
videoProgressBarColorsVideoProgressBarColors?The default colors used throughout the indicatornull
maxPreviewTimeDuration?Maximum preview duration.null
maxPreviewTimeBuilderFullScreenBuilder<Widget>?The widget displayed when the maximum preview duration is reached.null

If you like my project, please in the upper right corner of the project "Star". Your support is my biggest encouragement! ^_^