green_video 2.0.25 copy "green_video: ^2.0.25" to clipboard
green_video: ^2.0.25 copied to clipboard

Green Video Player Flutter plugin.

green_video #

Green Video Player for Flutter

Getting Started #

  1. Import the green_video dependency in your pubspec.yaml
  green_video:
    git:
      url: [email protected]:xymatic/green-video-flutter.git
      ref: main #or specific version
  1. Specify green-video-sdk as a dependency in your ios/Podfile file
pod 'GreenVideoSDK', :git => 'https://flutter:[email protected]/xymatic/green-video-sdk-ios.git', :tag => '2.0.17'

Add GitLab private repo to pull the Android native player SDK from to your android/build.gradle file

allprojects {
    repositories {
        google()
        mavenCentral()
        maven {
            name "Gitlab"
            url "https://gitlab.com/api/v4/projects/56291616/packages/maven"
            credentials(HttpHeaderCredentials) {
                name = 'Private-Token'
                value = 'glpat-HLU8z1u9FsU35xVyij5V'
            }
            authentication {
                header(HttpHeaderAuthentication)
            }
        }
    }
}

dependencies { // ... implementation 'com.xymatic.greenvideo:green-video-sdk:2.0.17' }

  1. import the player widget
import 'package:green_video/widgets/green_video.dart';
  1. use the Flutter GreenVideo Player widget in your app
@override
Widget build(BuildContext context) {
  return MaterialApp(
    home: Scaffold(
      appBar: AppBar(
        title: const Text('Example app'),
      ),
      body: Column(
        children: [
          const SizedBox(height: 100),
          GreenVideo(
            width: 400,
            height: 240,
            licenseKey: "LICENSE_KEY",
            embedId: "EMBED_ID",
            contentId: "CONTENT_ID",
            controller: /* a green video controller instance */,
          ),
        ],
      ),
    ),
  );
}
  1. Handle player events using the GreenVideoController
final controller = GreenVideoController();

controller.playerEvents.listen((event) {
  if (event is OnPlayEvent) {
    print("Player started playing");
  } else if (event is OnPauseEvent) {
    print("Player paused");
  } else if (event is OnSeekEvent) {
    print("Player seeked to position ${event.position}");
  }
});
  1. Control the player using the GreenVideoController
controller.execute(PlayCommand());  // Start playing
controller.execute(PauseCommand()); // Pause the player
controller.execute(SeekCommand(30.0)); // Seek to 30 seconds

Getting Started

Player Commands #

The GreenVideoController provides the following commands to control the player:

PlayCommand(): Start playing the video. PauseCommand(): Pause the video. SeekCommand(position): Seek to a specific position in the video (in seconds). MuteCommand(): Mute the video. UnmuteCommand(): Unmute the video. EnterFullscreenCommand(): Enter fullscreen mode. ExitFullscreenCommand(): Exit fullscreen mode. StartNextContentCommand(): Start the next content in the playlist. StartPreviousContentCommand(): Start the previous content in the playlist. SeekForwardCommand(time): Seek forward by the specified time (in seconds). SeekBackwardCommand(time): Seek backward by the specified time (in seconds). ShowUiCommand(): Show the player UI. HideUiCommand(): Hide the player UI. StartContentCommand(): Start the content.

Player Events #

The GreenVideoController emits the following events through the playerEvents stream:

OnReadyEvent: Emitted when the player is ready to play content. OnPlayEvent: Emitted when the player starts playing. OnContentStartEvent: Emitted when the player starts the content. OnPauseEvent: Emitted when the player is paused. OnMuteEvent: Emitted when the player is muted. OnUnmuteEvent: Emitted when the player is unmuted. OnSeekEvent: Emitted when the player seeks to a new position. OnEnterFullscreenEvent: Emitted when the player enters fullscreen mode. OnExitFullscreenEvent: Emitted when the player exits fullscreen mode. OnShowUiEvent: Emitted when the player shows the UI. OnHideUiEvent: Emitted when the player hides the UI. OnEnterPipEvent: Emitted when the player enters picture-in-picture mode. OnExitPipEvent: Emitted when the player exits picture-in-picture mode. OnTimeUpdateEvent: Emitted when the player updates the current time. OnMilestoneReachedEvent: Emitted when the player reaches a milestone. OnPlayerInitEvent: Emitted when the player is initialized. OnErrorEvent: Emitted when the player encounters an error.

You can listen to these events using the playerEvents stream provided by the GreenVideoController.