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

[ BUG ] appinio_video_player: Control icons(play, pause, etc) doesn't load. #314

Open
waged opened this issue Sep 20, 2024 · 0 comments
Open
Assignees

Comments

@waged
Copy link

waged commented Sep 20, 2024

appinio_video_player

I have applied the library to my flutter web project and works perfectly fine except one thing unfortunately the play/pause icons doesn't show and appears as missing asset with small box.

Screenshot 2024-09-21 at 00 55 00

and here is the code snippet:


class ProductDetail extends ConsumerWidget {
  ProductDetail({super.key});

  final customVideoStateProvider =
      StateProvider.autoDispose<CustomVideoPlayerController?>((ref) {
    return null;
  });

  @override
  Widget build(BuildContext context, WidgetRef ref) {

    // Video control
    final customVideoProvider = ref.watch(customVideoStateProvider);


    return Scaffold(
      appBar: AppBar(
        title: Text(product.name),
        leading: const BackButton(color: Colors.white),
      ),
      body: SingleChildScrollView(
        padding: const EdgeInsets.all(16.0),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            Stack(
              alignment: Alignment.center,
              children: [
                if (customVideoProvider != null)
                  CustomVideoPlayer(
                    customVideoPlayerController: customVideoProvider,
                  )
                else
                  Stack(alignment: Alignment.center, children: [
                    InkWell(
                      onTap: () async {
                        await _initializeVideo(ref,
                            'XXXXXXXXXX.mp4');
                      },
                      child: ClipRRect(
                        borderRadius: BorderRadius.circular(16.0),
                        child: Image.network(
                          "XXXXXX.png",
                          fit: BoxFit.cover,
                          errorBuilder: (BuildContext context, Object error,
                              StackTrace? stackTrace) {
                            return Container(
                              color: Colors.grey,
                              child: const Center(
                                child: Icon(Icons.error,
                                    color: Colors.red, size: 50),
                              ),
                            );
                          },
                        ),
                      ),
                    ),
                    IconButton(
                        iconSize: 72,
                        color: Colors.grey[500],
                        onPressed: () async {
                          await _initializeVideo(ref,
                              'XXXXXXXXX.mp4');
                        },
                        icon: const Icon(Icons.play_arrow))
                  ]),
              ],
            ),
            const SizedBox(height: 166),
          ],
        ),
      ),
    );
  }

  // Method to initialize video
  Future<void> _initializeVideo(WidgetRef ref, String url) async {
    final videoController = VideoPlayerController.networkUrl(Uri.parse(url));
    await videoController.initialize();
    await videoController.play();
    ref.read(customVideoStateProvider.notifier).state =
        CustomVideoPlayerController(
            context: ref.context, videoPlayerController: videoController);
  }
}

void main() {
  runApp(ProviderScope(child: MyApp()));
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      title: 'Product Details',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: ProductDetail(),
    );
  }
}


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

2 participants