lecle_yoyo_player 0.0.5%2B2

SDKflutter
Platformandroidios

Lecle YoYo Video Player is a HLS(.m3u8) video player for flutter. The YoyoPlayer is a video player that allows you to select HLS video streaming by selecting the quality.

KoHtut

YoYo Video Player

Lecle YoYo Video Player is a HLS(.m3u8) video player for flutter (migrate from yoyo_player package). The lecle_yoyo_player is a video player that allows you to select HLS video streaming by selecting the quality. Lecle YoYo Player wraps video_player under the hood and provides base architecture for developers to create their own set of UI and functionalities.

The package has been updated with more customizable properties and fixed the report issues from the old package.

Pub Version (including pre-releases)

Features

  • You can select multiple quality and open
  • On video tap play/pause, mute/unmute, or perform any action on video.
  • Auto hide controls.
  • (.m3u8) HLS Video streaming support

Install & Set up

Android

Add this permission to your <project root>/android/app/src/main/AndroidManifest.xml


<uses-permission android:name="android.permission.INTERNET"/>

iOS

If you need to access videos using http (rather than https) URLs, you have to add the appropriate NSAppTransportSecurity permissions to your app's <project root>/ios/Runner/Info.plist file.

Open Xcode and change the deployment target of your project to 11.

Project

  1. Add dependency, open the root directory pubspec.yaml file in dependencies:. Add the following code below:
lecle_yoyo_player: #latest_version
  1. Installation dependencies (please ignore if it has been installed automatically)
 cd project_directory
 flutter pub get
  1. Introduce the library in the page
import 'package:lecle_yoyo_player/lecle_yoyo_player.dart';

Usage

A simple usage example:

  YoYoPlayer(
    aspectRatio: 16 / 9,
    url: "video_url",
    videoStyle: VideoStyle(),
    videoLoadingStyle: VideoLoadingStyle(),
  ),

Change Icon

 videoStyle: VideoStyle(
    playIcon: Icon(Icons.play_arrow),
    pauseIcon: Icon(Icons.pause),
    fullscreenIcon: Icon(Icons.fullscreen),
    forwardIcon: Icon(Icons.skip_next),
    backwardIcon: Icon(Icons.skip_previous),
 )

