|
|
|
@ -5,8 +5,10 @@ import 'dart:typed_data';
|
|
|
|
|
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:flutter_countdown_timer/index.dart';
|
|
|
|
|
import 'package:lottie/lottie.dart';
|
|
|
|
|
import 'package:mohem_flutter_app/api/dashboard_api_client.dart';
|
|
|
|
|
import 'package:mohem_flutter_app/classes/colors.dart';
|
|
|
|
|
import 'package:mohem_flutter_app/classes/lottie_consts.dart';
|
|
|
|
|
import 'package:mohem_flutter_app/classes/utils.dart';
|
|
|
|
|
import 'package:mohem_flutter_app/extensions/int_extensions.dart';
|
|
|
|
|
import 'package:mohem_flutter_app/extensions/string_extensions.dart';
|
|
|
|
@ -29,6 +31,7 @@ class _ITGAdsScreenState extends State<ITGAdsScreen> {
|
|
|
|
|
bool skip = false;
|
|
|
|
|
bool isVideo = false;
|
|
|
|
|
bool isImage = false;
|
|
|
|
|
bool isAudio = false;
|
|
|
|
|
String ext = '';
|
|
|
|
|
late File imageFile;
|
|
|
|
|
ads.Advertisement? advertisementData;
|
|
|
|
@ -44,11 +47,13 @@ class _ITGAdsScreenState extends State<ITGAdsScreen> {
|
|
|
|
|
await processImage(rFile!);
|
|
|
|
|
isImage = true;
|
|
|
|
|
} else {
|
|
|
|
|
if (ext == ".aac") {
|
|
|
|
|
isAudio = true;
|
|
|
|
|
}
|
|
|
|
|
isVideo = true;
|
|
|
|
|
_futureController = createVideoPlayer(rFile!);
|
|
|
|
|
}
|
|
|
|
|
setState(() {});
|
|
|
|
|
// initTimer();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future processImage(String encodedBytes) async {
|
|
|
|
@ -89,18 +94,19 @@ class _ITGAdsScreenState extends State<ITGAdsScreen> {
|
|
|
|
|
@override
|
|
|
|
|
void dispose() {
|
|
|
|
|
_controller.dispose();
|
|
|
|
|
// player.stop();
|
|
|
|
|
// player.dispose();
|
|
|
|
|
super.dispose();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
data = ModalRoute.of(context)!.settings.arguments;
|
|
|
|
|
if (advertisementData == null) advertisementData = data["advertisement"] as ads.Advertisement;
|
|
|
|
|
if (masterID == null) masterID = data["masterId"];
|
|
|
|
|
advertisementData ??= data["advertisement"] as ads.Advertisement;
|
|
|
|
|
masterID ??= data["masterId"];
|
|
|
|
|
if (advertisementData != null) {
|
|
|
|
|
checkFileType();
|
|
|
|
|
videoDuration = advertisementData?.durationInSeconds ?? 0;
|
|
|
|
|
print("VIDEO DURATION: $videoDuration");
|
|
|
|
|
}
|
|
|
|
|
return Scaffold(
|
|
|
|
|
backgroundColor: Colors.black,
|
|
|
|
@ -116,10 +122,12 @@ class _ITGAdsScreenState extends State<ITGAdsScreen> {
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
|
children: [
|
|
|
|
|
Center(
|
|
|
|
|
child: AspectRatio(
|
|
|
|
|
aspectRatio: _controller.value.aspectRatio,
|
|
|
|
|
child: VideoPlayer(_controller),
|
|
|
|
|
),
|
|
|
|
|
child: isAudio
|
|
|
|
|
? Lottie.asset(MyLottieConsts.audioPlaybackLottie)
|
|
|
|
|
: AspectRatio(
|
|
|
|
|
aspectRatio: _controller.value.aspectRatio,
|
|
|
|
|
child: VideoPlayer(_controller),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
30.height,
|
|
|
|
|
CountdownTimer(
|
|
|
|
@ -165,7 +173,6 @@ class _ITGAdsScreenState extends State<ITGAdsScreen> {
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
if (isImage) Image.file(imageFile),
|
|
|
|
|
// if (skip)
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|