{"id":18498065,"url":"https://github.com/apivideo/api.video-flutter-player","last_synced_at":"2025-04-09T00:30:56.728Z","repository":{"id":63955161,"uuid":"548816503","full_name":"apivideo/api.video-flutter-player","owner":"apivideo","description":"The official Flutter player for api.video ","archived":false,"fork":false,"pushed_at":"2024-07-26T14:19:46.000Z","size":685,"stargazers_count":23,"open_issues_count":8,"forks_count":6,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-23T19:44:46.352Z","etag":null,"topics":["android","flutter","ios","player","web"],"latest_commit_sha":null,"homepage":"https://api.video","language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/apivideo.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-10-10T08:21:04.000Z","updated_at":"2025-02-25T09:22:35.000Z","dependencies_parsed_at":"2023-10-03T17:13:38.749Z","dependency_job_id":"a228f8a2-9da9-4581-b4d6-13d8f0715be7","html_url":"https://github.com/apivideo/api.video-flutter-player","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apivideo%2Fapi.video-flutter-player","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apivideo%2Fapi.video-flutter-player/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apivideo%2Fapi.video-flutter-player/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apivideo%2Fapi.video-flutter-player/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/apivideo","download_url":"https://codeload.github.com/apivideo/api.video-flutter-player/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247949754,"owners_count":21023382,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","flutter","ios","player","web"],"created_at":"2024-11-06T13:37:30.720Z","updated_at":"2025-04-09T00:30:55.159Z","avatar_url":"https://github.com/apivideo.png","language":"Dart","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003c!--\u003cdocumentation_excluded\u003e--\u003e\n[![badge](https://img.shields.io/twitter/follow/api_video?style=social)](https://twitter.com/intent/follow?screen_name=api_video)\n\u0026nbsp; [![badge](https://img.shields.io/github/stars/apivideo/api.video-flutter-player?style=social)](https://github.com/apivideo/api.video-flutter-player)\n\u0026nbsp; [![badge](https://img.shields.io/discourse/topics?server=https%3A%2F%2Fcommunity.api.video)](https://community.api.video)\n![](https://github.com/apivideo/.github/blob/main/assets/apivideo_banner.png)\n\u003ch1 align=\"center\"\u003eapi.video Flutter player\u003c/h1\u003e\n\n[api.video](https://api.video) is the video infrastructure for product builders. Lightning fast\nvideo APIs for integrating, scaling, and managing on-demand \u0026 low latency live streaming features in\nyour app.\n\n## Table of contents\n\n- [Table of contents](#table-of-contents)\n- [Project description](#project-description)\n- [Getting started](#getting-started)\n  - [Installation](#installation)\n- [Documentation](#documentation)\n  - [Instantiation](#instantiation)\n    - [1. The ApiVideoPlayerController](#1-the-apivideoplayercontroller)\n    - [2. The ApiVideoPlayer](#2-the-apivideoplayer)\n  - [Methods](#methods)\n  - [Properties](#properties)\n  - [Events listener](#events-listener)\n    - [Add a new event listener: Method 1](#add-a-new-event-listener-method-1)\n    - [Add a new event listener: Method 2](#add-a-new-event-listener-method-2)\n    - [Remove an event listener](#remove-an-event-listener)\n- [Sample application](#sample-application)\n- [Dependencies](#dependencies)\n- [FAQ](#faq)\n\n\u003c!--\u003c/documentation_excluded\u003e--\u003e\n\u003c!--\u003cdocumentation_only\u003e\n---\ntitle: api.video Flutter Player\nmeta: \n  description: The official api.video Flutter Player component for api.video. [api.video](https://api.video/) is the video infrastructure for product builders. Lightning fast video APIs for integrating, scaling, and managing on-demand \u0026 low latency live streaming features in your app.\n---\n\n# api.video Flutter Player\n\n[api.video](https://api.video/) is the video infrastructure for product builders. Lightning fast video APIs for integrating, scaling, and managing on-demand \u0026 low latency live streaming features in your app.\n\n\u003c/documentation_only\u003e--\u003e\n## Project description\n\nEasily integrate a video player for videos from api.video in your Flutter application for iOS,\nAndroid and Web.\n\n## Getting started\n\n### Installation\n\nRun the following command at the root of your project.\n\n```shell\nflutter pub add apivideo_player\n```\n\n## Documentation\n\n### Instantiation\n\n#### 1. The ApiVideoPlayerController\n\nTo use a video player, you must instantiate a new controller.\n\nThe [ApiVideoPlayerController](https://github.com/apivideo/api.video-flutter-player/blob/main/lib/src/apivideo_player_controller.dart) parameters are:\n\n| Parameter    | Mandatory          | Type                                                                                                                                               | Description                                                                   |\n|--------------|--------------------|----------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------|\n| videoOptions | Yes                | [VideoOptions](https://github.com/apivideo/api.video-flutter-player/blob/4efe23f20ccf1c9459cee7588da1d3fed74e8e36/lib/src/apivideo_types.dart#L13) | Options from the video you want to display inside the current video player    |\n| autoplay     | No (default false) | bool                                                                                                                                               | Whether you want your video to be automatically played when it's ready or not |\n| onReady      | No                 | VoidCallback                                                                                                                                       | A callback called when the video is ready to be played                        |\n| onPlay       | No                 | VoidCallback                                                                                                                                       | A callback called when the video is played                                    |\n| onPause      | No                 | VoidCallback                                                                                                                                       | A callback called when the video is paused                                    |\n| onEnd        | No                 | VoidCallback                                                                                                                                       | A callback called when the video has ended                                    |\n| onError      | No                 | Function(Object)                                                                                                                                   | A callback called when an error occured                                       |\n\nOnce instantiated, you need to initialize the controller by calling its `initialize()` method.\n\n```dart\nfinal ApiVideoPlayerController controller = ApiVideoPlayerController(\n  videoOptions: VideoOptions(videoId: 'VIDEO_ID'), // `VIDEO_ID` is the video id or the live stream id\n  // For private video: VideoOptions(videoId: \"YOUR_VIDEO_ID\", token: \"YOUR_PRIVATE_TOKEN\")\n);\n\nawait controller.initialize();\n```\n\nSee the sample application below for more details.\n\n#### 2. The ApiVideoPlayer\n\nA Widget that displays the video and its controls.\n\nThe [ApiVideoPlayer](https://github.com/apivideo/api.video-flutter-player/blob/main/lib/src/widgets/apivideo_player.dart) constructor takes 3 parameters:\n\n| Parameter  | Mandatory                      | Type                                                                                                                               | Description                                                   |\n|------------|--------------------------------|------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------|\n| controller | Yes                            | [ApiVideoPlayerController](https://github.com/apivideo/api.video-flutter-player/blob/main/lib/src/apivideo_player_controller.dart) | The controller that controls a video player                   |                                                                                                                                               | Allows you to hide or show the controls of a video player |\n| fit        | No (default BoxFit.contain)    | [BoxFit](https://api.flutter.dev/flutter/painting/BoxFit.html)                                                                     | How the player should be inscribed into its box.              |\n| style      | No (default api.video style)   | [PlayerStyle](https://github.com/apivideo/api.video-flutter-player/blob/main/lib/src/style/apivideo_style.dart#L102)               | Allows you to customize the video player's colors, shapes,... |\n| child      | No (default api.video overlay) | Widget                                                                                                                             | Replace api.video overlay by your own implementation.         |\n\n```dart\n\nfinal ApiVideoPlayerController controller = ApiVideoPlayerController(\n  videoOptions: VideoOptions(videoId: 'VIDEO_ID'),\n  // For private video: VideoOptions(videoId: \"YOUR_VIDEO_ID\", token: \"YOUR_PRIVATE_TOKEN\")\n);\n\nawait controller.initialize();\n\nWidget build(BuildContext context) {\n  return ApiVideoPlayer(\n    controller: controller,\n  );\n}\n```\n\n### Methods\n\nOnce the [ApiVideoPlayerController](https://github.com/apivideo/api.video-flutter-player/blob/main/lib/src/apivideo_player_controller.dart) has been instantiated, you can control the player it has been assigned to with its methods:\n\n| Method                                     | Description                                                                   |\n|--------------------------------------------|-------------------------------------------------------------------------------|\n| play()                                     | Play the video                                                                |\n| pause()                                    | Pause the video                                                               |\n| seek(Duration offset)                      | Add/substract the given Duration from the current time                        |\n| setVolume(double volume)                   | Change the audio volume to the given value. From 0 to 1 (0 = muted, 1 = 100%) |\n| setIsMuted(bool isMuted)                   | Mute/unmute the video                                                         |\n| setAutoplay(bool autoplay)                 | Define if the video should start playing as soon as it is loaded              |\n| setIsLooping(bool isLooping)               | Define if the video should be played in loop                                  |\n| setCurrentTime(Duration currentTime)       | Set the current playback time                                                 |\n| setVideoOptions(VideoOptions videoOptions) | Set the video options                                                         |\n\nExample:\n\n```dart\n\nfinal ApiVideoPlayerController controller = ApiVideoPlayerController(\n  videoOptions: VideoOptions(videoId: 'VIDEO_ID'),\n  // For private video: VideoOptions(videoId: \"YOUR_VIDEO_ID\", token: \"YOUR_PRIVATE_TOKEN\")\n);\n\nawait controller.initialize();\n\ncontroller.play(); // Play the video\n```\n\n### Properties\n\nOnce the [ApiVideoPlayerController](https://github.com/apivideo/api.video-flutter-player/blob/main/lib/src/apivideo_player_controller.dart) has been instantiated, you can access the video player's properties:\n\n| Property     | Type                  | Description                                     |\n|--------------|-----------------------|-------------------------------------------------|\n| isCreated    | Future\\\u003cbool\u003e         | Check if the player has been created            |\n| isPlaying    | Future\\\u003cbool\u003e         | Check whether the video is playing              |\n| videoOptions | Future\\\u003cVideoOptions\u003e | Retrieve the current video options              |\n| currentTime  | Future\\\u003cDuration\u003e     | Retrieve the current playback time of the video |\n| duration     | Future\\\u003cDuration\u003e     | Retrieve the duration of the video              |\n| autoplay     | Future\\\u003cbool\u003e         | Check whether the video is autoplayed           |\n| isMuted      | Future\\\u003cbool\u003e         | Check whether the video is muted                |\n| isLooping    | Future\\\u003cbool\u003e         | Check whether the video is in loop mode         |\n| volume       | Future\\\u003cdouble\u003e       | Retrieve the current volume                     |\n| videoSize    | Future\\\u003cSize?\u003e        | Retrieve the current video size                 |\n\nExample:\n\n```dart\n\nfinal ApiVideoPlayerController controller = ApiVideoPlayerController(\n  videoOptions: VideoOptions(videoId: 'VIDEO_ID'),\n  // For private video: VideoOptions(videoId: \"YOUR_VIDEO_ID\", token: \"YOUR_PRIVATE_TOKEN\")\n);\n\nawait controller.initialize();\n\nfinal bool isMuted = await controller.isMuted;\n```\n\n### Events listener\n\n#### Add a new event listener: Method 1\n\nWhen you instantiate a new [ApiVideoPlayerController](https://github.com/apivideo/api.video-flutter-player/blob/main/lib/src/apivideo_player_controller.dart), you can bind callbacks to some events:\n\n```dart\n\nfinal ApiVideoPlayerController controller = ApiVideoPlayerController(\n  videoOptions: VideoOptions(videoId: 'VIDEO_ID'),\n  // For private video: VideoOptions(videoId: \"YOUR_VIDEO_ID\", token: \"YOUR_PRIVATE_TOKEN\")\n  onPlay: () =\u003e print('PLAY'),\n  onPause: () =\u003e print('PAUSE'),\n);\n```\n\n#### Add a new event listener: Method 2\n\nOnce the [ApiVideoPlayerController](https://github.com/apivideo/api.video-flutter-player/blob/main/lib/src/apivideo_player_controller.dart) has been instantiated, you can bind callbacks to some events:\n\n```dart\n\nfinal ApiVideoPlayerController controller = ApiVideoPlayerController(\n  videoOptions: VideoOptions(videoId: 'VIDEO_ID'),\n  // For private video: VideoOptions(videoId: \"YOUR_VIDEO_ID\", token: \"YOUR_PRIVATE_TOKEN\")\n);\n\nawait controller.initialize();\n\nfinal ApiVideoPlayerControllerEventsListener eventsListener =\nApiVideoPlayerControllerEventsListener(\n  onPlay: () =\u003e print('PLAY'),\n);\n\ncontroller.addListener(eventsListener);\n```\n\n| Event   | Type             | Description                                            |\n|---------|------------------|--------------------------------------------------------|\n| onReady | VoidCallback     | A callback called when the video is ready to be played |\n| onPlay  | VoidCallback     | A callback called when the video is played             |\n| onPause | VoidCallback     | A callback called when the video is paused             |\n| onEnd   | VoidCallback     | A callback called when the video has ended             |\n| onError | Function(Object) | A callback called when an error occured                |\n\n#### Remove an event listener\n\nTo remove an event listener, you need to call the controller's `removeListener` method.\n\n```dart\n\nfinal ApiVideoPlayerController controller = ApiVideoPlayerController(\n  videoOptions: VideoOptions(videoId: 'VIDEO_ID'),\n  // For private video: VideoOptions(videoId: \"YOUR_VIDEO_ID\", token: \"YOUR_PRIVATE_TOKEN\")\n);\n\nawait controller.initialize();\n\nfinal ApiVideoPlayerControllerEventsListener eventsListener =\nApiVideoPlayerControllerEventsListener(\n  onPlay: () =\u003e print('PLAY'),\n);\n\ncontroller.removeListener(eventsListener);\n```\n\n## Sample application\n\n```dart\nimport 'package:apivideo_player/apivideo_player.dart';\nimport 'package:flutter/material.dart';\n\nvoid main() {\n  runApp(const MyApp());\n}\n\nclass MyApp extends StatefulWidget {\n  const MyApp({Key? key}) : super(key: key);\n\n  @override\n  State\u003cMyApp\u003e createState() =\u003e _MyAppState();\n}\n\nclass _MyAppState extends State\u003cMyApp\u003e {\n  final ApiVideoPlayerController _controller = ApiVideoPlayerController(\n    videoOptions: VideoOptions(videoId: 'VIDEO_ID'),\n    // For private video: VideoOptions(videoId: \"YOUR_VIDEO_ID\", token: \"YOUR_PRIVATE_TOKEN\")\n    onPlay: () =\u003e print('PLAY'),\n  );\n  String _duration = 'Get duration';\n\n  @override\n  void initState() {\n    super.initState();\n    _controller.initialize();\n    _controller.addListener(\n      ApiVideoPlayerControllerEventsListener(\n        onPause: () =\u003e print('PAUSE'),\n      ),\n    );\n  }\n\n  void _getDuration() async {\n    final Duration duration = await _controller.duration;\n    setState(() {\n      _duration = 'Duration: $duration';\n    });\n  }\n\n  void _muteVideo() {\n    _controller.setIsMuted(true);\n  }\n\n  @override\n  Widget build(BuildContext context) {\n    return MaterialApp(\n      home: Builder(builder: (context) {\n        return Scaffold(\n          body: Center(\n            child: Column(\n              children: \u003cWidget\u003e[\n                SizedBox(\n                  width: 400.0,\n                  height: 300.0,\n                  child: ApiVideoPlayer(\n                    controller: _controller,\n                  ),\n                ),\n                IconButton(\n                  icon: const Icon(Icons.volume_off),\n                  onPressed: _muteVideo,\n                ),\n                TextButton(\n                  onPressed: _getDuration,\n                  child: Text(\n                    _duration,\n                    textAlign: TextAlign.center,\n                  ),\n                ),\n              ],\n            ),\n          ),\n        );\n      }),\n    );\n  }\n}\n```\n\n## Dependencies\n\nWe are using external library\n\n| Plugin                                           | README                                                  |\n|--------------------------------------------------|---------------------------------------------------------|\n| [Exoplayer](https://github.com/google/ExoPlayer) | [README.md](https://github.com/google/ExoPlayer#readme) |\n\n\n## FAQ\n\nIf you have any questions, ask us in the [community](https://community.api.video) or\nuse [issues](https://github.com/apivideo/api.video-flutter-player/issues).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fapivideo%2Fapi.video-flutter-player","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fapivideo%2Fapi.video-flutter-player","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fapivideo%2Fapi.video-flutter-player/lists"}