product recommendations api integration, content bytes

This commit is contained in:
jayesh
2024-05-08 17:15:26 +05:30
parent a2796be19c
commit 8d526c7b65
15 changed files with 435 additions and 132 deletions

View File

@@ -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;
// }
// }
}