Play library

Fast, Enjoyable & Customizable Play library

Pub Version

Play Library untuk memutar video dan audio cross platform dengan mudah hanya menambah code pada dart, example sudah ada di

Features

  • 🚀 Cross platform: mobile, desktop, web, cli
  • ⚡ Great performance
  • ❤️ Simple, powerful, & intuitive API

Demo

https://user-images.githubusercontent.com/82513502/204106088-90c8d756-fbee-4724-9087-46bc99e69a00.mp4

https://user-images.githubusercontent.com/82513502/204106197-4bc3d9ba-f374-40ff-9913-7f4ffd40b530.mp4

Install Library

dart pub add play
flutter pub add play

To-Do

  1. x Cross platform support (Android,iOS, Linux, Windows, Web)
  2. x Easy Play Video and Audio
  3. x Custom View Audio And Video
  4. x Realtime Player Like (call, streaming)
  5. Custom Encoding & Decoding Audio & Video

Tested On

OS Tested
Android Tested
Linux Tested
Windows Tested
ios Tested
Web Tested
macOS Not Tested

Quickstart

add library in first dart file

import 'package:play/play.dart';

Flutter



import 'package:flutter/material.dart';
import 'package:play/play.dart';

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  Play.ensureInitialized();

  /// --- your code
   /// return runApp(
    /// const MaterialApp(home: MainPage()),
  ///);
}

Audio Player


Scaffold(

  ---
  Audio(
    audioData: AudioData.file(
      file: File(path),
    ),
    isAutoStart: false,
    builder: (BuildContext context, Widget child, Audio audio, AudioState audioState,AudioController audioController) {
      return child;
    }
  );
  ---

)

Video Player

Scaffold(

  ---
  Video(
    mediaData: MediaData.file(
      file: File(path),
    ),
    isAutoStart: false,
    builder: (BuildContext context, Widget child, Video video, VideoState videoState, MediaController mediaController) {
      return child;
    }
  );
  ---

)

I don't have enough native coding skills so I can't add many features in this library, if you want to contribute please just add it I'll be happy if you help me

Docs

I use 3 libraries so your document can be seen here

  1. video_player
  2. media_kit

Audio

Documentation audio

  1. AudioData
  • file
    AudioData.file(
      file: File("./path_to_audio.mp3"),
    )
    
  • asset
    AudioData.asset(
      asset: "assets/audio/audio.mp3",
    )
    
  • network
    AudioData.network(
      url: "https://example.com/example.mp3",
    )
    
  1. isAutoStart

    • true if you want auto play set data to true
    • false if you don't want auto play set data to true
  2. id

    • int If you want to play a lot of media, add the IDs in the order of the videos / don't have the same ones
  3. builder

AudioController

  • pause
  • play

Video

Documentation video


Scaffold(
  child: Video(
    mediaData: MediaData.file(
      file: File(path),
    ),
    isAutoStart: false,
    builder: (BuildContext context, Widget child, Video video, VideoState videoState, MediaController mediaController) {
      /// custom view
      return child;
    }
  );
)
  1. mediaData
  • file
    MediaData.file(
      file: File("./path_to_video.mp4"),
    )
    
  • asset
    MediaData.asset(
      asset: "assets/videos/video.mp4",
    )
    
  • network
    MediaData.network(
      url: "https://example.com/example.mp4",
    )
    
  1. isAutoStart

    • true if you want auto play set data to true
    • false if you don't want auto play set data to true
  2. id

    • int If you want to play a lot of media, add the IDs in the order of the videos / don't have the same ones
  3. builder

MediaController

  • seek(Duration())
  • playOrPause
  • isPlaying
  • pause
  • play
  • size
  • aspectRatio
  • setPlaybackSpeed(1.5)
  • setVolume(0.5)