Нет параметров defaultHeight
и defaultWidth
для VlcPlayer . Что вы можете сделать, так это поместить этот виджет в SizedBox, чтобы отрегулировать ширину и высоту:
new SizedBox(
height: 480,
width: 640,
child: new VlcPlayer(
controller: _vlcPlayerController,
aspectRatio: 4 / 3,
url: _streamUrl,
placeholder: Container(),
),
)
Я не уверен, какое программное обеспечение или сервис вы используете для Raspberry Pi. В соответствии с этим вам необходимо ввести URL-адрес потока внутри приложения. Убедитесь, что ваш Raspberry Pi и смартфон находятся в одной сети.
Я предполагаю, что вы использовали это видео для написания этого кода. В нем также объясняется, что вам необходимо использовать Motion на стороне Raspberry Pi.
Удачи!
Редактировать : Ниже мой код, чтобы вы могли его попробовать;
import 'package:flutter/material.dart';
import 'package:flutter_vlc_player/flutter_vlc_player.dart';
class LiveStream extends StatefulWidget {
@override
_LiveStreamState createState() => _LiveStreamState();
}
class _LiveStreamState extends State<LiveStream> {
VlcPlayerController _liveController;
final String _url = "YOUR_STREAM_URL";
@override
void initState() {
_liveController = new VlcPlayerController(
onInit: () {}
);
super.initState();
}
@override
Widget build(BuildContext context) {
return WillPopScope(
onWillPop: _back,
child: Scaffold(
appBar: AppBar(
backgroundColor: Colors.red,
title: Text("Live View"),
centerTitle: true,
leading: IconButton(
icon: Icon(Icons.arrow_back),
onPressed: _back,
),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Container(
decoration: BoxDecoration(
border: Border.all(
color: Colors.black,
style: BorderStyle.solid,
),
borderRadius: BorderRadiuscircular(2),
),
child: SizedBox(
width: 400,
height: 300,
child: new VlcPlayer(
url: _url,
controller: _liveController,
aspectRatio: 4 / 3,
placeholder: Container(
height: 250,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[CircularProgressIndicator(valueColor: AlwaysStoppedAnimation<Color>(Colors.red),),],
)
),
),
),
),
RaisedButton.icon(
onPressed: _play,
icon: Icon(Icons.play_circle_outline),
label: Text("Click to watch", style: TextStyle(fontSize: 22),)),
],
),
),
)
);
}
Future<bool> _back() async {
if (_liveController.initialized) {
print("Disposing...");
_liveController.dispose(); // to ensure disposing of the liveController to free up resources
}
Navigator.pop(context);
}
void _play() {
print(_liveController.initialized);
if (_liveController.initialized) {
_liveController.play();
}
}
}