vdocipher_flutter

VdoCipher plugin for flutter apps.

This project is a Flutter plugin package, that will enable video playback functionality by delegating to respective native libraries based on the platform.

Note:

  1. Please contact us at support@vdocipher.com before using it in your application
  2. IOS is not supported. Only Android support available. IOS support will be added in future.

Getting started

Run this command with Flutter:

$ flutter pub add vdocipher_flutter

This will add a line like this to your package's pubspec.yaml (and run an implicit dart pub get):

dependencies:
  vdocipher_flutter: ^1.0.0-alpha.3

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

Import it

Now in your Dart code, you can use:

import 'package:vdocipher_flutter/vdocipher_flutter.dart';

Example

vdoplayback_view.dart

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

const EmbedInfo _embedInfo = EmbedInfo.streaming(
    otp: '20160313versASE313BlEe9YKEaDuju5J0XcX2Z03Hrvm5rzKScvuyojMSBZBxfZ',
    playbackInfo: 'eyJ2aWRlb0lkIjoiM2YyOWI1NDM0YTVjNjE1Y2RhMThiMTZhNjIzMmZkNzUifQ==',
    embedInfoOptions: EmbedInfoOptions(
        autoplay: true
    )
);

class VdoPlaybackView extends StatefulWidget {

  @override
  _VdoPlaybackViewState createState() => _VdoPlaybackViewState();
}

class _VdoPlaybackViewState extends State<VdoPlaybackView> {
  VdoPlayerController _controller;
  final double aspectRatio = 16/9;
  ValueNotifier<bool> _isFullScreen = ValueNotifier(false);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Column(
        crossAxisAlignment: CrossAxisAlignment.stretch,
        children: [
          Flexible(child: Container(
            child: VdoPlayer(
                embedInfo: _embedInfo,
                onPlayerCreated: (controller) => _onPlayerCreated(controller),
                onFullscreenChange: _onFullscreenChange),
            width: MediaQuery.of(context).size.width,
            height: _isFullScreen.value ? MediaQuery.of(context).size.height : _getHeightForWidth(MediaQuery.of(context).size.width),
          )),
          ValueListenableBuilder(
              valueListenable: _isFullScreen,
              builder: (context, value, child) {
                return value ? SizedBox.shrink() : _nonFullScreenContent();
              })
      ])
    );
  }

  _onPlayerCreated(VdoPlayerController controller) {
    setState(() {
      _controller = controller;
    });
  }

  _onFullscreenChange(isFullscreen) {
    setState(() {
      _isFullScreen.value = isFullscreen;
    });
  }

  _nonFullScreenContent() {
    return Column(
        children: [
          Text('Sample Playback', style: TextStyle(fontSize: 20.0),)
      ]);
  }

  double _getHeightForWidth(double width) {
    return width / aspectRatio;
  }
}

VdoPlayer

PropertyTypeDescription
embedInfoEmbedInfoEmbed info object
onPlayerCreated(controller)Function(VdoController)Callback function returns VdoController object

EmbedInfo

PropertyTypeDescription
offlinebool (Default false)Video will be offline or online
otpStringa valid OTP
playbackInfoStringA valid playbackinfo;
mediaIdStringA valid mediaId
embedInfoOptionsEmbedInfoOptionsEmbed Info options

EmbedInfoOptions

PropertyTypeDescription
safetyNetApiKeyStringA valid SafetyNetApiKey
preferredCaptionsLanguageStringPreferred caption language
startPositionDurationVideo start position
endPositionDurationVideo end position
resumePositionDurationVdeo resume position
maxVideoBitrateKbpsintMaximum video bitrate KBPS
bufferingGoalMsintBuffering goal in MS
techOverrideList<String>Tech override list
disableAnalyticsbool (Default false)Disable analytics
autoplaybool (Default true)Start autoplay
forceLowestBitratebool (Default false)Force lowest bitrate
forceHighestSupportedBitratebool (Default false)Force highest supported Bitrat

VdoController

PropertyReturn TypeDescription
isPlayingboolVideo playing
isBufferingboolVideo buffering
isLoadingboolVideo loading
isEndedboolVideo fully watched
isFullScreenValueNotifier<bool>Video is in full screen or portrait mode
enterFullScreen(bool isFull)voidSet full screen mode
load(EmbedInfo embedInfo)Future<LoadResult>Load video with embed info
play()Future<void>Play video
pause()Future<void>Pause video
stop()Future<void>Stop video
getDuration()Future<Duration>Get video duration
getPosition()Future<Duration>Get current video played position
seek(Duration target)Future<void>Seek video to target duration
setPlaybackSpeed(double speed)Future<void>Set playback speed
setCaptionLanguage(String language)Future<bool>Set Caption Language

Libraries

vdocipher_flutter
VdoCipher Flutter plugin