ERM Channel Audio playback implemented

merge-requests/3/head
haroon amjad 2 years ago
parent c1d89ae5e7
commit 1ebcbd1079

File diff suppressed because one or more lines are too long

@ -9,4 +9,5 @@ class MyLottieConsts {
static const String congratsGif = "assets/images/congrats.gif";
static const String loadingLottie = "assets/lottie/loading_lottie.json";
static const String noWinnerLottie = "assets/lottie/no_winner.json";
static const String audioPlaybackLottie = "assets/lottie/audio_playback.json";
}

@ -0,0 +1,21 @@
import 'package:flutter/foundation.dart';
import 'package:just_audio/just_audio.dart';
class MyCustomStream extends StreamAudioSource {
final Uint8List bytes;
MyCustomStream(this.bytes);
@override
Future<StreamAudioResponse> request([int? start, int? end]) async {
start ??= 0;
end ??= bytes.length;
return StreamAudioResponse(
sourceLength: bytes.length,
contentLength: end - start,
offset: start,
stream: Stream.value(bytes.sublist(start, end)),
contentType: 'audio/aac',
);
}
}

@ -69,7 +69,7 @@ class AppNotifications {
if (Platform.isAndroid) {
// await hmsApiAvailability.isHMSAvailable().then((value) async {
if (await Utils.isAppInstalledFromHuawei()) {
if (!(await Utils.isGoogleServicesAvailable())) {
huawei_push.Push.enableLogger();
var result = await huawei_push.Push.setAutoInitEnabled(true);

@ -394,20 +394,6 @@ class Utils {
}
//HUAWEI DECISION MAKING
static Future<bool> isAppInstalledFromHuawei() async {
Source installationSource = await StoreChecker.getSource;
if (installationSource == Source.IS_INSTALLED_FROM_HUAWEI_APP_GALLERY) {
return true;
}
return false;
}
static Future<String> getInstallationSource() async {
Source installationSource = await StoreChecker.getSource;
return installationSource.toString().split(".")[1];
}
static Future<bool> isGoogleServicesAvailable() async {
GooglePlayServicesAvailability availability = await GoogleApiAvailability.instance.checkGooglePlayServicesAvailability();
String status = availability.toString().split('.').last;

@ -8,6 +8,7 @@ import 'package:just_audio/just_audio.dart';
import 'package:mohem_flutter_app/api/chat/chat_api_client.dart';
import 'package:mohem_flutter_app/app_state/app_state.dart';
import 'package:mohem_flutter_app/classes/colors.dart';
import 'package:mohem_flutter_app/classes/my_custom_stream.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';
@ -429,7 +430,7 @@ class ChatBubble extends StatelessWidget {
Widget getPlayer({required AudioPlayer player, required SingleUserChatModel modelData}) {
return StreamBuilder<PlayerState>(
stream: player!.playerStateStream,
stream: player.playerStateStream,
builder: (BuildContext context, AsyncSnapshot<PlayerState> snapshot) {
PlayerState? playerState = snapshot.data;
ProcessingState? processingState = playerState?.processingState;
@ -442,7 +443,7 @@ class ChatBubble extends StatelessWidget {
child: const CircularProgressIndicator(),
);
} else if (playing != true) {
return Icon(
return const Icon(
Icons.play_arrow,
size: 30,
color: MyColors.lightGreenColor,
@ -470,22 +471,3 @@ class ChatBubble extends StatelessWidget {
);
}
}
class MyCustomStream extends StreamAudioSource {
final Uint8List bytes;
MyCustomStream(this.bytes);
@override
Future<StreamAudioResponse> request([int? start, int? end]) async {
start ??= 0;
end ??= bytes.length;
return StreamAudioResponse(
sourceLength: bytes.length,
contentLength: end - start,
offset: start,
stream: Stream.value(bytes.sublist(start, end)),
contentType: 'audio/aac',
);
}
}

@ -244,25 +244,7 @@ class _DashboardScreenState extends State<DashboardScreen> with WidgetsBindingOb
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
LocaleKeys.welcomeBack.tr().toText14(color: MyColors.grey77Color),
(AppState().memberInformationList!.eMPLOYEENAME ?? "").toText24(isBold: true).onPress(() async {
return showMDialog(
context,
backgroundColor: Colors.transparent,
isDismissable: true,
child: SizedBox(
width: MediaQuery.of(context).size.width / 2.2,
height: MediaQuery.of(context).size.width / 2.2,
child: Card(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(25.0),
),
child: Center(
child: "This app is installed from ${await Utils.getInstallationSource()}".toText16(isCentered: true),
),
),
),
);
}),
(AppState().memberInformationList!.eMPLOYEENAME ?? "").toText24(isBold: true),
16.height,
Row(
children: [

@ -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)
],
),
);

@ -102,8 +102,6 @@ class _LoginScreenState extends State<LoginScreen> {
Utils.showLoading(context);
if (Platform.isAndroid) {
try {
// await hmsApiAvailability.isHMSAvailable().then((value) async {
// if (await Utils.isAppInstalledFromHuawei() && !(await Utils.isGoogleServicesAvailable())) {
if (!(await Utils.isGoogleServicesAvailable())) {
print("HUAWEI APPPP GALLERYYYY!!!!");
AppState().setIsHuawei = true;

Loading…
Cancel
Save