Smart Player plugin for Flutter

A Flutter plugin for iOS and Android for playing back video on a Widget surface.

Android iOS
Support SDK 21+ 11.0+

Main Features

  • Add ads before video.
  • Dynamic ads url.
  • Casting.
  • Aspect ratio.
  • Dynamic color option.
  • Play back speed.
  • Screen lock option.

Future Feature

  • Picture-in-picture mode.
  • Access video from files.

Screenshots

Installation

First, add smart_player as a dependency in your pubspec.yaml file.

iOS

If you need to access videos using http (rather than https) URLs, you will need to add the appropriate NSAppTransportSecurity permissions to your app's Info.plist file, located in <project root>/ios/Runner/Info.plist. See Apple's documentation to determine the right combination of entries for your use case and supported iOS versions.

Android

If you are using network-based videos, ensure that the following permission is present in your Android Manifest file, located in <project root>/android/app/src/main/AndroidManifest.xml:

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

Supported Formats

  • On iOS, the backing player is AVPlayer. The supported formats vary depending on the version of iOS, AVURLAsset class has audiovisualTypes that you can query for supported av formats.
  • On Android, the backing player is ExoPlayer, please refer here for list of supported formats.

Example

import 'package:flutter/material.dart';
import 'package:smart_player/video_player_page.dart';

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

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Smart Player Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const MyHomePage(title: 'Smart Player'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({Key? key, required this.title}) : super(key: key);
  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: SizedBox(
        height: 300,
        width: MediaQuery.of(context).size.width,
        child: const SmartPlayer(
          url: "https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/WeAreGoingOnBullrun.mp4",
        ),
      ),
    );
  }
}

Usage

The following section contains usage information that goes beyond what is included in the documentation in order to give a more elaborate overview of the API.