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
890 changes: 489 additions & 401 deletions CHANGELOG.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ internal class BetterPlayer(
private val customDefaultLoadControl: CustomDefaultLoadControl =
customDefaultLoadControl ?: CustomDefaultLoadControl()
private var lastSendBufferedPosition = 0L
private var playerErrorStatus: Boolean = false

init {
val loadBuilder = DefaultLoadControl.Builder()
Expand Down Expand Up @@ -485,11 +486,17 @@ internal class BetterPlayer(
}
Player.STATE_IDLE -> {
//no-op
if (playerErrorStatus) {
val event: MutableMap<String, Any> = HashMap()
event["event"] = "stalledCheck"
eventSink.success(event)
}
}
}
}

override fun onPlayerError(error: PlaybackException) {
playerErrorStatus = true
eventSink.error("VideoError", "Video player had error $error", "")
}
})
Expand Down
2 changes: 1 addition & 1 deletion example/ios/Flutter/AppFrameworkInfo.plist
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
<key>CFBundleVersion</key>
<string>1.0</string>
<key>MinimumOSVersion</key>
<string>9.0</string>
<string>11.0</string>
</dict>
</plist>
2 changes: 1 addition & 1 deletion example/ios/Podfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Uncomment this line to define a global platform for your project
# platform :ios, '9.0'
# platform :ios, '11.0'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
Expand Down
25 changes: 17 additions & 8 deletions example/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@
"${BUILT_PRODUCTS_DIR}/PINCache/PINCache.framework",
"${BUILT_PRODUCTS_DIR}/PINOperation/PINOperation.framework",
"${BUILT_PRODUCTS_DIR}/better_player/better_player.framework",
"${BUILT_PRODUCTS_DIR}/path_provider_ios/path_provider_ios.framework",
"${BUILT_PRODUCTS_DIR}/path_provider_foundation/path_provider_foundation.framework",
"${BUILT_PRODUCTS_DIR}/wakelock/wakelock.framework",
);
name = "[CP] Embed Pods Frameworks";
Expand All @@ -281,7 +281,7 @@
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/PINCache.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/PINOperation.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/better_player.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/path_provider_ios.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/path_provider_foundation.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/wakelock.framework",
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -364,7 +364,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos;
Expand All @@ -390,7 +390,10 @@
);
INFOPLIST_FILE = Runner/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/Flutter",
Expand Down Expand Up @@ -451,7 +454,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
Expand Down Expand Up @@ -500,7 +503,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos;
Expand All @@ -527,7 +530,10 @@
);
INFOPLIST_FILE = Runner/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/Flutter",
Expand Down Expand Up @@ -559,7 +565,10 @@
);
INFOPLIST_FILE = Runner/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/Flutter",
Expand Down
2 changes: 2 additions & 0 deletions example/ios/Runner/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,7 @@
</array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
<key>UIApplicationSupportsIndirectInputEvents</key>
<true/>
</dict>
</plist>
7 changes: 5 additions & 2 deletions example/lib/constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ class Constants {
static const String bugBuckBunnyVideoUrl =
"https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4";
static const String forBiggerBlazesUrl =
"https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ForBiggerBlazes.mp4";
"https://storage.googleapis.com/ps_videos/enterprise/YTrLL3LEIj2jM/YTrLL3LEIj2jM.m3u8";
// "https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ForBiggerBlazes.mp4";
static const String fileTestVideoUrl = "testvideo.mp4";
static const String fileTestVideoEncryptUrl = "testvideo_encrypt.mp4";
static const String networkTestVideoEncryptUrl =
Expand Down Expand Up @@ -33,8 +34,10 @@ class Constants {
static String logo = "logo.png";
static String placeholderUrl =
"https://imgix.bustle.com/uploads/image/2020/8/5/23905b9c-6b8c-47fa-bc0f-434de1d7e9bf-avengers-5.jpg";
// static String elephantDreamStreamUrl =
// "http://cdn.theoplayer.com/video/elephants-dream/playlist.m3u8";
static String elephantDreamStreamUrl =
"http://cdn.theoplayer.com/video/elephants-dream/playlist.m3u8";
"https://demo.unified-streaming.com/k8s/features/stable/video/tears-of-steel/tears-of-steel.ism/.m3u8";
static String tokenEncodedHlsUrl =
"https://amssamples.streaming.mediaservices.windows.net/830584f8-f0c8-4e41-968b-6538b9380aa5/TearsOfSteelTeaser.ism/manifest(format=m3u8-aapl)";
static String tokenEncodedHlsToken =
Expand Down
3 changes: 2 additions & 1 deletion example/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:better_player_example/pages/player_page.dart';
import 'package:better_player_example/pages/welcome_page.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
Expand Down Expand Up @@ -25,7 +26,7 @@ class MyApp extends StatelessWidget {
theme: ThemeData(
primarySwatch: Colors.green,
),
home: WelcomePage(),
home: PlayerPageWidget(),
));
}
}
12 changes: 8 additions & 4 deletions example/lib/pages/hls_audio_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ class _HlsAudioPageState extends State<HlsAudioPage> {

@override
void initState() {
print("_HlsAudioPageState");
BetterPlayerConfiguration betterPlayerConfiguration =
BetterPlayerConfiguration(
aspectRatio: 16 / 9,
fit: BoxFit.contain,
autoPlay: true,
);
BetterPlayerDataSource dataSource = BetterPlayerDataSource(
BetterPlayerDataSourceType.network,
Expand Down Expand Up @@ -44,10 +46,12 @@ class _HlsAudioPageState extends State<HlsAudioPage> {
style: TextStyle(fontSize: 16),
),
),
AspectRatio(
aspectRatio: 16 / 9,
child: BetterPlayer(controller: _betterPlayerController),
),
_betterPlayerController.isVideoInitialized() ?? false
? AspectRatio(
aspectRatio: 16 / 9,
child: BetterPlayer(controller: _betterPlayerController),
)
: Container(),
],
),
);
Expand Down
47 changes: 37 additions & 10 deletions example/lib/pages/normal_player_page.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import 'package:better_player/better_player.dart';
import 'package:better_player_example/constants.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:path/path.dart' as path;

