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: 1 addition & 1 deletion lib/constants/api_constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ const String IMDB_BASE_URL = 'https://imdb.com/title/';
const String TWOEMBED_BASE_URL = 'https://2embed.biz';
const String CINEMAX_UPDATE_URL =
'https://beamlakaschalew.github.io/cinemax/res/update.json';
const String CONSUMET_API = 'https://cinemax-backend.vercel.app/';
const String CONSUMET_API = 'https://consumet-api-1p19.onrender.com/';
7 changes: 5 additions & 2 deletions lib/constants/app_constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const kTextSmallAboutBodyStyle = TextStyle(
const kTableLeftStyle =
TextStyle(overflow: TextOverflow.ellipsis, fontWeight: FontWeight.bold);

const String currentAppVersion = '2.1.0';
const String currentAppVersion = '2.1.1-bv3';

final client = HttpClient();
const retryOptions = RetryOptions(
Expand All @@ -60,7 +60,10 @@ final List<String> appNames = [
'cinemax-v2.0.0.apk',
'cinemax-v2.0.0-build-v2.apk',
'cinemax-v2.0.0-build-v3.apk',
'cinemax-v2.1.0.apk'
'cinemax-v2.1.0.apk',
'cinemax-v2.1.1.apk',
'cinemax-v2.1.1-bv2.apk',
'cinemax-v2.1.1-bv3.apk',
];

CacheManager cacheProp() {
Expand Down
8 changes: 8 additions & 0 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,15 @@ Future<void> appInitialize() async {
await settingsProvider.getMaxBufferDuration();
await settingsProvider.getVideoResolution();
await settingsProvider.getSubtitleLanguage();
await settingsProvider.getViewMode();
await _initialization;
// UnityAds.init(
// testMode: false,
// gameId: '5280322',
// onComplete: () => print('Initialization Complete'),
// onFailed: (error, message) =>
// print('Initialization Failed: $error $message'),
// );
}

void main() async {
Expand Down
13 changes: 12 additions & 1 deletion lib/models/setting_preferences.dart
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class ImagePreferences {
}

class Material3Preferences {
static const MATERIAL3_MODE_STATUS = "adultStatus";
static const MATERIAL3_MODE_STATUS = "materialStatus";

setMaterial3Mode(bool value) async {
SharedPreferences prefs = await SharedPreferences.getInstance();
Expand Down Expand Up @@ -151,4 +151,15 @@ class VideoPlayerPreferences {
SharedPreferences prefs = await SharedPreferences.getInstance();
return prefs.getString(DEFAULT_SUBTITLE) ?? '';
}

static const DEFAULT_FULL_SCREEN = 'default_full_screen';
setDefaultFullScreen(bool mode) async {
SharedPreferences prefs = await SharedPreferences.getInstance();
prefs.setBool(DEFAULT_FULL_SCREEN, mode);
}

Future<bool> autoFullScreen() async {
SharedPreferences prefs = await SharedPreferences.getInstance();
return prefs.getBool(DEFAULT_FULL_SCREEN) ?? true;
}
}
13 changes: 13 additions & 0 deletions lib/provider/settings_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ class SettingsProvider with ChangeNotifier {
String _defaultSubtitleLanguage = 'English';
String get defaultSubtitleLanguage => _defaultSubtitleLanguage;

bool _defaultViewMode = true;
bool get defaultViewMode => _defaultViewMode;

late Mixpanel mixpanel;

// theme change
Expand Down Expand Up @@ -146,6 +149,16 @@ class SettingsProvider with ChangeNotifier {
notifyListeners();
}

Future<void> getViewMode() async {
defaultViewMode = await videoPlayerPreferences.autoFullScreen();
}

set defaultViewMode(bool value) {
_defaultViewMode = value;
videoPlayerPreferences.setDefaultFullScreen(value);
notifyListeners();
}

// Future<void> getMinBufferDuration() async {
// defaultMinBufferDuration = await videoPlayerPreferences.getMinBuffer();
// }
Expand Down
4 changes: 2 additions & 2 deletions lib/screens/common/about.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ class AboutPage extends StatelessWidget {
],
),
const Text(
'Cinemax v2.1.0',
'Cinemax v2.1.1-bv3',
style: TextStyle(
fontSize: 27.0,
fontSize: 24.0,
),
),
const Text(
Expand Down
60 changes: 10 additions & 50 deletions lib/screens/common/live_player.dart
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
import 'dart:math';

import 'package:better_player/better_player.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:startapp_sdk/startapp.dart';

class LivePlayer extends StatefulWidget {
const LivePlayer({required this.sources, required this.colors, Key? key})
const LivePlayer(
{required this.sources,
required this.colors,
required this.autoFullScreen,
Key? key})
: super(key: key);
final Map<String, String> sources;
final List<Color> colors;
final bool autoFullScreen;

@override
State<LivePlayer> createState() => _LivePlayerState();
Expand All @@ -20,24 +23,12 @@ class _LivePlayerState extends State<LivePlayer> {
late BetterPlayerControlsConfiguration betterPlayerControlsConfiguration;
late BetterPlayerBufferingConfiguration betterPlayerBufferingConfiguration;
var startAppSdk = StartAppSdk();
StartAppRewardedVideoAd? rewardedVideoAd;
StartAppBannerAd? playerBannerAd;
late bool loadAd;

bool isEventOccur() {
Random random = Random();
int randomNumber = random.nextInt(10);
return randomNumber == 0;
}

@override
void initState() {
super.initState();
loadAd = isEventOccur();
if (loadAd == true) {
loadRewardedVideoAd();
}
startAppSdk.loadBannerAd(StartAppBannerType.MREC).then((bannerAd) {
startAppSdk.loadBannerAd(StartAppBannerType.BANNER).then((bannerAd) {
setState(() {
playerBannerAd = bannerAd;
});
Expand Down Expand Up @@ -91,46 +82,15 @@ class _LivePlayerState extends State<LivePlayer> {
_betterPlayerController.setupDataSource(dataSource).then((value) {
if (_betterPlayerController.videoPlayerController!.value.aspectRatio >
1.0) {
_betterPlayerController.enterFullScreen();
if (widget.autoFullScreen) {
_betterPlayerController.enterFullScreen();
}
}
});
}

void loadRewardedVideoAd() {
startAppSdk.loadRewardedVideoAd(
onAdNotDisplayed: () {
debugPrint('onAdNotDisplayed: rewarded video');
setState(() {
rewardedVideoAd?.dispose();
rewardedVideoAd = null;
});
},
onAdHidden: () {
debugPrint('onAdHidden: rewarded video');
setState(() {
rewardedVideoAd?.dispose();
rewardedVideoAd = null;
});
},
).then((rewardedVideoAd) {
setState(() {
this.rewardedVideoAd = rewardedVideoAd;
});
}).onError<StartAppException>((ex, stackTrace) {
debugPrint("Error loading Rewarded Video ad: ${ex.message}");
}).onError((error, stackTrace) {
debugPrint("Error loading Rewarded Video ad: $error");
});
}

@override
void dispose() {
if (rewardedVideoAd != null && loadAd == true) {
rewardedVideoAd!.show().onError((error, stackTrace) {
debugPrint("Error showing Rewarded Video ad: $error");
return false;
});
}
SystemChrome.setPreferredOrientations([
DeviceOrientation.portraitUp,
]);
Expand Down
74 changes: 29 additions & 45 deletions lib/screens/common/live_tv_screen.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import 'dart:math';

import 'package:cached_network_image/cached_network_image.dart';
import 'package:cinemax/models/live_tv.dart';
import 'package:cinemax/screens/common/live_player.dart';
Expand All @@ -19,6 +17,27 @@ class LiveTV extends StatefulWidget {
}

class _LiveTVState extends State<LiveTV> {
var startAppSdk = StartAppSdk();

StartAppBannerAd? bannerAd;

@override
void initState() {
startAppSdk
.loadBannerAd(StartAppBannerType.BANNER,
prefs: const StartAppAdPreferences(minCPM: 0.01))
.then((bannerAd) {
setState(() {
this.bannerAd = bannerAd;
});
}).onError<StartAppException>((ex, stackTrace) {
debugPrint("Error loading Banner ad: ${ex.message}");
}).onError((error, stackTrace) {
debugPrint("Error loading Banner ad: $error");
});
super.initState();
}

final List<CatImage> categories = [
CatImage(categoryName: 'General', imagePath: 'assets/images/general.png'),
CatImage(
Expand Down Expand Up @@ -72,7 +91,8 @@ class _LiveTVState extends State<LiveTV> {
),
);
}),
)))
))),
bannerAd != null ? StartAppBanner(bannerAd!) : Container()
],
),
));
Expand Down Expand Up @@ -131,9 +151,8 @@ class _ChannelListState extends State<ChannelList> {
@override
void initState() {
startAppSdk
.loadBannerAd(
StartAppBannerType.BANNER,
)
.loadBannerAd(StartAppBannerType.BANNER,
prefs: const StartAppAdPreferences(minCPM: 0.01))
.then((bannerAd) {
setState(() {
this.bannerAd = bannerAd;
Expand Down Expand Up @@ -197,9 +216,6 @@ class ChannelWidget extends StatefulWidget {

class _ChannelWidgetState extends State<ChannelWidget> {
Map<String, String> videos = {};
var startAppSdk = StartAppSdk();
late bool showAd;
StartAppInterstitialAd? interstitialAd;
Map<String, String> reversedVids = {};

void sett() {
Expand All @@ -215,66 +231,34 @@ class _ChannelWidgetState extends State<ChannelWidget> {
}
}

bool isEventOccur() {
Random random = Random();
int randomNumber = random.nextInt(4);
return randomNumber == 0;
}

@override
void initState() {
loadInterstitialAd();
sett();
super.initState();
}

void loadInterstitialAd() {
startAppSdk.loadInterstitialAd().then((interstitialAd) {
setState(() {
this.interstitialAd = interstitialAd;
});
}).onError<StartAppException>((ex, stackTrace) {
debugPrint("Error loading Interstitial ad: ${ex.message}");
}).onError((error, stackTrace) {
debugPrint("Error loading Interstitial ad: $error");
});
}

@override
Widget build(BuildContext context) {
return Column(
children: [
InkWell(
child: GestureDetector(
onTap: () {
setState(() {
showAd = isEventOccur();
});
final mixpanel =
Provider.of<SettingsProvider>(context, listen: false)
.mixpanel;
final autoFS =
Provider.of<SettingsProvider>(context, listen: false)
.defaultViewMode;
mixpanel.track('Most viewed TV channels', properties: {
'TV Channel name': widget.channel.channelName,
'Category': widget.catName,
});
if (interstitialAd != null && showAd == true) {
interstitialAd!.show().then((shown) {
if (shown) {
setState(() {
interstitialAd = null;
loadInterstitialAd();
});
}

return null;
}).onError((error, stackTrace) {
debugPrint("Error showing Interstitial ad: $error");
});
}

Navigator.push(context, MaterialPageRoute(builder: ((context) {
return LivePlayer(
sources: reversedVids,
autoFullScreen: autoFS,
colors: [
Theme.of(context).primaryColor,
Theme.of(context).colorScheme.background
Expand Down
2 changes: 1 addition & 1 deletion lib/screens/common/player.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class _PlayerOneState extends State<PlayerOne> {
BetterPlayerConfiguration betterPlayerConfiguration =
BetterPlayerConfiguration(
autoDetectFullscreenDeviceOrientation: true,
fullScreenByDefault: true,
fullScreenByDefault: widget.videoProperties.elementAt(3),
autoPlay: true,
fit: BoxFit.contain,
autoDispose: true,
Expand Down
14 changes: 14 additions & 0 deletions lib/screens/common/player_settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,27 @@ class _PlayerSettingsState extends State<PlayerSettings> {
final seekSecond = Provider.of<SettingsProvider>(context);
final bufferAmount = Provider.of<SettingsProvider>(context);
final videoResolution = Provider.of<SettingsProvider>(context);
final videoOrientation = Provider.of<SettingsProvider>(context);
// final subtitleLanguage = Provider.of<SettingsProvider>(context);
return Scaffold(
appBar: AppBar(
title: const Text('Player settings'),
),
body: Column(
children: [
ListTile(
leading: const Icon(Icons.fullscreen),
title: const Text('Auto full screen'),
trailing: Switch(
inactiveThumbColor: Colors.white,
inactiveTrackColor: const Color(0xFF9B9B9B),
value: videoOrientation.defaultViewMode,
onChanged: ((value) {
setState(() {
videoOrientation.defaultViewMode = value;
});
}),
)),
ListTile(
leading: const Icon(Icons.forward_10),
title: const Text('Seek second'),
Expand Down
Loading