TheWidlarzGroup / react-native-video

A <Video /> component for react-native
http://thewidlarzgroup.github.io/react-native-video/
MIT License
7.14k stars 2.88k forks source link

[BUG]: onEnd callback is not triggered android #4098

Open Koykoy200078 opened 3 weeks ago

Koykoy200078 commented 3 weeks ago

Version

^6.4.5

What platforms are you having the problem on?

Android

System Version

12

On what device are you experiencing the issue?

Real device

Architecture

Old architecture

What happened?

While playing any video till the end, the onEnd Callback sometime is not triggered

"react-native": "0.75.1", "react-native-video": "^6.4.5", "react-native-media-console": "^2.2.4",

// Video Player Component <VideoPlayer videoRef={videoRef} useAnimations={useAnimations} source={{ uri: videoLink, headers: { Referer: referer, }, }} navigator={navigation} title={videoTitle} controlTimeoutDelay={3000} isFullscreen={isFullscreen} disableBack={!isFullscreen} resizeMode='contain' containerStyle={{ width: width, height: '100%' }} showDuration={true} onBuffer={onBuffer} onError={onError} onEnterFullscreen={handleFullScreen} showOnEnd={true} onEnd={() => { onVideoEnd() console.log('Video Ended') Orientation.lockToPortrait() setIsFullscreen(false) fullView(false) StatusBar.setHidden(false) showNavigationBar() changeNavigationBarColor(COLORS.background, true, true) }} onBack={() => { Orientation.lockToPortrait() setIsFullscreen(false) fullView(false) StatusBar.setHidden(false) showNavigationBar() changeNavigationBarColor(COLORS.background, true, true) }} />

// Main Layout <VideoPlayerComponent videoLink={video_link} referer={referer} navigation={navigation} isPlaying={isPlaying} videoTitle={allData.title} isFinished={videoEnded} fullView={(val: boolean) => setHideFullScreen(val)} onBuffer={(val) => setIsBuffering(val.isBuffering)} onPressPlay={() => setIsPlaying(true)} onPressReplay={() => setIsPlaying(true)} onVideoEnd={() => { setVideoEnded(true) setIsPlaying(false) updateEpisodesWatched(lastCurrentEpisodeWatched.animeId, lastCurrentEpisodeWatched.episodeId) lastEpisodeWatched(lastCurrentEpisodeWatched.animeId, lastCurrentEpisodeWatched.episodeId) }} onError={(error) => showError({ title: 'Error', description: error, }) } />

Reproduction

repository link

Reproduction

Step to reproduce this bug are:

moskalakamil commented 3 weeks ago

Hi, thanks for reporting the issue! Could you please tell me, if you remove all of the props except source and onEnd, the issue is still active? I'm just wondering if it's connected to other prop

Koykoy200078 commented 3 weeks ago

Hi, thanks for reporting the issue! Could you please tell me, if you remove all of the props except source and onEnd, the issue is still active? I'm just wondering if it's connected to other prop

yes, I already try on that way but still not giving me a response back that the video is already finished, also i have a problem with the subtitle I works perfectly fine only the problem occures when i forward the video and giving me back this error: ERROR Error playing video: {"error": {"errorCode": "22001", "errorException": "androidx.media3.exoplayer.ExoPlaybackException: Source error", "errorStackTrace": "androidx.media3.exoplayer.ExoPlaybackException: Source error at androidx.media3.exoplayer.ExoPlayerImplInternal.handleIoException(ExoPlayerImplInternal.java:717) at androidx.media3.exoplayer.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:689) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loopOnce(Looper.java:240) at android.os.Looper.loop(Looper.java:351) at android.os.HandlerThread.run(HandlerThread.java:67) Caused by: androidx.media3.datasource.HttpDataSource$HttpDataSourceException: okhttp3.internal.http2.StreamResetException: stream was reset: INTERNAL_ERROR at androidx.media3.datasource.okhttp.OkHttpDataSource.read(OkHttpDataSource.java:396) at androidx.media3.datasource.DefaultDataSource.read(DefaultDataSource.java:281) at androidx.media3.datasource.StatsDataSource.read(StatsDataSource.java:94) at androidx.media3.extractor.DefaultExtractorInput.readFromUpstream(DefaultExtractorInput.java:293) at androidx.media3.extractor.DefaultExtractorInput.read(DefaultExtractorInput.java:70) at androidx.media3.extractor.ts.TsExtractor.fillBufferWithAtLeastOnePacket(TsExtractor.java:558) at androidx.media3.extractor.ts.TsExtractor.read(TsExtractor.java:448) at androidx.media3.exoplayer.hls.BundledHlsMediaChunkExtractor.read(BundledHlsMediaChunkExtractor.java:102) at androidx.media3.exoplayer.hls.HlsMediaChunk.feedDataToExtractor(HlsMediaChunk.java:503) at androidx.media3.exoplayer.hls.HlsMediaChunk.loadMedia(HlsMediaChunk.java:467) at androidx.media3.exoplayer.hls.HlsMediaChunk.load(HlsMediaChunk.java:424) at androidx.media3.exoplayer.upstream.Loader$LoadTask.run(Loader.java:421) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644) at java.lang.Thread.run(Thread.java:1012) Caused by: okhttp3.internal.http2.StreamResetException: stream was reset: INTERNAL_ERROR at okhttp3.internal.http2.Http2Stream$FramingSource.read(Http2Stream.kt:355) at okhttp3.internal.connection.Exchange$ResponseBodySource.read(Exchange.kt:281) at okio.RealBufferedSource$inputStream$1.read(RealBufferedSource.kt:161) at androidx.media3.datasource.okhttp.OkHttpDataSource.readInternal(OkHttpDataSource.java:562) at androidx.media3.datasource.okhttp.OkHttpDataSource.read(OkHttpDataSource.java:394) ... 14 more ", "errorString": "ExoPlaybackException: ERROR_CODE_IO_NETWORK_CONNECTION_FAILED"}}

// this is my setup also const [selectedSubtitleType] = useState<{ type: string; value: string }>({ type: 'language', value: 'en', })

const [subtitle] = useState<{ title: string; language: string; type: string; uri: string }[]>([ { title: resultSubs.lang, language: 'en', type: 'text/vtt', uri: resultSubs.url, } ])

selectedTextTrack={selectedSubtitleType} textTracks={subtitle && subtitle.length > 0 ? subtitle : []}`

freeboub commented 3 weeks ago

@Koykoy200078 Did you try to reproduct he issue with the sample app ? I am suspecting something with your CDN or the content you are playing ...

noumanali53 commented 3 weeks ago

when you have to set repeat={false} then onEnd callback function is called other wise they can't called

Koykoy200078 commented 3 weeks ago

@Koykoy200078 Did you try to reproduct he issue with the sample app ? I am suspecting something with your CDN or the content you are playing ...

yes, i tried in a simple app without any 3rd parties except react-native-video, with the latest version of react native by fetching 3 videos length 2 mins each via link, the first link called the onEnd but somethimes when i move forward to a specific time it will not called onEnd, the second and third not called onEnd again when it called in link one

Koykoy200078 commented 3 weeks ago

when you have to set repeat={false} then onEnd callback function is called other wise they can't called

I didn't know there is a repeat in the attributes, I will check this if work

seyedmostafahasani commented 3 weeks ago

Let me check it out.

noumanali53 commented 3 weeks ago

Hi, thanks for reporting the issue! Could you please tell me, if you remove all of the props except source and onEnd, the issue is still active? I'm just wondering if it's connected to other prop

When i remove other props then work perfectly. But the issues when is use repeat props then onEnd not work in android side. the same props work perfectly on IOS side.

noumanali53 commented 3 weeks ago

when you have to set repeat={false} then onEnd callback function is called other wise they can't called

I didn't know there is a repeat in the attributes, I will check this if work

Sure! try to check using repeat={true} and call the onEnd callback Function

seyedmostafahasani commented 6 days ago

@Koykoy200078 @noumanali53 I tested with repeat={true}, and onEnd works correctly.

freeboub commented 6 days ago

I cannot reproduce the issue with the sample app also. Are you able to provide a sample stream or sample app or reproduce it with sample ?