Detect when a movie has been read successfully

Did you know that the (or object will report when it has completed a read operation? You can show that report to the user as visual feedback, and/or you can use that report to trigger other events in your program, such as querying for information about the movie that is being read.

When receives a read message it opens the specified movie file and reads in the first frame of video (followed by successive frames if the autostart attribute is on). It also sends out a read message of its own out its right outlet, reporting the name of the file and a “flag” (a 1 or a 0) telling whether the read operation was successful. A typical output message might look like ‘read 1′. By looking for that success flag in the outgoing read message (using a select 1 object), you can confirm that the operation was successful, and can trigger other things to happen.

The route object in this patch looks for the selector read and sends the rest of the message (the filename and the success flag) out its left outlet, the unpack object separates the symbol (the filename) from the integer (the flag), and the sel 1 object sends a bang if the file opened successfully.

The example patches “Movie attributes” and “Attributes of” show how to use that bang to query the object for other useful information contained in the movie’s attributes, such as its duration, its frame rate, etc.