vdocipher_flutter 2.6.5 copy "vdocipher_flutter: ^2.6.5" to clipboard
vdocipher_flutter: ^2.6.5 copied to clipboard

A VdoCipher plugin for flutter apps. This Plugin will help to serve content on supported platform app with Hollywood grade security to prevent video piracy.

example/lib/main.dart

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

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

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

  @override
  Widget build(BuildContext context) {
    SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle(
      statusBarColor: Colors.blue.shade700, // status bar color
    ));
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      home: const MyHome(),
      navigatorObservers: [
        VdoPlayerController.navigatorObserver('/player/(.*)')
      ],
      theme: ThemeData(
          primaryColor: Colors.blue,
          textTheme: const TextTheme(bodyLarge: TextStyle(fontSize: 14.0))),
    );
  }
}

class MyHome extends StatefulWidget {
  const MyHome({Key? key}) : super(key: key);

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

class MyHomeState extends State<MyHome> {
  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: const Text('VdoCipher Example'),
          centerTitle: true,
        ),
        body: const VdoPlaybackView(
          controls: true,
        ));
  }
}

const EmbedInfo sample_1 = EmbedInfo.streaming(
    otp: '20150519versASE31ba8fc50a0ac49b8e74b9c40f49e099755cd36dc8adccaa3',
    playbackInfo:
        'eyJ2aWRlb0lkIjoiM2YyOWI1NDM0YTVjNjE1Y2RhMThiMTZhNjIzMmZkNzUifQ==');

class VdoPlaybackView extends StatefulWidget {
  final bool controls;

  const VdoPlaybackView({Key? key, this.controls = true}) : super(key: key);

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

class VdoPlaybackViewState extends State<VdoPlaybackView> {
  VdoPlayerController? _controller;
  VdoPlayerValue? vdoPlayerValue;
  final double aspectRatio = 16 / 9;
  final ValueNotifier<bool> _isFullScreen = ValueNotifier(false);
  Duration? duration;

  @override
  Widget build(BuildContext context) {
    String? mediaId = ModalRoute.of(context)?.settings.arguments as String?;
    EmbedInfo embedInfo = sample_1;
    if (mediaId != null && mediaId.isNotEmpty) {
      embedInfo = EmbedInfo.offline(mediaId: mediaId);
    }
    return Scaffold(
        body: SafeArea(
      child: Column(crossAxisAlignment: CrossAxisAlignment.stretch, children: [
        Stack(
          alignment: Alignment.center,
          children: [
            SizedBox(
              width: _getPlayerWidth(),
              height: _getPlayerHeight(),
              child: VdoPlayer(
                embedInfo: embedInfo,
                aspectRatio: aspectRatio,
                onError: _onVdoError,
                onFullscreenChange: _onFullscreenChange,
                onPlayerCreated: _onPlayerCreated,
                controls: widget.controls,
                onPictureInPictureModeChanged: _onPictureInPictureModeChanged,
              ),
            )
          ],
        ),
      ]),
    ));
  }

  _onVdoError(VdoError vdoError) {
    if (kDebugMode) {
      print("Oops, the system encountered a problem: ${vdoError.message}");
    }
  }

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

  _onPictureInPictureModeChanged(bool isInPictureInPictureMode) {}

  _onEventChange(VdoPlayerController? controller) {
    controller?.addListener(() {
      setState(() {
        vdoPlayerValue = controller.value;
      });
    });
  }

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

  _getPlayerWidth() {
    return kIsWeb ? 800 : MediaQuery.of(context).size.width;
  }

  _getPlayerHeight() {
    return kIsWeb
        ? 550
        : _isFullScreen.value
            ? MediaQuery.of(context).size.height
            : _getHeightForWidth(MediaQuery.of(context).size.width);
  }

  double _getHeightForWidth(double width) {
    return width / aspectRatio;
  }
}
19
likes
120
pub points
89%
popularity

Publisher

verified publishervdocipher.com

A VdoCipher plugin for flutter apps. This Plugin will help to serve content on supported platform app with Hollywood grade security to prevent video piracy.

Homepage

Documentation

API reference

License

MIT (LICENSE)

Dependencies

flutter, flutter_web_plugins, js, plugin_platform_interface

More

Packages that depend on vdocipher_flutter