Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ android {
implementation "com.google.android.exoplayer:exoplayer-smoothstreaming:$exoPlayerVersion"
implementation "com.google.android.exoplayer:exoplayer-ui:$exoPlayerVersion"
implementation "com.google.android.exoplayer:extension-mediasession:$exoPlayerVersion"


implementation "androidx.lifecycle:lifecycle-runtime-ktx:$lifecycleVersion"
implementation "androidx.lifecycle:lifecycle-common:$lifecycleVersion"
implementation "androidx.lifecycle:lifecycle-common-java8:$lifecycleVersion"
Expand Down
2 changes: 1 addition & 1 deletion example/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ subprojects {
project.evaluationDependsOn(':app')
}

task clean(type: Delete) {
tasks.register("clean", Delete) {
delete rootProject.buildDir
}
2 changes: 1 addition & 1 deletion example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,4 @@ SPEC CHECKSUMS:

PODFILE CHECKSUM: ef19549a9bc3046e7bb7d2fab4d021637c0c58a3

COCOAPODS: 1.14.3
COCOAPODS: 1.15.2
5 changes: 3 additions & 2 deletions example/lib/constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ class Constants {
static const String networkTestVideoEncryptUrl =
"https://github.com/tinusneethling/betterplayer/raw/ClearKeySupport/example/assets/testvideo_encrypt.mp4";
static const String fileExampleSubtitlesUrl = "example_subtitles.srt";
static const String hlsTestStreamUrl =
"https://mtoczko.github.io/hls-test-streams/test-group/playlist.m3u8";
static const String hlsTestStreamUrl ='https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8';
// 'https://demo.unified-streaming.com/k8s/features/stable/video/tears-of-steel/tears-of-steel.ism/.m3u8';
// "https://mtoczko.github.io/hls-test-streams/test-group/playlist.m3u8";
static const String hlsPlaylistUrl =
"https://bitdash-a.akamaihd.net/content/sintel/hls/playlist.m3u8";
static const Map<String, String> exampleResolutionsUrls = {
Expand Down
1 change: 1 addition & 0 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class MyApp extends StatelessWidget {
LogicalKeySet(LogicalKeyboardKey.select): const ActivateIntent(),
},
child: MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Better player demo',
localizationsDelegates: [
GlobalMaterialLocalizations.delegate,
Expand Down
115 changes: 54 additions & 61 deletions example/lib/pages/basic_player_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,78 +16,71 @@ class _BasicPlayerPageState extends State<BasicPlayerPage> {
void initState() {
_betterPlayerDataSource = BetterPlayerDataSource(
BetterPlayerDataSourceType.network,
'https://d357lqen3ahf81.cloudfront.net/transcoded/Af34Dm2h4M5/video.m3u8',
'https://d357lqen3ahf81.cloudfront.net/transcoded/7EsHghnDzbx/video.m3u8',
cacheConfiguration: const BetterPlayerCacheConfiguration(useCache: true),
bufferingConfiguration: const BetterPlayerBufferingConfiguration(maxBufferMs: 3000, minBufferMs: 1000),
bufferingConfiguration: const BetterPlayerBufferingConfiguration(),
);

_controller = BetterPlayerController(BetterPlayerConfiguration(autoPlay: true),
_controller = BetterPlayerController(
BetterPlayerConfiguration(
autoPlay: true,
),
betterPlayerDataSource: _betterPlayerDataSource);
super.initState();
}

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Basic player"),
),
body: ListView(
children: [
const SizedBox(height: 8),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: Text(
"Basic player created with the simplest factory method. Shows video from URL.",
style: TextStyle(fontSize: 16),
return MaterialApp(
debugShowCheckedModeBanner: false,
home: Scaffold(
appBar: AppBar(
title: Text("Basic player"),
),
body: ListView(
children: [
const SizedBox(height: 8),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: Text(
"Basic player created with the simplest factory method. Shows video from URL.",
style: TextStyle(fontSize: 16),
),
),
),
// AspectRatio(
// aspectRatio: 16 / 9,
// child: BetterPlayer.network(
// Constants.forBiggerBlazesUrl,
// ),
// ),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: Text(
"Next player shows video from file.",
style: TextStyle(fontSize: 16),
BetterPlayer(controller: _controller!),
const SizedBox(height: 8),
// FutureBuilder<String>(
// future: Utils.getFileUrl(Constants.fileTestVideoUrl),
// builder: (BuildContext context, AsyncSnapshot<String> snapshot) {
// if (snapshot.data != null) {
// return BetterPlayer(
// controller: _controller!,
// );
// } else {
// return const SizedBox();
// }
// },
// ),
SizedBox(
height: 20,
),
),
const SizedBox(height: 8),
FutureBuilder<String>(
future: Utils.getFileUrl(Constants.fileTestVideoUrl),
builder: (BuildContext context, AsyncSnapshot<String> snapshot) {
if (snapshot.data != null) {
return BetterPlayer(
controller: _controller!,
);
} else {
return const SizedBox();
}
},
),

SizedBox(
height: 20,
),

AnimatedContainer(
width: double.infinity,
height: 350,
duration: const Duration(milliseconds: 300),
// color: _controller.value.isControlsVisible ? Colors.black.withAlpha(150) : Colors.transparent,
// color: Colors.black.withAlpha(120)
decoration: BoxDecoration(
gradient: LinearGradient(colors: [
Color(0xff000000),
Color(0xff000000).withOpacity(0),
Color(0xff000000),
], begin: Alignment.topCenter, end: Alignment.bottomCenter),
AnimatedContainer(
width: double.infinity,
height: 350,
duration: const Duration(milliseconds: 300),
// color: _controller.value.isControlsVisible ? Colors.black.withAlpha(150) : Colors.transparent,
// color: Colors.black.withAlpha(120)
decoration: BoxDecoration(
gradient: LinearGradient(colors: [
Color(0xff000000),
Color(0xff000000).withOpacity(0),
Color(0xff000000),
], begin: Alignment.topCenter, end: Alignment.bottomCenter),
),
// color: Colors.red,
),
// color: Colors.red,
),
],
],
),
),
);
}
Expand Down
21 changes: 18 additions & 3 deletions example/lib/pages/hls_tracks_page.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'dart:developer';

import 'package:better_player/better_player.dart';
import 'package:better_player_example/constants.dart';
import 'package:flutter/material.dart';
Expand All @@ -24,9 +26,20 @@ class _HlsTracksPageState extends State<HlsTracksPage> {
);
_betterPlayerController = BetterPlayerController(betterPlayerConfiguration);
_betterPlayerController.setupDataSource(dataSource);

super.initState();
}

@override
void dispose() {
// TODO: implement dispose

log('9048 crossed checkpoints ---> ${_betterPlayerController.getCheckPointsCount()}');
_betterPlayerController.dispose();

super.dispose();
}

@override
Widget build(BuildContext context) {
return Scaffold(
Expand All @@ -44,9 +57,11 @@ class _HlsTracksPageState extends State<HlsTracksPage> {
style: TextStyle(fontSize: 16),
),
),
AspectRatio(
aspectRatio: 16 / 9,
child: BetterPlayer(controller: _betterPlayerController),
Flexible(
child: AspectRatio(
aspectRatio: 16 / 9,
child: BetterPlayer(controller: _betterPlayerController),
),
),
],
),
Expand Down
21 changes: 21 additions & 0 deletions lib/src/checkPoints/check_points.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
class CheckPointData {
final double videoFraction;
final bool status;

CheckPointData({required this.status, required this.videoFraction});

CheckPointData copyWith({
double? value,
bool? status,
}) {
return CheckPointData(
videoFraction: value ?? this.videoFraction,
status: status ?? this.status,
);
}

@override
String toString() {
return 'CheckPointData(value: $videoFraction, status: $status)';
}
}
Loading