=== Castio.live – Live Streaming Plugin for WordPress (HLS) + Real-Time Chat ===
Contributors: proxymis
Donate link: https://proxymis.com/
Tags: live streaming, wordpress live streaming, hls streaming, live chat, video streaming, livestream, paywall, monetization, video player
Requires at least: 6.2
Tested up to: 6.9
Requires PHP: 7.3
Stable tag: 1.2.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Live streaming plugin for WordPress with HLS, real-time chat, PayPal & Stripe paywall, and Gutenberg blocks. No OBS, no RTMP.

== Description ==

Castio.live is a **live streaming plugin for WordPress** that lets you go live directly from your admin — no OBS, no RTMP, no external platforms.

Stream video, chat with your audience in real time, and monetize your content with Stripe or PayPal — all from your own WordPress site.

Perfect for creators, educators, events, and premium content platforms.

Castio.live is one of the few WordPress plugins that enables browser-based live streaming without OBS or RTMP.

=== At a Glance ===

- Live streaming plugin for WordPress (HLS)
- Go live directly from WordPress Admin
- Built-in real-time chat
- No OBS, no RTMP, no external platform
- Paywall: Stripe & PayPal
- Gutenberg blocks for easy embedding
- Auto-generated viewer pages
- Works on shared hosting and VPS

