Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Not seeing QMediaPlayer::EndOfMedia at end of some videos; other videos OK
I'm using Qt 5.1 on a mid-2012 MacBook Pro and using QMediaPlayer and QVideoWidget. I created a trivial player app (something very easy to do with these 2 components) and played some of the sample videos Apple has put up at "here":http://support.apple.com/kb/HT1425?viewlocale=no_NO&locale=no_NO ; I have some logging slot functions connected to the various signals emitted by the player (and set the notify interval to 1000ms).
sample_mpeg2.m2v and sample_mpeg4.mp4 seem to work fine and do what I'd expect to see: QMediaPlayer emits a series of sensible looking signals on startup including reporting of the duration, followed by periodic logging of the position through the stream as it plays and a final change to QMediaPlayer::StoppedState and QMediaPlayer::EndOfMedia.
However, sample_iTunes.mov from that site behaves more strangely: the signals reporting position seems to stop after some random interval (although the video continues playing fine) and when the video does reach its end, this isn't reported via either of a QMediaPlayer::StoppedState or QMediaPlayer::EndOfMedia. Also (and this is where it gets weird) if I then do later minimise (or resize, or obscure with another window) the player window, that seems to somehow "flush" the final signalling of an end positon, a QMediaPlayer::StoppedState and a QMediaPlayer::EndOfMedia.
I also observe this behaviour when I attempt to play my own .mov files in QMediaPlayer. I did try converting one to mpeg2/4 with mencoder, but then the converted files still seem to exhibit this behaviour of the end of the video not being "noticed" (at least until the window is prodded somehow, when those events do get "flushed" as mentioned above). In any case I'm not entirely sure that the sample mpeg2/4 don't appear to work better just because they're shorter (needs more testing).
If I didn't care that much about the video end being reached, I could probably ignore this issue, but what I want to do eventually will need my application to be aware of it when it happens to be able to react to it.
Any insight into what's going on here, how to work round it or what to try next? Would be most grateful for any pointers to get things working better.
My minimal example is 4 files, 128 lines total (not sure what etiquette is here; post it or use something like pastebin?) I haven't tried this on any other OS yet (my Linux machines are on Debian stable's 4.8 - which didn't have QMediaPlayer/QVideoWidget - and I don't have a Windows machine).
Hmmm inspecting src/plugins/qt7/mediaplayer/qt7playersession.mm in the Qt51 sources I see that a QTMovieDidEndNotification is being wired up by NSNotificationCenter to call QT7PlayerSession::processEOS() which emits the expected signals and all looks entirely sensible.
Unfortunately googling QTMovieDidEndNotification suggests I'm not alone in finding Quicktime not emitting this notification sometimes ("example":http://lists.apple.com/archives/quicktime-api/2009/Mar/msg00020.html).
I now doubt my earlier suspicion the issue is video stream format related; anything over 5-10s seems to be at risk of not getting an end of stream MediaStatus change. I have seen one stream just switch to constantly reporting a constant position at the end though.
All very mysterious; investigations continue...
Upgraded to Qt 5.1.1 on the Mac; no improvement.
To get a "second opinion" from another platform, I now have Debian's embryonic Qt 5.1 running in a sid+experimental VM.
Qt's supplied examples/multimediawidgets/videowidget example actually illustrates the issue nicely. Both machines will play the file sample_iTunes.mov "downloaded from here":http://support.apple.com/kb/ht1425 (video and audio). At the end of the video (the tedious start can be skipped over with the example's slider) behaviour differs:
On linux, the pause/play button reverts to the "play" icon (indicating the arrival of a non QMediaPlayer::PlayingState state in mediaStateChanged) immediately after the video ends (right after the last spoken word of audio).
On the Mac, usually nothing happens when it gets there and the button continues to show the "pause" icon. If you add some instrumentation to log position from the positionChanged slot, you'll see the position just gets stuck repeatedly reporting a constant number, but there's no state change from PlayingState. However, if you minimise the app or obscure it with another window, that does seem to be sufficient for the media state to be flushed and the button changes to the "play" graphic as expected (adding some logging to the mediaStateChanged slot makes it more obvious what's happening - or rather not happening - and when).
Now raised in "Jira":https://bugreports.qt-project.org/browse/QTBUG-33761
Unfortunately the Mac behaviour is proving to be a real pain to work round. The media state can't just be ignored; if a video does ever hit the end, then at some random point in the future the mediaplayer may suddenly be stopped and reset to the start when the stuck end-of-media and stop is flushed. I am actually now playing with a watchdog ticker to try and spot when this happens and quickly revert the player back to the intended state and position; but it's just too horrid really.