I've uploaded a corrupted video (just opened in text editor and mucked with components of a real video) here: http://www.selikoffsolutions.com/BadVideo.flv
Even the Adobe Media Player doesn't throw an error when opening or reading this file. I'd really like to know what listener, if any, is thrown a VideoDisplay object tries to play such a video.
W e can't expect some error event to be thrown to playback a tempered file. In most of the cases, one can look at the playhead counter. If that counter gets stuck on a value, one can conclude the content is bad.
Such as the following---
***********************************PlaybackAction Netstatus Event NetConnection.Connect.SuccessPlaybackAction NetStream.play():http://www.selikoffsolutions.com/BadVideo.flvPlaybackAction NetStream.play() returns. Waiting for event...PlaybackAction Netstatus Event NetStream.Play.StartPlaybackAction time to play: 10PlaybackAction Playhead time (s) 0PlaybackAction Playhead time (s) 0PlaybackAction Netstatus Event NetStream.Buffer.FlushPlaybackAction Netstatus Event NetStream.Play.StopPlaybackAction Playhead time (s) 0PlaybackAction Playhead time (s) 0PlaybackAction Playhead time (s) 0...playhead always 0
> We can't expect some error event to be thrown to playback a tempered file.
Yes, we can, and we should. In this example, the file was manually distorted but in the real example that this came from, file was corrupted from a bad transmission. Sitting there with a black screen doing nothing is never an acceptable solution and the flash video play should recognize this and throw an error to the user.
Have you looked in to the fl.video.VideoError class?
Are you using streaming or progressive download?
The code is the standard VideoDisplay loading code.
Generally, the corrupted audio/video packages will be silently dropped. That’s the behavior of FlashPlayer. In this perticuler case, http://www.selikoffsolutions.com/BadVideo.flv, the metadata can be retrieved by listening MetadataEvent.METADATA_RECEIVED. But it falls to the "stopped" state very fast. There is no picture played; and no error event dispatched. In some other cases, the video can go to some point then get stuck there, even without the state event turning to "stopped".
If we look at the VideoEvent.PLAYHEAD_UPDATE event, the time value will always get stuck at a fixed value under these circumstances. So one workaround would be to observe this event. We fail the playback if this playhead time value doesn't advance for a tolerable time interval. Here is code sample:
<mx:VideoDisplay x="142" y="116" width="704" height="386" id="player" rewind="false" source="http://www.selikoffsolutions.com/BadVideo.flv"/>
private var lastPlayHead :Number; // remember the playhead time from the last polling
private var timeoutTimer :Timer = null;
private function registerListener() :void
private function onPlayheadUpdate(e :VideoEvent) :void
var currentHead :Number = e.playheadTime;
if (currentHead > lastPlayHead)
// restart a timeout timer
if(timeoutTimer != null)
timeoutTimer = new Timer(60000, 0); // if the playhead not increment for 1 minute, then timeout this action
lastPlayHead = currentHead;
private function timeoutHandler (e :TimerEvent) :void
// fail the playback