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

Video is Playing but sound is not coming and there is a no method for implementing video controlors #14

Open
KasunHasanga opened this issue Oct 9, 2020 · 0 comments

Comments

@KasunHasanga
Copy link

Screenshot_1602286457
`import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter/widgets.dart';
import 'package:ext_video_player/ext_video_player.dart';

class FirstAidVideo extends StatefulWidget {
@OverRide
_FirstAidVideoState createState() => _FirstAidVideoState();
}

class _FirstAidVideoState extends State {

VideoPlayerController _controller;

void initState() {
super.initState();
controller = VideoPlayerController.network(
'https://www.youtube.com/watch?v=2vpB9IwbjdA')
..initialize().then((
) {
// Ensure the first frame is shown after the video is initialized, even before the play button has been pressed.
setState(() {});
});
}
void dispose() {
super.dispose();
_controller.dispose();
}

@OverRide
Widget build(BuildContext context) {

return MaterialApp(
  title: 'Video Demo',
  home: Scaffold(
    body: SingleChildScrollView(
      child: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        children: <Widget>[
          Text('Motivational Video'),
          Container(
            child: _controller.value.initialized
                ? AspectRatio(
              aspectRatio: _controller.value.aspectRatio,
              child: VideoPlayer(_controller),
            )
                : Container(),
          ),
        ],
      ),
    ),
    floatingActionButton: FloatingActionButton(
      onPressed: () {
        setState(() {
          _controller.value.isPlaying
              ? _controller.pause()
              : _controller.play();
        });
      },
      child: Icon(
        _controller.value.isPlaying ? Icons.pause : Icons.play_arrow,
      ),
    ),
  ),
);

`

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

1 participant