class NormalPlayerPage extends StatefulWidget {
final String videoLink;

const NormalPlayerPage({Key? key, required this.videoLink}) : super(key: key);
@override
_NormalPlayerPageState createState() => _NormalPlayerPageState();
}
Expand All @@ -15,25 +17,50 @@ class _NormalPlayerPageState extends State<NormalPlayerPage> {
@override
void initState() {
BetterPlayerConfiguration betterPlayerConfiguration =
BetterPlayerConfiguration(
aspectRatio: 16 / 9,
fit: BoxFit.contain,
const BetterPlayerConfiguration(
autoPlay: true,
autoDetectFullscreenAspectRatio: true,
looping: true,
deviceOrientationsAfterFullScreen: [
DeviceOrientation.portraitDown,
DeviceOrientation.portraitUp
],
handleLifecycle: true,
autoDispose: false,
controlsConfiguration: BetterPlayerControlsConfiguration(
showControls: true,
showControlsOnInitialize: true,
enableProgressBar: true,
),
);
final String extension = path.extension(widget.videoLink);
_betterPlayerDataSource = BetterPlayerDataSource(
BetterPlayerDataSourceType.network,
Constants.forBiggerBlazesUrl,
widget.videoLink,
videoExtension: extension == ".m3u8" ? "m3u8" : extension.substring(1),
videoFormat: extension == ".m3u8" ? BetterPlayerVideoFormat.hls : null,
liveStream: extension == ".m3u8" ? true : null,
bufferingConfiguration: const BetterPlayerBufferingConfiguration(
minBufferMs: 3000,
bufferForPlaybackMs: 250,
bufferForPlaybackAfterRebufferMs: 500,
maxBufferMs: 3000,
),
cacheConfiguration: extension != ".m3u8"
? null
: BetterPlayerCacheConfiguration(
useCache: true,
key: widget.videoLink,
),
preferredForwardBufferDurationIos: 3,
);
_betterPlayerController = BetterPlayerController(betterPlayerConfiguration);
_betterPlayerController.setupDataSource(_betterPlayerDataSource);
super.initState();
}

@override
void dispose() {
_betterPlayerController.dispose(forceDispose: true);
super.dispose();
}

@override
Widget build(BuildContext context) {
return Scaffold(
Expand Down
44 changes: 44 additions & 0 deletions example/lib/pages/player_page.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import 'package:better_player_example/pages/normal_player_page.dart';
import 'package:flutter/material.dart';

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

@override
State<PlayerPageWidget> createState() => _PlayerPageWidgetState();
}

class _PlayerPageWidgetState extends State<PlayerPageWidget> {
TextEditingController textEditingController = TextEditingController();
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Btter player testing"),
),
body: Column(
children: [
Padding(
padding: const EdgeInsets.all(16.0),
child: TextField(
controller: textEditingController,
decoration: InputDecoration(hintText: "Enter m3u8 video link"),
),
),
ElevatedButton(
onPressed: () {
Navigator.of(context).push<void>(
MaterialPageRoute(
builder: (context) => NormalPlayerPage(
videoLink: textEditingController.text,
),
),
);
},
child: Text("Submit"),
),
],
),
);
}
}
3 changes: 2 additions & 1 deletion example/lib/pages/welcome_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import 'package:better_player_example/pages/notification_player_page.dart';
import 'package:better_player_example/pages/overridden_aspect_ratio_page.dart';
import 'package:better_player_example/pages/overriden_duration_page.dart';
import 'package:better_player_example/pages/placeholder_until_play_page.dart';
import 'package:better_player_example/pages/player_page.dart';
import 'package:better_player_example/pages/playlist_page.dart';
import 'package:better_player_example/pages/resolutions_page.dart';
import 'package:better_player_example/pages/reusable_video_list/reusable_video_list_page.dart';
Expand Down Expand Up @@ -82,7 +83,7 @@ class _WelcomePageState extends State<WelcomePage> {
_navigateToPage(BasicPlayerPage());
}),
_buildExampleElementWidget("Normal player", () {
_navigateToPage(NormalPlayerPage());
_navigateToPage(PlayerPageWidget());
}),
_buildExampleElementWidget("Controls configuration", () {
_navigateToPage(ControlsConfigurationPage());
Expand Down
4 changes: 2 additions & 2 deletions ios/Classes/BetterPlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ NS_ASSUME_NONNULL_BEGIN
- (instancetype)initWithFrame:(CGRect)frame;
- (void)setMixWithOthers:(bool)mixWithOthers;
- (void)seekTo:(int)location;
- (void)setDataSourceAsset:(NSString*)asset withKey:(NSString*)key withCertificateUrl:(NSString*)certificateUrl withLicenseUrl:(NSString*)licenseUrl cacheKey:(NSString*)cacheKey cacheManager:(CacheManager*)cacheManager overriddenDuration:(int) overriddenDuration;
- (void)setDataSourceURL:(NSURL*)url withKey:(NSString*)key withCertificateUrl:(NSString*)certificateUrl withLicenseUrl:(NSString*)licenseUrl withHeaders:(NSDictionary*)headers withCache:(BOOL)useCache cacheKey:(NSString*)cacheKey cacheManager:(CacheManager*)cacheManager overriddenDuration:(int) overriddenDuration videoExtension: (NSString*) videoExtension;
- (void)setDataSourceAsset:(NSString*)asset withKey:(NSString*)key withCertificateUrl:(NSString*)certificateUrl withLicenseUrl:(NSString*)licenseUrl cacheKey:(NSString*)cacheKey cacheManager:(CacheManager*)cacheManager overriddenDuration:(int)overriddenDuration;
- (void)setDataSourceURL:(NSURL*)url withKey:(NSString*)key withCertificateUrl:(NSString*)certificateUrl withLicenseUrl:(NSString*)licenseUrl withHeaders:(NSDictionary*)headers withCache:(BOOL)useCache cacheKey:(NSString*)cacheKey cacheManager:(CacheManager*)cacheManager overriddenDuration:(int)overriddenDuration videoExtension:(NSString*)videoExtension preferredForwardBufferDurationIos:(int)preferredForwardBufferDurationIos;
- (void)setVolume:(double)volume;
- (void)setSpeed:(double)speed result:(FlutterResult)result;
- (void) setAudioTrack:(NSString*) name index:(int) index;
Expand Down
Loading