Change Video Loading

   videoLoadingStyle: VideoLoadingStyle(loading : Center(child: Text("Loading video")),

Play With Subtitle

        body: YoYoPlayer(
          aspectRatio: 16 / 9,
          // Url (Video streaming links)
          // 'https://dsqqu7oxq6o1v.cloudfront.net/preview-9650dW8x3YLoZ8.webm',
          // "https://flutter.github.io/assets-for-api-docs/assets/videos/bee.mp4",
          // "https://test-streams.mux.dev/x36xhzz/x36xhzz.m3u8",
          url:  "https://sfux-ext.sfux.info/hls/chapter/105/1588724110/1588724110.m3u8",
          videoStyle: VideoStyle(
            qualityStyle: TextStyle(
              fontSize: 16.0,
              fontWeight: FontWeight.w500,
              color: Colors.white,
            ),
            forwardAndBackwardBtSize: 30.0,
            playButtonIconSize: 40.0,
            playIcon: Icon(
              Icons.add_circle_outline_outlined,
              size: 40.0, color: Colors.white,
            ),
            pauseIcon: Icon(
              Icons.remove_circle_outline_outlined,
              size: 40.0, color: Colors.white,
            ),
            videoQualityPadding: EdgeInsets.all(5.0),
          ),
          videoLoadingStyle: VideoLoadingStyle(
            loading: Center(
              child: Text("Loading video"),
            ),
          ),
          allowCacheFile: true,
          onCacheFileCompleted: (files) {
            print('Cached file length ::: ${files?.length}');

            if (files != null && files.isNotEmpty) {
              for (var file in files) {
                print('File path ::: ${file.path}');
              }
            }
          },
          onCacheFileFailed: (error) {
            print('Cache file error ::: $error');
          },
          onFullScreen: (value) {
            setState(() {
              if (fullscreen != value) {
                fullscreen = value;
              }
            });
          }
        ),

Live video


videoStyle: VideoStyle(
  showLiveDirectButton: true,
)

Player Option

Player

AttributesTypeDescription
urlStringVideo source ( .m3u8 & File only)
videoStyleVideoStyleVideo player style
videoLoadingStyleVideoLoadingStyleVideo loading Style
aspectRatiodoubleVideo AspectRaitio [aspectRatio : 16 / 9 ]
onFullScreenVideoCallbackVideo state fullscreen
onPlayingVideoVideoCallbackVideo type ( eg : mkv,mp4,hls)
onPlayButtonTapVideoCallbackVideo playing state
onFastForwardVideoCallback<VideoPlayerValue?>Video new value after forward
onRewindVideoCallback<VideoPlayerValue?>Video new value after rewind
onShowMenuVideoCallback<bool, bool>Video control buttons state and video quality picker state
onVideoInitCompletedVideoCallbackExpose the video controller after init the video
headersMap<String, String>Additional headers for video url request
autoPlayVideoAfterInitboolAllow video auto play after init
displayFullScreenAfterInitboolAllow video display in full screen mode after init
onCacheFileCompletedVideoCallback<List?>Video list after caching
onCacheFileCompletedVideoCallbackVideo caching error
allowCacheFileboolAllow cache file into device's storage
closedCaptionFileVideoCallback<ClosedCaptionFile?>Closed caption file
videoPlayerOptionsVideoPlayerOptionsProvide additional configuration options
onLiveDirectTapVideoCallback<VideoPlayerValue?>Live video current value

Player custom style (VideoStyle)

AttributesTypeDescription
playIconWidgetPlay button custom play icon
pauseIconWidgetPlay button custom pause icon
fullscreenIconWidgetFull screen button custom icon
forwardIconWidgetForward button custom icon
backwardIconWidgetBackward button custom icon
qualityStyleTextStyleVideo current quality text style
qualityOptionStyleTextStyleVideo's quality options style
videoSeekStyleTextStyleVideo's current position text style
videoDurationStyleTextStyleVideo's duration text style
allowScrubbingboolDetect touch input and try to seek the video accordingly
progressIndicatorColorsVideoProgressColorsDefault colors used throughout the indicator
progressIndicatorPaddingEdgeInsetsGeometryVisual padding around the progress indicator
playButtonIconColorColorThe custom color for the play button's icon
playButtonIconSizedoubleThe custom size for the play button's icon
spaceBetweenBottomBarButtonsdoubleSpace between play, forward and backward buttons
actionBarBgColorColorCustom background color for the action bar
actionBarPaddingEdgeInsetsGeometryCustom padding for the action bar
qualityOptionsBgColorColorCustom background color for the quality options popup
qualityOptionsMarginEdgeInsetsGeometryCustom margin to change the display position for the quality options popup
qualityOptionsPaddingEdgeInsetsGeometryCustom padding around the video quality option text
qualityOptionsRadiusBorderRadiusCustom border radius for the quality options popup
qualityButtonAndFullScrIcoSpacedoubleSpace between the fullscreen and the video quality buttons
forwardAndBackwardBtSizedoubleCustom size for the forward and backward buttons
forwardIconColorColorCustom color for the forward button
backwardIconColorColorCustom color for the backward button
bottomBarPaddingEdgeInsetsGeometryPadding around for the bottom bar
videoQualityBgColorColorCustom background color for the selected video quality widget
videoQualityRadiusBorderRadiusGeometryCustom border radius for the selected video quality widget
videoQualityPaddingEdgeInsetsGeometryPadding around for the selected video quality text
qualityOptionWidthdoubleWidth for each item inside the video options popup
fullScreenIconSizedoubleFull screen button's icon size
fullScreenIconColorColorCustom color for the fullscreen button
showLiveDirectButtonboolEnable or disable live direct button (Use for live video)
liveDirectButtonTextStringCustom text for live direct button
liveDirectButtonTextStyleTextStyleCustom style for the direct button text
liveDirectButtonColorColorCustom color for the circle of the live direct button
liveDirectButtonDisableColorColorCustom disable color for the circle of the live direct button
liveDirectButtonSizedoubleCustom size for the circle of the live direct button
enableSystemOrientationsOverrideboolEnable or disable system's orientation override
orientationListA set of orientations the application interface can be displayed in

Player loading custom style (VideoLoadingStyle)

AttributesTypeDescription
loadingWidgetCustom loading widget to replace the default loading widget
loadingBackgroundColorColorCustom background color for the loading widget
loadingIndicatorValueColorColorCustom color for the loading indicator
loadingTextStringCustom loading text of the loading widget
loadingTextStyleTextStyleCustom TextStyle for the loading text
loadingIndicatorBgColorColorThe progress indicator's background color
loadingIndicatorColorColorThe progress indicator's color
loadingIndicatorWidthdoubleThe width of the line used to draw the circle
indicatorSemanticsLabelStringThe SemanticsProperties.label for the progress indicator
indicatorSemanticsValueStringThe SemanticsProperties.value for the progress indicator
indicatorInitValuedoubleThe value of the progress indicator
spaceBetweenIndicatorAndTextdoubleThe space between the loading text and the loading indicator
showLoadingTextboolAllow the loading widget to show the loading text

How is it created ?

  • The data in the source url (m3u8) is regex checked and the child m3u8 files are created and saved according to the respective rules.
  • It starts creating child m3u8 files as soon as the video starts playing
  • Each time a video is completed or the main url changes, child m3u8 files are checked and deleted.

The child m3u8 files are created as follows:

  • If video quality yoyo_[file-name]_[video-quality].m3u8

  • If video quality & audio quality yoyo_[video-quality]_[audio-quality].m3u8

Support M3U8

  • #EXT-X-MEDIA
  • #EXT-X-STREAM-INF(not for ios)

Player Screenshot