jhomlala / betterplayer

Better video player for Flutter, with multiple configuration options. Solving typical use cases!

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[BUG] Wrong duration when playing Clear Key encrypted video

mouhandalkadri opened this issue · comments

History check
No issues mentioned this bug before

Describe the bug
When trying to play a video encrypted by Clear Key better_player shows wrong duration. for example we tried to play the video provided in the examples we are getting duration of 00:00. Even though the video is playing perfectly fine but the total duration is stuck at 00:00.

 
To Reproduce

  1. Install better_player
  2. Initialize video with clear key
  3. Use this link https://github.com/tinusneethling/betterplayer/raw/ClearKeySupport/example/assets/testvideo_encrypt.mp4 (The one provided in the example)
  4. Use the following keys
    { "f3c5e0361e6654b28f8049c778b23946": "a4631a153a443df9eed0593043db7519", "abba271e8bcf552bbd2e86a434a9a5d9": "69eaa802a6763af979e8d1940fb88392" }

*Example code

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

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


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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const BetterPlayerWithBug(),
    );
  }
}


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

  @override
  State<BetterPlayerWithBug> createState() => _BetterPlayerWithBugState();
}

class _BetterPlayerWithBugState extends State<BetterPlayerWithBug> {

  late BetterPlayerController _betterPlayerController;

  
  @override
  void initState() {
    
    BetterPlayerDataSource betterPlayerDataSource = BetterPlayerDataSource(
      BetterPlayerDataSourceType.network,
      "https://github.com/tinusneethling/betterplayer/raw/ClearKeySupport/example/assets/testvideo_encrypt.mp4",
      
      drmConfiguration: BetterPlayerDrmConfiguration(
        drmType: BetterPlayerDrmType.clearKey,
        clearKey: BetterPlayerClearKeyUtils.generateKey(({
            "f3c5e0361e6654b28f8049c778b23946":
                "a4631a153a443df9eed0593043db7519",
            "abba271e8bcf552bbd2e86a434a9a5d9":
                "69eaa802a6763af979e8d1940fb88392"
          })),
      ),
    );
    _betterPlayerController = BetterPlayerController(
      const BetterPlayerConfiguration(
        autoPlay: true,
      ),
    );
    
    _betterPlayerController.setupDataSource(betterPlayerDataSource);
    super.initState();
  }
  
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Column(
        children: [
          const SizedBox(height: 40,),
          Container(
            margin: const EdgeInsets.only(bottom: 15.0),
            height: 220,
            child: ClipRRect(
              borderRadius: BorderRadius.circular(15.0),
              child: SizedBox(
                child: BetterPlayer(
                  controller: _betterPlayerController,
                ),
              ),
            ),
          ),
        ],
      ),
    );
  }
}

Expected behavior
The player should show the right duration

Better Player version

  • Version: 0.83
  • Flutter: 3.0.4