Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

does flutter support rstp/rtmp video player?

Tags:

video

flutter

I found flutter video_player based on AVPlayer in IOS, which does not support rtsp url. Can anyone help me know how to play a video with format like 'rstp/rtmp' in flutter? 🤔

like image 727
kemdo Avatar asked May 30 '18 19:05

kemdo


1 Answers

Flutter Vlc player package can handle rtsp streams.

flutter_vlc_player

This is the example from the readme section, change value of "urlToStreamVideo" for your source address to test it.

import 'package:flutter/material.dart';
import 'package:flutter_vlc_player/flutter_vlc_player.dart';

class ExampleVideo extends StatefulWidget {
  @override
  _ExampleVideoState createState() => _ExampleVideoState();
}

class _ExampleVideoState extends State<ExampleVideo> {
  final String urlToStreamVideo = 'http://distribution.bbb3d.renderfarming.net/video/mp4/bbb_sunflower_1080p_60fps_normal.mp4';
  final VlcPlayerController controller = new VlcPlayerController(
      // Start playing as soon as the video is loaded.
      onInit: (){
          controller.play();
      }  
  );
  final int playerWidth = 640;
  final int playerHeight = 360;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        body: SizedBox(
            height: playerHeight,
            width: playerWidth,
            child: new VlcPlayer(
                aspectRatio: 16 / 9,
                url: urlToStreamVideo,
                controller: controller,
                placeholder: Center(child: CircularProgressIndicator()),
            )
        )
    );
  }
}
like image 101
velsorange Avatar answered Sep 21 '22 19:09

velsorange