=== Video Hosting & Live Streaming with Paywall ===
Contributors: dcast
Tags: live stream, video hosting, pay per view, video player, sell videos
Requires at least: 6.3
Tested up to: 7.1
Requires PHP: 8.1
Stable tag: 0.2.4
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Stream live, host videos and sell access on your site - upload from wp-admin, embed with a block, paid content stays locked.

== Description ==

Video Hosting & Live Streaming with Paywall by DCAST connects your WordPress site to your DCAST account. You stop copying embed codes by hand: pick a stream or a video from a list inside WordPress, and the player appears on the page.

* **DCAST player block.** Add the block, pick a live stream or a video from your account, done. Optional live chat next to the stream player.
* **Shortcodes** for the classic editor: `[dcast_stream id="..."]` and `[dcast_video id="..."]`.
* **Upload a video** from the WordPress admin (DCAST, Upload video). The file goes from your computer straight to your DCAST account, so this site's upload size limit does not apply and the file does not take space on your web server. A progress bar shows the upload and then DCAST preparing the video; when it is ready it is in the block's list, with a button for a new post.
* **Create a stream** from the WordPress admin. The encoder settings (server and stream key for OBS) are shown right there, and a draft post with the player can be created in the same step.
* **Your streams and videos in WordPress.** One click puts one into a new draft or at the end of an existing post or page.
* **Allowed websites check.** If your DCAST account limits which websites may show your player, the settings screen says so and adds this site with one click.
* **Clear errors.** When DCAST refuses something (a plan limit, a wrong key), the message says what to do next.

The player code always comes from your DCAST account through the DCAST Partner API, so what you see on your site is the same player your DCAST account gives you. What your plan includes (for example, removing DCAST branding) is decided by your DCAST plan, not by this plugin; the plugin has no paid features of its own.

= Shortcode options =

* `[dcast_stream id="ID" chat="yes"]` shows the live chat under the player.
* `responsive="no"` uses a fixed-size player instead of one that fits the page width.
* `width="960" height="540"` sets the fixed size (with `responsive="no"`).
* `[dcast_video id="ID"]` takes `responsive`, `width` and `height` the same way.

== External services ==

This plugin is a client of the DCAST service (a live streaming and video hosting platform). It does nothing without a DCAST account and a DCAST API key.

**1. DCAST Partner API, called from your server.** Address: `https://api.dcast.pro/api/v1` by default (an administrator can change it on the settings page or with the `DCAST_LIVE_API_BASE` constant). Every request carries the saved API key, a random request id, and the plugin and WordPress version numbers in the User-Agent. Requests are made only in these cases:

* An administrator opens DCAST, Settings with a key saved: the plugin reads the account the key belongs to, its plan and its list of websites allowed to show the player.
* An administrator clicks "Allow" for this site: the plugin sends the account's list of allowed websites with this site's host name added.
* A user opens DCAST, Streams and videos, or picks an item in the DCAST player block: the plugin reads the account's streams and videos (an optional search word is sent for videos). When the user puts one into a new draft, the plugin reads that stream or video to take its title.
* An administrator creates a stream: the title and the visibility are sent, and the new stream is read back once to show its encoder settings (server and stream key) on the screen; the stream key is not stored on your site.
* A user uploads a video: the title, the file name, the file size and the visibility are sent; then the plugin asks for the processing status of that video, and on "Cancel upload" it asks DCAST to delete that video.
* A page with a DCAST block or shortcode is shown and no fresh copy is cached on your site: the id of the stream or video and the player size are sent, and DCAST answers with the player code. The answer is cached for 10 minutes; the last good copy is kept for up to 7 days and shown to visitors while DCAST cannot be reached.

No data about your site's visitors is sent by the plugin.

**2. Video file upload, from the uploading user's browser.** For an upload, your server asks DCAST for a signed upload address that is valid for one video and one hour, and gives only that address to the browser of the user who uploads. That browser then sends the video file directly to DCAST (to `api.dcast.pro`, which forwards it to a DCAST storage server). The API key is never sent to the browser.

**3. The DCAST player, loaded by your visitors' browsers.** Pages with a DCAST block or shortcode show the DCAST player (and, if chosen, the live chat) in an iframe. The visitor's browser loads it from the player address of your DCAST account: your verified custom domain or DCAST subdomain, otherwise `dcast.tv`. What the player does is governed by DCAST's terms and privacy policy.

The settings screen and error messages also contain links to your DCAST account at `dcast.tv` (the address can be changed on the settings page); they are opened only when you click them.

* DCAST terms of service: https://dcast.tv/terms
* DCAST privacy policy: https://dcast.tv/privacy

== Installation ==

1. Install and activate the plugin.
2. In your DCAST account open Settings, API Keys and create a key. For creating streams and uploading videos from WordPress, give it STANDARD or FULL_ACCESS access; for showing players only, READ_ONLY is enough.
3. In WordPress open DCAST, Settings and paste the key. The screen confirms the connection and the account it belongs to.
4. Add the DCAST player block to a post or page, or open DCAST, Streams and videos.

== Frequently Asked Questions ==

= Where is my API key stored? =

In your WordPress database (options table), and it is never shown again after saving. It is sent only to the DCAST API address on the settings page, from your server; it never reaches visitors' browsers or the block editor.

= The player frame is empty on my site. =

Your DCAST account may limit which websites can show your player. Open DCAST, Settings: if this site is not on the list, the screen offers to add it.

= Who may upload videos? =

Users who may add media to this site (the `upload_files` capability: by default administrators, editors and authors). A site can change it with the `dcast_live_upload_capability` filter. Every upload goes into the DCAST account whose key is saved in the settings and counts toward its storage.

= Is there a file size limit? =

This site's PHP upload limit does not apply, because the file does not pass through this site. The limits of your DCAST plan apply; when one is reached, the upload screen shows DCAST's message.

= Can I protect videos from downloading with this plugin? =

No. The plugin shows the DCAST player; access rules (who may watch) are set on the stream or video in DCAST.

= What is removed when I delete the plugin? =

The saved API key, the two DCAST addresses, the cached player code and each user's list of unfinished uploads. Nothing in your DCAST account is deleted.

== Screenshots ==

1. The DCAST player block in the editor: pick a live stream or a video from your DCAST account.
2. DCAST, Streams and videos: your streams and videos, with one click to put one into a post.
3. DCAST, Upload video: the file goes straight to your DCAST account, with a progress bar.
4. DCAST, Settings: the API key, the connection check and the allowed websites check.

== Changelog ==

= 0.2.4 =
* Text domain and folder renamed to video-hosting-live-streaming-with-paywall, the slug WordPress.org gives this plugin name, so translations load from translate.wordpress.org.
* Error notices in the admin are escaped where they are printed.

= 0.2.3 =
* Readme for the WordPress.org directory: the External services section lists every request the plugin makes, when it makes it and what it sends.
* Uninstall also removes each user's list of unfinished uploads.

= 0.2.2 =
* Advice for the DCAST email wall (VERIFICATION_REQUIRED): an unconfirmed account gets its first item of each kind; the second asks to confirm the email.

= 0.2.1 =
* Renamed to Video Hosting & Live Streaming with Paywall.

= 0.2.0 =
* Upload to DCAST: upload a video file from the WordPress admin straight into the DCAST account, with progress, resume of interrupted pieces, cancel, and a new post with the video when it is ready.

= 0.1.1 =
* Tested with WordPress 7.1.
* Translation template (languages/dcast-live.pot).

= 0.1.0 =
* First version: settings, block, shortcodes, stream creation, stream and video list with one-click insert, allowed websites check.
