繁体   English   中英

我在使用 flutter_vlc_player 时遇到这些问题,这是为什么呢?

[英]I'm having these issues with flutter_vlc_player, why is that?

我正在测试 flutter 的依赖关系,并在尝试使用 ngrok 显示视频流时遇到这些问题,这些是我遇到的问题:

E/VLC     (15337): [00000071a614bc90/3c35] libvlc stream: HTTP connection failure
E/VLC     (15337): [00000071a614bc90/3c35] libvlc stream: connection failed: Network is unreachable
E/VLC     (15337): [00000071a614bc90/3c35] libvlc stream: cannot connect to ae872c2bd308.ngrok.io:80

这是我正在使用的代码:

import 'package:flutter/material.dart';
import 'package:flutter_vlc_player/flutter_vlc_player.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(
      'http://ae872c2bd308.ngrok.io/stream',
      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()),
        ),
      ),
    );
  }
}

知道可能是什么问题吗?

我使用 VLC 播放器测试了传输,并且可以使其工作。

autoPlay: true添加到 controller 使其变为

_videoPlayerController = VlcPlayerController.network(
  'http://ae872c2bd308.ngrok.io/stream',
  hwAcc: HwAcc.FULL,
  autoPlay: true,
  options: VlcPlayerOptions(),
);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM