diff --git a/proprietary/wvm/WVMExtractorImpl.cpp b/proprietary/wvm/WVMExtractorImpl.cpp index 25e44ec6..de65227b 100644 --- a/proprietary/wvm/WVMExtractorImpl.cpp +++ b/proprietary/wvm/WVMExtractorImpl.cpp @@ -466,6 +466,20 @@ int64_t WVMExtractorImpl::getCachedDurationUs(status_t *finalStatus) { if (status == WV_Status_OK) { *finalStatus = OK; durationUs = 8000000LL * bytesBuffered / encodedRates[currentTrack]; + + // Fixed 4515636 Playback stops 5-7 seconds before end of video, + // session isn't terminated. Awesome player pauses video if + // duration is less than 2 seconds (see kLowWaterMarkUs in + // AwesomePlayer.cpp); we return END_OF_STREAM when we have 2 + // seconds of data left and let WVMK handles the actual end of media. + std::string szDuration = WV_Info_GetDuration(mSession, "sec"); + std::string szCurrent = WV_Info_GetTime(mSession, "sec"); + + double duration = strtod(szDuration.c_str(), NULL); + double current = strtod(szCurrent.c_str(), NULL); + if ((duration - current) <= 2.00) { + *finalStatus = ERROR_END_OF_STREAM; + } } else if (status == WV_Status_End_Of_Media) { *finalStatus = ERROR_END_OF_STREAM; }