on_play_done
The `on_play_done` directive specifies a custom HTTP callback endpoint to invoke when playback is finished in the NGINX RTMP module.
Description
The on_play_done directive is part of the NGINX RTMP module, providing the ability to call a specified HTTP endpoint once playback of a media stream has completed. This functionality is particularly useful in live streaming scenarios where actions may need to be taken at the end of a stream, such as logging, analytics, or side effects like triggering other processes. The directive accepts a single argument, which is the URL of the HTTP endpoint to call when playback is finished.
When playback completes, NGINX will send an HTTP request to the specified URL. The request method is generally a POST and can include parameters indicating details about the stream, user, or any other payload needed for handling the completion event on the server side. This design allows for asynchronous processing, enabling the main streaming process to continue without waiting for the HTTP request to complete.
In a typical setup, an application can leverage this directive by defining a callback that records or processes stream information for analytics or storage once the stream is no longer being watched. Using on_play_done in conjunction with other RTMP module directives can significantly enhance the functionality and interactivity of streaming applications.
Config Example
application live {
live on;
on_play_done http://localhost:8080/playdone;
}Ensure the callback URL is reachable from the NGINX server; otherwise, the HTTP request will fail silently.
Check that the HTTP server handling the callback can process incoming requests quickly to avoid potential delays in stream processing.
Using on_play_done might introduce additional latency due to the HTTP request; it's essential to manage this in high traffic situations.