Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android平台 player设置不能播放的链接后release会导致anr #87

Closed
Smallsmallwindupknight opened this issue Jun 18, 2019 · 14 comments
Labels
android bug Something isn't working

Comments

@Smallsmallwindupknight
Copy link

你好,这是anr文件的截图
QQ图片20190618152119

@CaiJingLong CaiJingLong added android bug Something isn't working labels Jun 18, 2019
@CaiJingLong
Copy link
Owner

How about iOS?

@Smallsmallwindupknight
Copy link
Author

Smallsmallwindupknight commented Jun 18, 2019 via email

@CaiJingLong
Copy link
Owner

Thx for issue.
I will fix it in next version.

@Smallsmallwindupknight
Copy link
Author

Smallsmallwindupknight commented Jun 18, 2019 via email

@CaiJingLong
Copy link
Owner

CaiJingLong commented Jun 18, 2019

I can't repeat this crash.
So, please test the code use the ref:

flutter_ijkplayer:
  git:
    url: https://github.com/CaiJingLong/flutter_ijkplayer.git
    ref: c016290922c31b91b088ccb692a7636ebd1b91c6

Or, can you publish a minimum code to help me locate the crash.

@Smallsmallwindupknight
Copy link
Author

Smallsmallwindupknight commented Jun 18, 2019

I used flutter_ijkplayer: ^0.2.8,not git

there the custome widget ,the widget is in a PageView,player release when PageView change page

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_ijkplayer/flutter_ijkplayer.dart';

class VideoView extends StatefulWidget {
  final String url;
  VideoView(this.url);
  @override
  _VideoViewState createState() => _VideoViewState();
}

class _VideoViewState extends State<VideoView> with WidgetsBindingObserver{
  IjkMediaController controller;
  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    controller = IjkMediaController();
//    controller.setNetworkDataSource(widget.url,autoPlay: true);
//    controller.setNetworkDataSource("http://itv.100.ahct.lv1.vcache.cn/100/ott_baseline_kalaok/hd/151/CP0541903573/playlist.m3u8",autoPlay: true);
    controller.setNetworkDataSource("http://114.55.36.48/1204/27/index.m3u8",autoPlay: true);
    Stream<IjkStatus> ijkStatusStream = controller.ijkStatusStream;
    ijkStatusStream.listen((status){
      if(status==IjkStatus.complete){
        controller?.play();
      }
    });
//    SystemChannels.lifecycle.setMessageHandler((msg) {});
  }
  @override
  void didChangeAppLifecycleState(AppLifecycleState state) {
    if(state==AppLifecycleState.resumed){
      controller?.play();
    }else if(state==AppLifecycleState.paused){
      controller?.pause();
    }
  }
  @override
  void deactivate() {
    // TODO: implement deactivate
    super.deactivate();
    controller?.pause();
  }
@override
  void reassemble() {
    // TODO: implement reassemble
    super.reassemble();
    controller?.play();
  }
  @override
  void dispose() {
    // TODO: implement dispose
    super.dispose();
    controller?.dispose();
  }
  @override
  Widget build(BuildContext context) {
    return IjkPlayer(
      mediaController: controller,
      controllerWidgetBuilder: (mController)=>new Container(),
    );
  }
}

@Smallsmallwindupknight
Copy link
Author

image
here the flutter doctor info @CaiJingLong

@CaiJingLong
Copy link
Owner

I run next code, and I don't meet crash/ANR.

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

class VideoWidget extends StatefulWidget {
  final String url;
  VideoWidget(this.url);
  @override
  _VideoWidgetState createState() => _VideoWidgetState();
}

class _VideoWidgetState extends State<VideoWidget> with WidgetsBindingObserver {
  IjkMediaController controller;
  @override
  void initState() {
    super.initState();
    controller = IjkMediaController();
    controller.setNetworkDataSource(widget.url, autoPlay: true);
    Stream<IjkStatus> ijkStatusStream = controller.ijkStatusStream;
    ijkStatusStream.listen((status) {
      if (status == IjkStatus.complete) {
        controller?.play();
      }
    });
//    SystemChannels.lifecycle.setMessageHandler((msg) {});
  }

  @override
  void didChangeAppLifecycleState(AppLifecycleState state) {
    if (state == AppLifecycleState.resumed) {
      controller?.play();
    } else if (state == AppLifecycleState.paused) {
      controller?.pause();
    }
  }

  @override
  void deactivate() {
    super.deactivate();
    controller?.pause();
  }

  @override
  void reassemble() {
    super.reassemble();
    controller?.play();
  }

  @override
  void dispose() {
    super.dispose();
    controller?.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return IjkPlayer(
      mediaController: controller,
      controllerWidgetBuilder: (mController) => new Container(),
    );
  }
}

class SreErrorPage extends StatefulWidget {
  @override
  _SreErrorPageState createState() => _SreErrorPageState();
}

class _SreErrorPageState extends State<SreErrorPage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(),
      body: Container(
        child: PageView.builder(
          itemBuilder: (BuildContext context, int index) {
            return VideoWidget("http://114.55.36.48/1204/27/index$index.m3u8");
          },
        ),
      ),
    );
  }
}

@Smallsmallwindupknight
Copy link
Author

can the url play?must use the error url. try to replace with this url:

http://itv.100.ahct.lv1.vcache.cn/100/ott_baseline_kalaok/hd/151/CP0541903573/playlist.m3u8

@CaiJingLong
Copy link
Owner

OK, the url will crash, I will locate and resolve it.

@Smallsmallwindupknight
Copy link
Author

ok,thanks

@CaiJingLong
Copy link
Owner

Before I update the pub version, you can temporarily use git dependencies.

There was no crash in this Ref.

flutter_ijkplayer:
  git:
    url: https://github.com/CaiJingLong/flutter_ijkplayer.git
    ref: c016290922c31b91b088ccb692a7636ebd1b91c6

@Smallsmallwindupknight
Copy link
Author

ok

@CaiJingLong
Copy link
Owner

I update pub version 0.2.9, and the version fix it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
android bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants