npaw_forge_better_player_plus 9.6.0 copy "npaw_forge_better_player_plus: ^9.6.0" to clipboard
npaw_forge_better_player_plus: ^9.6.0 copied to clipboard

NPAW Forge adapter for the better_player_plus Flutter player: reports typed playback lifecycle plus track-level QoS (bitrate, rendition, fps) to the Forge core.

example/lib/main.dart

// Copyright (C) NPAW - All Rights Reserved
//
// This source code is protected under international copyright law. All rights
// reserved and protected by the copyright holders. This file is confidential and
// only available to authorized individuals with the permission of the copyright
// holders. If you encounter this file and do not have permission, please contact
// the copyright holders and delete this file.
//
//
// @author: Victor Soto <victor.soto@nicepeopleatwork.com>
// @description: NPAW Forge better_player_plus example app playing a sample stream with automatic analytics.

import 'package:better_player_plus/better_player_plus.dart';
import 'package:flutter/material.dart';
import 'package:npaw_forge/npaw_forge.dart';
import 'package:npaw_forge_better_player_plus/npaw_forge_better_player_plus.dart';

/// Demo account; override with --dart-define=FORGE_ACCOUNT_CODE=yourAccount.
const String accountCode = String.fromEnvironment(
  'FORGE_ACCOUNT_CODE',
  defaultValue: 'npawdemodev',
);

/// Ingest endpoint; point smoke runs at stage, never production.
const String lmaEndpoint = String.fromEnvironment('FORGE_LMA_ENDPOINT');

const String sampleStream = String.fromEnvironment(
  'FORGE_SAMPLE_STREAM',
  defaultValue: 'https://test-streams.mux.dev/x36xhzz/x36xhzz.m3u8',
);

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();
  final forge = await NpawForge.start(
    ForgeConfig(
      accountCode: accountCode,
      appName: 'npaw-forge-better-player-plus-example',
      lmaEndpoint: lmaEndpoint.isEmpty ? null : lmaEndpoint,
      logLevel: 'info',
    ),
  );
  WidgetsBinding.instance.addObserver(ForgeLifecycleObserver(forge));
  runApp(ExampleApp(forge: forge));
}

class ExampleApp extends StatefulWidget {
  const ExampleApp({required this.forge, super.key});

  final NpawForge forge;

  @override
  State<ExampleApp> createState() => _ExampleAppState();
}

class _ExampleAppState extends State<ExampleApp> {
  late final BetterPlayerController controller = BetterPlayerController(
    const BetterPlayerConfiguration(autoPlay: true, aspectRatio: 16 / 9),
  );
  ForgeBetterPlayerAttachment? attachment;

  @override
  void initState() {
    super.initState();
    _start();
  }

  Future<void> _start() async {
    attachment = await attachBetterPlayer(
      widget.forge,
      controller,
      metadata:
          const ContentMetadata(title: 'better_player_plus sample stream'),
    );
    await controller.setupDataSource(
      BetterPlayerDataSource.network(sampleStream),
    );
  }

  @override
  void dispose() {
    attachment?.dispose();
    controller.dispose(forceDispose: true);
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Forge better_player_plus example',
      home: Scaffold(
        appBar: AppBar(title: const Text('Forge better_player_plus example')),
        body: Center(
          child: AspectRatio(
            aspectRatio: 16 / 9,
            child: BetterPlayer(controller: controller),
          ),
        ),
      ),
    );
  }
}
0
likes
0
points
634
downloads

Publisher

unverified uploader

Weekly Downloads

NPAW Forge adapter for the better_player_plus Flutter player: reports typed playback lifecycle plus track-level QoS (bitrate, rendition, fps) to the Forge core.

Homepage
Repository

License

unknown (license)

Dependencies

better_player_plus, flutter, npaw_forge

More

Packages that depend on npaw_forge_better_player_plus