1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[Flutter] image_picker + video_player are displays video with incorrect angle and stretched...

Discussão em 'Mobile' iniciado por Stack, Outubro 10, 2024 às 15:32.

  1. Stack

    Stack Membro Participativo

    In Flutter application I try to pick videos and display it. My videos displays. But they have incorrect rotation. If my videos was recorder in vertical mode video displays in container for vertical video but video is rotated and displayed as if vertically and stretched in width. (vertical size became horizontal and vise versa so my video wider than it should be, but shorter by his height)

    Future<void> _pickVideo() async {
    final XFile? video = await _picker.pickVideo(source: ImageSource.gallery);

    if (video != null){
    _videoFile = File(video!.path);
    _videoController = VideoPlayerController.file(_videoFile!)..initialize().then((_) {
    setState(() {

    });
    _videoController?.play();
    });
    }


    }

    @override
    Widget build(BuildContext context) {
    child: Column(
    crossAxisAlignment: CrossAxisAlignment.stretch,
    children: [
    ElevatedButton(
    onPressed: _pickVideo,
    child: const Text('Choose Video'),
    ),
    const SizedBox(height: 20),
    if (_videoFile != null)
    _videoController!.value.isInitialized ? AspectRatio(
    aspectRatio: _videoController!.value.aspectRatio,
    child: VideoPlayer(_videoController!),
    ) : Container()
    else
    const Text("Click on pick video to selecte video"),


    ...

    I tried to rotate

    child: Transform.rotate(
    angle: 3.14159 / 2,
    child: VideoPlayer(_videoController!),
    ),


    but it rotate horizontal mode too(that's not good) and for vertical it rotate it but image became square. and other place under and above occupies a blank background

    Continue reading...

Compartilhe esta Página