1

我正在尝试使用颤振中的 video_player 依赖项从网络播放 mp4 视频(仅在 android 上运行我的应用程序),视频不播放并且应用程序在几秒钟后崩溃。我正在尝试在 API 19 max 上运行该应用程序。

这是我的代码:

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

void main() => runApp(VideoApp());

class VideoApp extends StatefulWidget {
  @override
  _VideoAppState createState() => _VideoAppState();
}

class _VideoAppState extends State<VideoApp> {
  VideoPlayerController _controller;

  @override
  void initState() {
    super.initState();
    _controller = VideoPlayerController.network(
        'https://flutter.github.io/assets-for-api-docs/assets/videos/bee.mp4')
      ..initialize().then((_) {
        // Ensure the first frame is shown after the video is initialized, even before the play button has been pressed.
        setState(() {});
      });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Video Demo',
      home: Scaffold(
        body: Center(
          child: _controller.value.initialized
              ? AspectRatio(
                  aspectRatio: _controller.value.aspectRatio,
                  child: VideoPlayer(_controller),
                )
              : Container(),
        ),
        floatingActionButton: FloatingActionButton(
          onPressed: () {
            setState(() {
              _controller.value.isPlaying
                  ? _controller.pause()
                  : _controller.play();
            });
          },
          child: Icon(
            _controller.value.isPlaying ? Icons.pause : Icons.play_arrow,
          ),
        ),
      ),
    );
  }

  @override
  void dispose() {
    super.dispose();
    _controller.dispose();
  }
}

这是输出:

D/        ( 4654): HostConnection::get() New Host Connection established 0xb7b11d20, tid 4669
D/dalvikvm( 4654): GC_CONCURRENT freed 231K, 8% free 3676K/3980K, paused 1ms+1ms, total 4ms
E/ExoPlayerImplInternal( 4654): Source error.
E/ExoPlayerImplInternal( 4654): com.google.android.exoplayer2.upstream.HttpDataSource$HttpDataSourceException: Unable to connect to https://flutter.github.io/assets-for-api-docs/assets/videos/bee.mp4
E/ExoPlayerImplInternal( 4654):         at com.google.android.exoplayer2.upstream.DefaultHttpDataSource.open(DefaultHttpDataSource.java:281)
E/ExoPlayerImplInternal( 4654):         at com.google.android.exoplayer2.upstream.StatsDataSource.open(StatsDataSource.java:83)    
E/ExoPlayerImplInternal( 4654):         at com.google.android.exoplayer2.source.ExtractorMediaPeriod$ExtractingLoadable.load(ExtractorMediaPeriod.java:885)
E/ExoPlayerImplInternal( 4654):         at com.google.android.exoplayer2.upstream.Loader$LoadTask.run(Loader.java:381)
E/ExoPlayerImplInternal( 4654):         at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
E/ExoPlayerImplInternal( 4654):         at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
E/ExoPlayerImplInternal( 4654):         at java.lang.Thread.run(Thread.java:841)
E/ExoPlayerImplInternal( 4654): Caused by: javax.net.ssl.SSLHandshakeException: javax.net.ssl.SSLProtocolException: SSL handshake aborted: ssl=0xb7b30750: Failure in SSL library, usually a protocol error
E/ExoPlayerImplInternal( 4654): error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure (external/openssl/ssl/s23_clnt.c:741 0x8d995990:0x00000000)
E/ExoPlayerImplInternal( 4654):         at com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:448)  
E/ExoPlayerImplInternal( 4654):         at com.android.okhttp.Connection.upgradeToTls(Connection.java:146)
E/ExoPlayerImplInternal( 4654):         at com.android.okhttp.Connection.connect(Connection.java:107)
E/ExoPlayerImplInternal( 4654):         at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:294)
E/ExoPlayerImplInternal( 4654):         at com.android.okhttp.internal.http.HttpEngine.sendSocketRequest(HttpEngine.java:255)      
E/ExoPlayerImplInternal( 4654):         at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:206)
E/ExoPlayerImplInternal( 4654):         at com.android.okhttp.internal.http.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:345)
E/ExoPlayerImplInternal( 4654):         at com.android.okhttp.internal.http.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:89)
E/ExoPlayerImplInternal( 4654):         at com.android.okhttp.internal.http.HttpsURLConnectionImpl.connect(HttpsURLConnectionImpl.java:161)
E/ExoPlayerImplInternal( 4654):         at com.google.android.exoplayer2.upstream.DefaultHttpDataSource.makeConnection(DefaultHttpDataSource.java:528)
E/ExoPlayerImplInternal( 4654):         at com.google.android.exoplayer2.upstream.DefaultHttpDataSource.makeConnection(DefaultHttpDataSource.java:444)
E/ExoPlayerImplInternal( 4654):         at com.google.android.exoplayer2.upstream.DefaultHttpDataSource.open(DefaultHttpDataSource.java:279)
E/ExoPlayerImplInternal( 4654):         ... 6 more
E/ExoPlayerImplInternal( 4654): Caused by: javax.net.ssl.SSLProtocolException: SSL handshake aborted: ssl=0xb7b30750: Failure in SSL library, usually a protocol error
E/ExoPlayerImplInternal( 4654): error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure (external/openssl/ssl/s23_clnt.c:741 0x8d995990:0x00000000)
E/ExoPlayerImplInternal( 4654):         at com.android.org.conscrypt.NativeCrypto.SSL_do_handshake(Native Method)
E/ExoPlayerImplInternal( 4654):         at com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:405)  
E/ExoPlayerImplInternal( 4654):         ... 17 more
E/flutter ( 4654): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: PlatformException(VideoError, Video player had error com.google.android.exoplayer2.ExoPlaybackException: com.google.android.exoplayer2.upstream.HttpDataSource$HttpDataSourceException: Unable to connect to https://flutter.github.io/assets-for-api-docs/assets/videos/bee.mp4, null)
E/flutter ( 4654):
E/flutter ( 5040): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: PlatformException(VideoError, Video player had error com.google.android.exoplayer2.ExoPlaybackException: com.google.android.exoplayer2.upstream.HttpDataSource$HttpDataSourceException: Unable to connect to http://flutter.github.io/assets-for-api-docs/assets/videos/bee.mp4, null)
E/flutter ( 5040):
E/flutter ( 5097): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: PlatformException(VideoError, Video player had error com.google.android.exoplayer2.ExoPlaybackException: com.google.android.exoplayer2.upstream.HttpDataSource$HttpDataSourceException: Unable to connect to http://flutter.github.io/assets-for-api-docs/assets/videos/bee.mp4, null)
E/flutter ( 5097):
E/flutter ( 5176): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: PlatformException(VideoError, Video player had error com.google.android.exoplayer2.ExoPlaybackException: com.google.android.exoplayer2.upstream.HttpDataSource$HttpDataSourceException: Unable to connect to http://flutter.github.io/assets-for-api-docs/assets/videos/bee.mp4, null)
E/flutter ( 5176):
E/flutter ( 5268): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: PlatformException(VideoError, Video player had error com.google.android.exoplayer2.ExoPlaybackException: com.google.android.exoplayer2.upstream.HttpDataSource$HttpDataSourceException: Unable to connect to http://flutter.github.io/assets-for-api-docs/assets/videos/bee.mp4, null)
4

0 回答 0