product recommendations api integration, content bytes
This commit is contained in:
@@ -40,13 +40,14 @@ class ContentBytesController extends GetxController {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
void init(index) async {
|
||||
void init(index, type) async {
|
||||
audioPlayer = AudioPlayer();
|
||||
isAudioInitialize = true;
|
||||
indexForAudios.value = index;
|
||||
try {
|
||||
log(index.toString());
|
||||
await audioPlayer.setUrl(contentBytesModel.data!.audio![index].link!);
|
||||
await audioPlayer.setUrl(type == "new"
|
||||
? contentBytesModel.data!.newReleaseAudio![index].link!
|
||||
: contentBytesModel.data!.audio![index].link!);
|
||||
// await audioPlayer.setAsset(url);
|
||||
} on PlayerException catch (e) {
|
||||
print("Error code: ${e.code}");
|
||||
@@ -75,7 +76,7 @@ class ContentBytesController extends GetxController {
|
||||
} else if (processingState != ProcessingState.completed) {
|
||||
buttonNotifier.value = ButtonState.playing;
|
||||
} else {
|
||||
_playNextTrack();
|
||||
// _playNextTrack(type);
|
||||
|
||||
// audioPlayer.seek(Duration.zero);
|
||||
// audioPlayer.pause();
|
||||
@@ -110,7 +111,7 @@ class ContentBytesController extends GetxController {
|
||||
});
|
||||
}
|
||||
|
||||
void _playNextTrack() {
|
||||
void _playNextTrack(type) {
|
||||
// Determine the index of the next track (you need to implement this logic)
|
||||
int nextIndex = getNextTrackIndex();
|
||||
|
||||
@@ -120,7 +121,7 @@ class ContentBytesController extends GetxController {
|
||||
if (isPlaying()) {
|
||||
stop();
|
||||
}
|
||||
init(nextIndex);
|
||||
init(nextIndex, type);
|
||||
play(nextIndex);
|
||||
} else {
|
||||
audioPlayer.seek(Duration.zero);
|
||||
@@ -184,41 +185,4 @@ class ContentBytesController extends GetxController {
|
||||
titlePlayingList![index] = true;
|
||||
}
|
||||
}
|
||||
|
||||
// RxList<Video> searchResults = <Video>[].obs;
|
||||
|
||||
// Future<void> getContentBytesDataVideo(String query) async {
|
||||
// // Set isLoading to true if needed
|
||||
// isLoading.value = true;
|
||||
|
||||
// try {
|
||||
// // Make API call to fetch search results based on the query
|
||||
// final response = await ContentBytesApi().getContentBytesData({
|
||||
// // Pass query parameters if needed
|
||||
// 'search_data': query,
|
||||
// 'content_type': "video",
|
||||
// 'category_id': "",
|
||||
// });
|
||||
|
||||
// // Check if the API call was successful
|
||||
// if (response.status == ResponseStatus.SUCCESS) {
|
||||
// // Parse the response data into a list of videos
|
||||
// final List<dynamic> responseData = response.data['data']['video'];
|
||||
// searchResults.value =
|
||||
// responseData.map((data) => Video.fromJson(data)).toList();
|
||||
|
||||
// // Notify listeners about the changes to the searchResults list
|
||||
// update();
|
||||
// } else {
|
||||
// // Handle API call failure
|
||||
// // You may show an error message or handle it as needed
|
||||
// }
|
||||
// } catch (e) {
|
||||
// // Handle exceptions
|
||||
// // You may show an error message or handle it as needed
|
||||
// } finally {
|
||||
// // Set isLoading to false after the API call completes
|
||||
// isLoading.value = false;
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import 'package:device_info_plus/device_info_plus.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:permission_handler/permission_handler.dart';
|
||||
import 'package:traderscircuit/model/ProductsModel/call_recommendations_model.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
@@ -14,4 +16,15 @@ class ProductsController extends GetxController {
|
||||
DateTime newDateTime = DateTime(dateTime.year, 3, 25);
|
||||
return DateFormat("dd MMMM yyyy").format(newDateTime);
|
||||
}
|
||||
|
||||
static Future<bool> requestP() async {
|
||||
bool permissionStatus;
|
||||
final deviceInfo = await DeviceInfoPlugin().androidInfo;
|
||||
if (deviceInfo.version.sdkInt > 32) {
|
||||
permissionStatus = await Permission.photos.request().isGranted;
|
||||
} else {
|
||||
permissionStatus = await Permission.storage.request().isGranted;
|
||||
}
|
||||
return permissionStatus;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user