PEAR::HTML::Progress example: Listener usage with HTTP_Request
Author: Laurent Laville

examples

# Preload Shockwave Flash object

$Date: 2005/07/25 11:23:37 $

- Introduction
- Render options
- PHP source syntax highlight
- Play demo

## Introduction

This example requires :

- PEAR::HTTP_Request 1.2.2 or better (see source at line 14).
- PEAR::HTML_Progress 1.1 or better (see source at line 16).

Be aware that:

- HTTP_Request has dependencies (Net_URL 1.0.12+, Net_Socket 1.0.2+)

This example will display a basic progress bar while retrieving a large file.

We have created a Request/Listener class HTTP_Request_DownloadListener on lines 18 to 104. In this Listener, a progress bar was integrated on lines 78 to 84. It's a basic progress bar with only one render option changed (animation speed).

On lines 90 and 92 the progress bar is updated depending of the data size already received.

Media file is identify by URL defined at line 106.

When the shockwave flash object is fully loaded, page sw4p.html is shown on lines 115 to 117.

[Top]

## Render options

Animation speed is set to 10 (see source at line 79).

[Top]

## PHP source syntax highlight

Open source listing in a new window.

[Top]

## Play demo

Run the script.

[Top]