尝试使用 Vimeo url、video_player 和chewie 播放器获取视频时,出现错误
Exception has occurred.
PlatformException (PlatformException(VideoError, Video player had error com.google.android.exoplayer2.ExoPlaybackException: com.google.android.exoplayer2.upstream.HttpDataSource$InvalidResponseCodeException: Response code: 403, null))
如何打印网站上图片中显示的图像而不是这里的错误?
VideoPlayerController _videoPlayerController;
ChewieController _chewieController;
double _aspectRatio = 16 / 9;
TabController _tabController;
void _handleTabSelection() {
setState(() {});
}
@override
void initState() {
super.initState();
_tabController = new TabController(vsync: this, length: 2);
_tabController.addListener(_handleTabSelection);
_videoPlayerController =
VideoPlayerController.network('myvideourl');
_chewieController = ChewieController(
allowedScreenSleep: false,
allowFullScreen: true,
deviceOrientationsAfterFullScreen: [
DeviceOrientation.landscapeRight,
DeviceOrientation.landscapeLeft,
DeviceOrientation.portraitUp,
DeviceOrientation.portraitDown,
],
videoPlayerController: _videoPlayerController,
aspectRatio: _aspectRatio,
autoInitialize: true,
autoPlay: true,
showControls: true,
errorBuilder: (context, errorMessage) {
return Center(
child: Text(
errorMessage,
style: TextStyle(color: Colors.white),
),
);
});
_chewieController.addListener(() {
if (_chewieController.isFullScreen) {
SystemChrome.setPreferredOrientations([
DeviceOrientation.landscapeRight,
DeviceOrientation.landscapeLeft,
]);
} else {
SystemChrome.setPreferredOrientations([
DeviceOrientation.portraitUp,
DeviceOrientation.portraitDown,
]);
}
});
}
@override
void dispose() {
_videoPlayerController.dispose();
_chewieController.dispose();
SystemChrome.setPreferredOrientations([
DeviceOrientation.landscapeRight,
DeviceOrientation.landscapeLeft,
DeviceOrientation.portraitUp,
DeviceOrientation.portraitDown,
]);
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: const Color(0xff4fc1e9),
appBar: AppBar(
backgroundColor: Color(0xff3bafda),
shadowColor: Color(0xff4a89dc),
leading: IconButton(
icon: Icon(Icons.menu),
iconSize: 30.0,
color: Colors.white,
onPressed: () {} //=> _scaffoldKey.currentState.openDrawer(),
),
title: Image.asset(
"assets/images/firm-logo.png",
fit: BoxFit.contain,
height: 32,
),
centerTitle: true,
elevation: 5,
),
body: Column(
children: [
Stack(
children: <Widget>[
Container(
height: MediaQuery.of(context).size.width -
MediaQuery.of(context).size.width / 3.5,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(30.0),
boxShadow: [
BoxShadow(
color: Colors.black26,
offset: Offset(0.0, 2.0),
blurRadius: 6.0),
],
),
child: ClipRRect(
child: Container(
color: Colors.black,
child: Center(
child: Chewie(
controller: _chewieController,
),
),
),
),
),
],
),
我如何在颤振应用程序上捕获此错误