[youtube https://www.youtube.com/watch?v=fgw2u0fmAME]

**Start streaming in minutes**  
Install the plugin, click “Start Streaming” in WordPress Admin, and instantly share your live viewer page with your audience.

No streaming SaaS. No vendor lock-in. Full control over your content.

=== Live Streaming from WordPress Admin ===

Castio.live adds a dedicated streaming interface directly inside the WordPress Admin area.

You can:
- Select your camera and microphone
- Preview your stream before going live
- Start and stop streaming with a single click

Supported capture technologies:
- MediaDevices API
- MediaRecorder
- WebCodecs (when available, for lower latency)

Supported streaming browsers:
- Chrome or Edge (desktop)
- Chrome (Android)

Viewer playback works on all modern browsers, including mobile devices.

=== Viewer Page (Auto-Generated) ===

For each live stream, Castio.live can automatically generate a viewer page.

Viewer page features:
- HLS video playback (native HLS on Safari, hls.js on other browsers)
- Clean and lightweight interface
- Mobile-friendly layout
- Optional live chat panel

The viewer page URL can be:
- Public
- Shared privately
- Embedded into other pages
- Protected via access control options

=== Monetize Your Live Streams ===

Castio.live includes built-in monetization features so you can generate revenue from your content:

- Pay-per-view access
- Subscriptions via Stripe
- PayPal payments (no webhooks required)
- Secure access via signed cookies

Perfect for:
- Premium live events
- Online courses
- Private communities
- Exclusive content

No external SaaS required — you keep full control over your revenue.

=== Built-in Real-Time Chat ===

Each live stream includes a built-in real-time chat system.

Chat features:
- AJAX-based live message polling
- Username display
- Automatic refresh
- Message history stored in the WordPress database

Moderation tools:
- View all messages
- Delete individual messages
- Ban users by username
- Ban users by IP address

No external chat service is required.

=== Privacy, Ownership, and Compliance ===

Castio.live is designed with privacy and data ownership as a core principle.

- No third-party streaming services
- No external chat providers
- No analytics or tracking scripts included by default
- No cloud-based video or message processing

All streaming and chat data remains on your own server:
- HLS video segments
- Chat messages
- Stream metadata
- Viewer page configuration

This design helps simplify compliance with GDPR and similar data protection regulations.

=== Technical Architecture ===

Castio.live is a fully WordPress-native plugin.

No dependencies on:
- FFmpeg
- Node.js
- RTMP servers
- External streaming APIs

Core components:
- Browser-based HLS generation
- PHP for stream lifecycle and data storage
- JavaScript for capture, playback, and chat
- WordPress custom post types and options

The plugin works on shared hosting, VPS, and dedicated servers.

=== Key Features Summary ===

- Live stream directly from WordPress Admin
- No OBS, no RTMP, no external streaming platform
- Browser-generated HLS (.m3u8 + .ts)
- Automatic viewer page creation
- Built-in live chat
- Chat moderation tools
- Mobile-friendly viewer experience
- All streaming and chat data stored locally
- Lightweight and efficient
- Compatible with most CDNs, including Cloudflare

=== Who Is This Plugin For? ===

Castio.live is ideal for:
- Educators and online trainers
- Content creators
- Community websites
- Event organizers
- Developers and agencies
- Anyone who wants full control over live streaming without SaaS platforms

=== Source Code and Third-Party Libraries ===

This plugin includes both original source code and third-party JavaScript libraries.

**Original plugin code**
- Unminified, human-readable JavaScript files are included directly in the plugin.
- No obfuscated or encrypted code is used.

**Third-party libraries (vendored, unmodified)**

1. **MediaBunny**
   - File: `assets/js/vendor/mediabunny/mediabunny.esm.js`
   - Source: https://github.com/Vanilagy/mediabunny
   - License: MIT
   - Used for browser-based media processing.

2. **hls.js**
   - File: `assets/js/vendor/hls/hls.min.js`
   - Source: https://github.com/video-dev/hls.js
   - License: Apache License 2.0
   - Used for HLS playback on non-Safari browsers.

These libraries are included for performance and compatibility reasons.
All libraries retain their original licenses and copyright notices.

== External Services ==

This plugin connects to external third-party services to provide optional monetization and licensing features.

=== Stripe Payments ===

Castio.live can integrate with Stripe to allow site owners to sell access to live or recorded streams, including pay-per-view content and subscriptions.

What the service is used for:
Stripe is used to create checkout sessions, process payments, manage subscriptions, and retrieve payment reports related to paid video access.

What data is sent and when:
When a visitor purchases paid content or when the site owner views payment reports, the plugin sends the following data to Stripe:
- Email address provided during checkout
- Payment and checkout session identifiers
- Purchased content or pricing identifiers
- Subscription and payment status metadata

No video streams, chat messages, or media content are transmitted to Stripe.

Service provider:
Stripe, Inc.

Terms of Service:
https://stripe.com/legal

Privacy Policy:
https://stripe.com/privacy

=== PayPal Payments ===

Castio.live can integrate with PayPal to allow site owners to sell access to live or recorded streams via pay-per-view.

What the service is used for:
PayPal is used to create and capture payment orders for paid video access using the PayPal Orders API v2.

What data is sent and when:
When a visitor purchases paid content, the plugin sends the following data to PayPal:
- Order amount and currency
- Return and cancel URLs
- Stream identifier (used as order description)

No video streams, chat messages, or personal user data beyond the above are transmitted to PayPal.

Service provider:
PayPal Holdings, Inc.

Terms of Service:
https://www.paypal.com/us/legalhub/useragreement-full

Privacy Policy:
https://www.paypal.com/us/legalhub/privacy-full

=== Castio.live Licensing Server ===

This plugin connects to the Castio.live licensing server to validate premium licenses and enable optional premium features.

What the service is used for:
The licensing server is used to verify license validity and determine which premium features are available.

What data is sent and when:
During license validation (for example on activation, admin access, or periodic checks), the plugin sends:
- License key
- Site domain name
- Plugin version
- WordPress version

No user-generated content, video streams, or personal data are transmitted.

Service provider:
Castio.live

Terms of Service:
https://castio.live/terms

Privacy Policy:
https://castio.live/privacy

=== Demo and Additional Features ===

A public demo, documentation, and optional commercial features are available at:
https://castio.live

Commercial offerings may include:
- Advanced access control
- Enhanced chat moderation
- Extended streaming options
- Priority support

The core live streaming and chat functionality works without requiring any external service.

=== Author and Support ===

Developed by proxymis  
Website: https://proxymis.com  
Contact: contact@proxymis.com

== Installation ==

1. Upload the `castio-live` folder to `/wp-content/plugins/`, or search for “Castio.live” in the WordPress Plugin Directory.
2. Activate the plugin from the Plugins menu.
3. In WordPress Admin, go to Stream Live and create a new stream.
4. Click “Start Streaming” and share the viewer page URL.

Notes:
- Streaming requires Chrome or Edge on desktop, or Chrome on Android.
- iOS Safari and Firefox do not currently support the required streaming APIs.
- Viewing streams works on all modern browsers.
- HLS files are written to `wp-content/uploads/castio/{stream_id}`.

== Frequently Asked Questions ==

= Does this include real-time chat during streaming? =
Yes. The viewer page shows a built-in real-time chat panel next to the video so your audience can react and interact while you’re live. Moderation tools (ban/delete) require a premium license; basic chat is free.

= Does this plugin use external streaming servers? =
No. Live video streaming and chat run entirely on your own WordPress server.

= Does this plugin connect to external services? =
Yes. Optional features may connect to Stripe and PayPal for payment processing, and to the Castio.live licensing server for premium license validation.

= Can viewers watch streams on iOS Safari? =
Yes. Viewer playback works on iOS Safari using native HLS support.

= Why can’t I stream from iOS Safari or Firefox? =
Those browsers do not currently expose the APIs required to generate HLS streams in the browser.

= Is this plugin compatible with CDNs? =
Yes. Castio.live works with most CDNs, including Cloudflare.

== Screenshots ==
1. Plugin settings and configuration options
2. Sales and revenue reports dashboard
3. Live streaming interface in WordPress Admin
4. Built-in live chat during a stream
5. List of recorded live streams
6. Single recorded video viewer page
7. Pay-per-view access and checkout screen

== Changelog ==

= 1.2.0 =

🚀 **Major update: payments, Gutenberg, and UX improvements**

💳 **PayPal Paywall (NEW)**  
Accept payments via PayPal in addition to Stripe.  
Secure redirect flow (Orders API v2) — no webhooks required.

🧱 **Gutenberg Blocks (NEW)**  
4 native blocks to embed streaming features:
- Streams Grid
- Live Stream
- Stream Viewer
- My Videos

Fully dynamic with settings in the block editor.

📚 **FAQ redesign**  
New responsive 2-column layout for better readability.

🎞️ **Animated plugin icon**  
Improved visibility in WordPress plugin search results.

= 1.1.0 =

**New features**

* **Video preview on stream edit page** – A "Video Preview" meta box now appears on the stream edit screen (`castio_stream` post type). It uses hls.js to play the recorded VOD (`vod.m3u8`) or live playlist (`index.m3u8`) with poster image support, so editors can watch the video directly from the WordPress admin without leaving the page.
* **Vertical resize bar between video and chat** – A draggable handle between the video player and the chat panel lets viewers adjust the height split on the fly. Supports both mouse and touch (mobile).
* **Smart scroll with new-message notification** – When a viewer scrolls up to read earlier messages, incoming messages no longer force the chat to jump to the bottom. A "▼ N new messages" pill appears instead; clicking it scrolls back to the latest message.
* **User count on toggle button** – The "Show/Hide Users" button now displays the live connected-user count, e.g. "Hide Users (4)".
* **Support ticket shortcut on FAQ page** – A prominent button on the FAQ admin page opens `https://castio.live/support/` with the admin email, domain, and license key pre-filled as query parameters for faster support authentication.
* **Video preview excluded from stream listing** – The `[castio_streams]` shortcode now silently skips any stream post that has no recorded video on disk (`vod.m3u8` or `index.m3u8` absent), keeping the public listing clean.

**Freemium model changes**

* **Chat is now free** – Live chat is available on all plans, including the free (unlicensed) plan. The "Allow Chat (Premium)" label and disabled state have been removed.
* **Chat moderation is Premium** – Ban, unban, and delete-message controls now require an active premium license. Non-premium admins see a contextual upgrade notice inside the users sidebar. All five moderation REST endpoints (`/chat/mod/ban`, `/unban`, `/delete`, `/banned_list`, `/list`) enforce the premium check server-side.
* **Admin notice updated** – The locked-features notice no longer lists "Allow Chat"; it now lists "Chat Moderation (ban / delete)" and notes that chat is free.

**UX & UI improvements**

* **Emoji picker overhaul** – Expanded from 8 to 32 emojis across faces, hand gestures, and symbols. The picker now uses `position: fixed` (appended to `<body>`) so it renders above the video element on all browsers and devices, escaping any `overflow: hidden` clipping. Position is calculated from the button's bounding rect and clamped to stay fully within the viewport. On mobile (≤480 px) columns reduce from 8 to 6 to prevent overflow.
* **Chat form buttons** – All chat buttons now have a white background for a lighter look; the Send button retains a dark style to stay visually distinct.
* **Mobile users panel full-width** – On screens ≤640 px, opening the users panel makes it take the full width of the chat area (messages are hidden), providing a proper mobile experience.
* **Admin cannot ban themselves** – Both the sidebar ban button and the per-message ban button now detect when the target name matches the admin's own username and disable the action silently.

**License page improvements**

* Active license badge is now a prominent green pill with a checkmark (✓ Active) instead of plain colored text.
* When the license is active, the license-key input is shown as read-only (disabled) so the key remains visible but cannot be accidentally edited.
* The "Purchase Premium" button is hidden when the license is active.
* The "Save & Verify" button is always visible regardless of license status.

**Admin page (`?page=castio_live`) improvements**

* The "Description" fieldset legend renamed to "About this stream" for clearer phrasing.
* The Invitations block moved to appear directly above the "About this stream" block.
* "Allow Chat" checkbox is always enabled; the disabled/Premium state is removed.

**Bug fixes**

* Fixed emoji popup appearing behind the `<video>` element on mobile browsers (hardware-composited video layer issue) by relocating the popup to `<body>` with `position: fixed`.
* Fixed emoji popup overflowing off-screen edges; popup now measures its own rendered size before positioning and clamps to the viewport with a 6 px margin on all sides.
* Fixed `can_moderate` being passed as `1` for admins without a premium license.

= 1.0.0 =
Initial public release.

== Upgrade Notice ==

= 1.2.0 =
Adds PayPal paywall support, four Gutenberg blocks (Streams Grid, Live Stream, Stream Viewer, My Videos) under a dedicated Castio Live block category, and a 2-column FAQ layout.

= 1.1.0 =
Adds video preview in the admin, a resizable video/chat split, smart scroll with new-message notification, 32-emoji picker, full-width mobile users panel, and a freemium split: chat is now free for all users while moderation tools (ban/delete) require a premium license.

= 1.0.0 =
First public release on WordPress.org.