tcking / GiraffePlayer2

out of the box android video player(support lazy load, ListView/RecyclerView and hight performance)
Apache License 2.0
377 stars 110 forks source link

Using videoView in a fragment #99

Closed dhavalpatel349 closed 6 years ago

dhavalpatel349 commented 6 years ago

hi, I am trying to play video live stream url into videoView in a fragment; works fine for first time; but issue arises once fragment is popped and user selects a different url and redirects to same fragment same videoView with different url.

using latest 0.1.19 version.

some demo snippets for reference


    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //set global configuration: turn on multiple_requests
        PlayerManager.getInstance().getDefaultVideoInfo().addOption(Option.create(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "multiple_requests", 1L));
        if (getArguments() != null) {
            strUrl = getArguments().getString(ARG_PARAM);
        }
    }
    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        viewQuery = new ViewQuery(view);
        Log.e("###VIDEO", "url------ " + strUrl);
        final VideoView videoView = viewQuery.id(R.id.video_view).view();
        videoView.setVideoPath(strUrl);
    }

    @Override
    public void onDestroyView() {
        PlayerManager.getInstance().getCurrentPlayer().stop();
        super.onDestroyView();
    }

gives error in logcat:

 E/IJKMEDIA: https://livestream.5centscdn.com/flexlive/starplus123.stream/index.m3u8?st=SF2br2Lfpnu6AvdiOi-1cQ&e=1526464190: I/O error
E/tv.danmaku.ijk.media.player.IjkMediaPlayer: Error (-10000,0)

Thanks in advance...!!

tcking commented 6 years ago

try in onDestroyView replace with this code videoView.getPlayer.release()