[ Team LiB ] |
Recipe 14.11 Pausing and Resuming a Net Stream14.11.1 ProblemYou want to control the playback (pause or resume) of audio and/or video that is being played from a net stream. 14.11.2 SolutionUse the NetStream.pause( ) method. 14.11.3 DiscussionYou can use the NetStream.pause( ) method to pause the playback of a net stream. For example, if a net stream is playing, the following line of code pauses its playback: myNetStream.pause( ); However, the pause( ) method, when used without a parameter, acts as a toggle between pausing and resuming playback. If the net stream in the preceding example is already paused at the time that the pause( ) method is invoked, the stream begins playing again at the point where it left off. Alternatively, you can specify a Boolean parameter to indicate whether the net stream should pause or resume, regardless of its current state. A value of true causes a net stream to pause if it is playing or to remain paused if it is already paused. On the other hand, a value of false causes the net stream to resume playing if it is paused or to continue playing if it is already playing. For example: // Cause a net stream to pause. myNetStream.pause(true); // Cause a net stream to play. myNetStream.pause(false); The play( ) method should not be used to resume the playback of a net stream, nor should it be used to fast-forward or rewind (see Recipe 14.12). The play( ) method retrieves a stream from the FlashCom server and adds it to a client's net stream for playback. If you call play( ) more than once, one of two things can happen:
You can pause and resume any stream, even live streams. However, when you pause a live stream, it resumes at the current (realtime) position, not at the point where the stream was paused. 14.11.4 See AlsoRecipe 13.3, Recipe 14.8, and Recipe 14.12 |
[ Team LiB ] |