-
Notifications
You must be signed in to change notification settings - Fork 0
BunnyCDN Integration
Presto Player Pro integrates with Bunny.net for video hosting and delivery. The integration covers two distinct Bunny products: Bunny Stream (video encoding and delivery library) and Bunny Storage (file storage with CDN pull zones).
BunnyService (Services/Bunny/BunnyService.php)
│ Main facade — URL signing, JS vars, user video sync
│
├─ BunnyCDNBlock (Blocks/BunnyCDNBlock.php)
│ Block that renders Bunny stream videos (public + private)
│
├─ Controllers/
│ ├─ BunnyStreamController — library + pull zone setup
│ ├─ BunnyVideoLibraryController — create/update video libraries
│ ├─ BunnyVideosController — upload/list/delete stream videos
│ ├─ BunnyCollectionsController — video collection management
│ └─ BunnyPullZoneController — fetch/configure pull zones
│
├─ Libraries/
│ ├─ BunnyApiRequest — general Bunny API (CDN/storage API)
│ ├─ BunnyVideoApiRequest — Bunny Stream API
│ └─ Services/Bunny/CDNRequest — CDN/storage HTTP requests
│
└─ Models/Bunny/
├─ Account — account-level settings
├─ PullZone — pull zone config (ArrayAccess)
├─ StorageZone — storage zone config (ArrayAccess)
└─ Collection — video collection config (ArrayAccess)
| Option Key | Description |
|---|---|
presto_player_bunny_stream_public |
Public library: video_library_id, video_library_api_key, pull_zone_id, pull_zone_url, token_auth_key
|
presto_player_bunny_stream_private |
Private library: same fields as public |
presto_player_bunny_stream |
General: hls_start_level (default 480p), disable_legacy_storage
|
presto_player_bunny_pull_zone |
Pull zone details (stored via PullZone model) |
presto_player_bunny_storage_zone |
Storage zone details (stored via StorageZone model) |
Bunny Stream supports two video library types:
| Type | Access | URL Signing | HLS Auth |
|---|---|---|---|
| Public | Open — no auth | Not required | No token needed |
| Private | Restricted | Signed URLs with expiry | Token authentication |
The BunnyCDNBlock checks the video's library type and injects the appropriate signed URL and HLS configuration via:
add_filter( 'presto_player/block/default_attributes', [$this, 'addVideoAttributes'] );
add_filter( 'presto_player/component/attributes', [$this, 'injectSignedUrl'] );BunnyService signs video URLs before they are served to the browser:
- Checks
BunnyService::isSetup()— validates that pull zone, library, and token key are configured - On
presto_player_rest_prepared_response_itemfilter: callsmaybeSignURL()to replace the raw URL with a time-limited signed URL - Signed URL format:
https://{pull-zone-url}/{video-id}/playlist.m3u8?token={hash}&expires={timestamp}
- User uploads via Media Hub block or WP admin
-
RestBunnyStreamControllerreceivesPOST /bunny-stream/videos -
BunnyVideosControllercallsBunnyVideoApiRequestto create a video in the library - File is uploaded to Bunny Stream via tus or direct upload
- Bunny transcodes to HLS
-
presto_player_videos_createdfires →BunnyService::updateUserVideos()storesexternal_idin user meta
BunnyService stores a list of each user's Bunny video IDs in user meta to scope API results:
update_user_meta( $user_id, 'presto_bunny_video_ids', $video_ids );This prevents users from seeing other users' videos in the Media Hub browser.
For direct file storage (not Stream), Services/Bunny/Storage/StorageAPI.php handles:
- File upload to Bunny storage zone
- File deletion
- Directory listing
Security Note (v3.0.2): An arbitrary file deletion vulnerability in Bunny CDN API endpoints was patched. Always validate file paths and user permissions before processing delete requests.
- Obtain API key from Bunny.net dashboard
- Create a video library (public or private)
- In Presto Player settings → BunnyCDN → enter library ID + API key
- Run the pull zone setup wizard (creates CDN pull zone automatically)
- For private videos: enable token authentication in Bunny dashboard and copy the token auth key
- Add
BunnyCDNBlockto a post and select the video
Presto Player | Presto Player Pro | prestoplayer.com | PHP 7.3+ | WordPress 6.3+