我如何在颤振中播放 rtsp 视频流?

问题描述

这是我正在尝试使用 Flutter vlc player代码,但它不起作用,所以任何人都可以帮助我解决问题,或者我可以用另一种方式显示流?

所以你们可以给我任何建议或举任何小例子。我试图从过去两个小时开始解决这个问题,但它没有解决

import 'package:Flutter/material.dart';
import 'package:Flutter_vlc_player/Flutter_vlc_player.dart';
import 'package:Flutter_vlc_player/vlc_player.dart';
import 'package:Flutter_vlc_player/vlc_player_controller.dart';
void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',theme: ThemeData(
        visualDensity: VisualDensity.adaptivePlatformDensity,),home: MyHomePage(),);
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key}) : super(key: key);

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  VlcPlayerController _videoPlayerController;

  @override
  void initState() {
    super.initState();

    _videoPlayerController = VlcPlayerController.network(
      'rtsp://viewer:aeDoPhiucees3gohshie@173.249.14.110:27954/axis-media/media.amp?videocodec=h264&fps=15&audio=1&resolution=640x480',hwAcc: HwAcc.FULL,autoplay: false,options: VlcPlayerOptions(),);
  }

  @override
  void dispose() async {
    super.dispose();
    await _videoPlayerController.stopRendererScanning();
    await _videoPlayerController.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(),body: Center(
        child: VlcPlayer(
          controller: _videoPlayerController,aspectRatio: 16 / 9,placeholder: Center(child: CircularProgressIndicator()),);
  }
}

解决方法

查看这个库:https://pub.dev/packages/flutter_playout。它确实支持 HLS。

,

这是一个对我有用的小例子。我认为问题是在较新版本中必须立即初始化控制器。

我对这段代码的唯一问题是高级选项不起作用。不幸的是,很难找到一些好的信息

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

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',theme: ThemeData(
        primarySwatch: Colors.blue,),home: MyHomePage(title: 'Flutter Demo Home Page'),);
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key? key,required this.title}) : super(key: key);

  final String title;

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  VlcPlayerController _vlcViewController = new VlcPlayerController.network(
    "rtsp://192.72.1.1/liveRTSP/av4",autoPlay: true,);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,children: <Widget>[
            new VlcPlayer(
              controller: _vlcViewController,aspectRatio: 16 / 9,placeholder: Text("Hello World"),],);
  }
}