Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem after build #208

Open
SarthakGupta2912 opened this issue Jun 2, 2024 · 6 comments
Open

Problem after build #208

SarthakGupta2912 opened this issue Jun 2, 2024 · 6 comments

Comments

@SarthakGupta2912
Copy link

SarthakGupta2912 commented Jun 2, 2024

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.

@SarthakGupta2912
Copy link
Author

`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 {
List buttonCarouselControllers = [];
late List<List> controller = [];

final List sectionTitle = [
'Most Viewed',
'Most Popular',
];

List mostViewedVideoTitles = ['Title1', 'Title2', 'Title3'];
List mostPopularVideoTitles = [
'Title4',
'Title5',
'Title6',
'Title7'
];
final List<List> videoTitles = [];
final List videoUrls = [
'https://www.youtube.com/watch?v=C3aRyxcpy5A',
'https://www.youtube.com/watch?v=UtbwuxoEYt0',
'https://www.youtube.com/watch?v=A3ltMaM6noM',
];

final List videoUrls2 = [
'https://www.youtube.com/watch?v=gu-z9EbIZ5k',
'https://www.youtube.com/watch?v=ajvXxR1Di54',
'https://www.youtube.com/watch?v=yMNMb1JNqIs',
'https://www.youtube.com/watch?v=UtbwuxoEYt0',
];

late List<List> totalVideoUrlLists = [
videoUrls,
videoUrls2,
];
int totalSections = 2, controllerIndex = 0;

@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 videoUrls) {
for (int i = 0; i < videoUrls.length; i++) {
controller[controllerIndex].add(PodPlayerController(
podPlayerConfig: const PodPlayerConfig(autoPlay: false),
playVideoFrom: PlayVideoFrom.youtube(videoUrls[i]),
)..initialise());
}
controllerIndex++;
}

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

@SarthakGupta2912
Copy link
Author

SarthakGupta2912 commented Jun 2, 2024

Please Refer these example: https://github.com/newtaDev/pod_player/blob/master/example/lib/examples/play_list_of_videos.dart

https://github.com/newtaDev/pod_player/blob/master/example/lib/examples/play_videos_list_dynamically.dart

I did but still not working in the build. However, The problem is only occurring in the build apk.

@ltlalka
Copy link

ltlalka commented Jun 7, 2024

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)

@ltlalka
Copy link

ltlalka commented Jun 7, 2024

@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.

@TinhHuynh
Copy link

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants