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

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

Open
Koykoy200078 opened this issue Aug 19, 2024 · 14 comments
Open

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

Koykoy200078 opened this issue Aug 19, 2024 · 14 comments
Labels
bug demo requested Please submit a simple app that shows the issue

Comments

@Koykoy200078
Copy link

Koykoy200078 commented Aug 19, 2024

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:

  • Reach the end of the video and check that it won't trigger an onEnd callback. (I have tried to add alert or console.log to check it is working or not.)
@moskalakamil
Copy link
Member

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
Copy link
Author

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
Copy link
Collaborator

@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
Copy link

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

@Koykoy200078
Copy link
Author

@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
Copy link
Author

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
Copy link
Collaborator

Let me check it out.

@noumanali53
Copy link

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
Copy link

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
Copy link
Collaborator

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

@freeboub
Copy link
Collaborator

freeboub commented Sep 5, 2024

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 ?

@freeboub freeboub added the demo requested Please submit a simple app that shows the issue label Sep 5, 2024
Copy link

github-actions bot commented Oct 6, 2024

This issue is stale because it has been open for 30 days with no activity. If there won't be any activity in the next 14 days, this issue will be closed automatically.

@github-actions github-actions bot added the stale Closed due to inactivity or lack or resources label Oct 6, 2024
@farhan067
Copy link

I am still having the issue, using the latest version

onEnd not working with repeat={true}

@moskalakamil
Copy link
Member

@farhan067 could you please provide sample video when issue occurs?

@github-actions github-actions bot removed the stale Closed due to inactivity or lack or resources label Oct 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug demo requested Please submit a simple app that shows the issue
Projects
None yet
Development

No branches or pull requests

6 participants