Open SarthakGupta2912 opened 4 months ago
`import 'package:flutter/material.dart'; import 'package:carousel_slider/carousel_slider.dart'; import 'package:pod_player/pod_player.dart';
class MicroLearningPage extends StatefulWidget { const MicroLearningPage({super.key});
@override _MicroLearningPageState createState() => _MicroLearningPageState(); }
class _MicroLearningPageState extends State
final List
List
final List
late List<List
@override void initState() { super.initState();
controller = List.generate(totalSections, (_) => []);
buttonCarouselControllers =
List.generate(totalSections, (index) => CarouselController());
for (int i = 0; i < totalVideoUrlLists.length; i++) {
addPodPlayerController(totalVideoUrlLists[i]);
}
videoTitles.add(mostViewedVideoTitles);
videoTitles.add(mostPopularVideoTitles);
debugPrint('MicroLearningPage initialized!');
}
void addPodPlayerController(List
void disposeControllers() { for (int i = 0; i < controller.length; i++) { for (int j = 0; j < controller[i].length; j++) { controller[i][j].dispose(); } } }
@override void dispose() { super.dispose(); disposeControllers(); debugPrint('Disposed()'); }
@override Widget build(BuildContext context) { double screenWidth = MediaQuery.of(context).size.width; double screenHeight = MediaQuery.of(context).size.height; return Scaffold( appBar: AppBar( backgroundColor: Colors.green.withOpacity(0.2), title: const Text('Micro Learning'), ), body: Column( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ Expanded( child: ListView.builder( itemCount: totalSections, itemBuilder: (BuildContext context, int index) { return Column( children: [ SizedBox(height: screenHeight 0.02), Row( children: [ SizedBox(width: screenWidth 0.04), Text( sectionTitle[index], style: const TextStyle( fontWeight: FontWeight.bold, fontSize: 18, ), ), ], ), SizedBox(height: screenHeight 0.02), Column( children: [ Row( children: [ Column( children: [ IconButton( icon: const Icon( Icons.arrow_back_ios_new_rounded, color: Colors.black, ), onPressed: () { buttonCarouselControllers[index] .previousPage(); }, ), SizedBox(height: screenHeight 0.04), ], ), Expanded( child: CarouselSlider.builder( carouselController: buttonCarouselControllers[index], itemCount: totalVideoUrlLists[index].length, itemBuilder: (BuildContext context, int itemIndex, int pageViewIndex) { return Column( children: [ SizedBox( width: screenWidth 0.65, child: PodVideoPlayer( controller: controller[index][itemIndex], ), ), ], ); }, options: CarouselOptions( initialPage: 1, viewportFraction: 0.85, enableInfiniteScroll: false, enlargeCenterPage: true, ), ), ), Column( children: [ IconButton( icon: const Icon( Icons.arrow_forward_ios_rounded, color: Colors.black, ), onPressed: () { buttonCarouselControllers[index].nextPage(); }, ), SizedBox(height: screenHeight 0.04), ], ), ], ), ], ), ], ); }, ), ), ], ), ); } } `
Please Refer these example: https://github.com/newtaDev/pod_player/blob/master/example/lib/examples/play_list_of_videos.dart
I did but still not working in the build. However, The problem is only occurring in the build apk.
Same on my side. Also examples not working correctly. On debug mode all videos are ok. On release mode, loading same movie to all containers. Checked that on release mode controller initialized with the same url.
Flutter (Channel stable, 3.22.1, on macOS 14.4.1 23E224 darwin-arm64)
@newtaDev
One information that can be helpful.
After downgrade flutter to 3.19.5, everything works ok. So this is something related with newest Flutter version.
Hi, the PodPlayerController
uses UniqueKey().toString()
to generate a tag for the internal PodGetXController
. However, in Flutter 3.22, there is an issue that UniqueKey always returns "Instance of UniqueKey" in release mode. No matter how many PodPlayerController are created, they still share the same PodGetXController
instance.
I created PR that replaces UniqueKey
with UUID
for safer tag generation. Hope this will get merged soon!
When i test my app in the debug mode or using cable then it works fine but after i test the build-release apk then it creates problem. So the problem is that i am trying to play many youtube videos as i have a list of videos. They play very well during debug mode but when i build the app and then test then only the last instance i created is assigned to every video and they play and pause all together.
The below is my code.