Skip to content

Commit

Permalink
Merge branch 'release/1.0.1' into v1
Browse files Browse the repository at this point in the history
  • Loading branch information
khalwat committed Feb 1, 2019
2 parents 4e4d0c6 + 2147989 commit 0eb06a7
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# YouTube Live Embed Changelog

## 1.0.1 - 2019-02-01
### Added
- Added a controller endpoint so the `is-live` and `live-viewers` can be pinged dynamically via JavaScript

## 1.0.0 - 2019-01-12
### Added
- Initial release
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ This plugin allows you to embed a YouTube live stream and/or live chat on your w

## Requirements

This plugin requires Craft CMS 3.0.0-beta.23 or later.
This plugin requires Craft CMS 3.0.0 or later.

## Installation

Expand Down Expand Up @@ -128,6 +128,12 @@ To determine if the YouTube Video Stream is live, you can do:
{% endif %}
```

You can also ping the YouTube Live Embed controller via JavaScript to get a dynamic result:

```
/actions/youtubeliveembed/info/is-live
```

### Determining the Number of Live Viewers

To determine the number of viewers watching the live YouTube Video Stream, you can do:
Expand All @@ -136,6 +142,12 @@ To determine the number of viewers watching the live YouTube Video Stream, you c
{% set liveViewers = craft.youtubelive.liveViewers() %}
```

You can also ping the YouTube Live Embed controller via JavaScript to get a dynamic result:

```
/actions/youtubeliveembed/info/live-viewers
```

## YouTube Live Embed Roadmap

Some things to do, and ideas for potential features:
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "nystudio107/craft-youtubeliveembed",
"description": "This plugin allows you to embed a YouTube live stream and/or live chat on your webpage",
"type": "craft-plugin",
"version": "1.0.0",
"version": "1.0.1",
"keywords": [
"craft",
"cms",
Expand Down
56 changes: 56 additions & 0 deletions src/controllers/InfoController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?php
/**
* YouTube Live Embed plugin for Craft CMS 3.x
*
* This plugin allows you to embed a YouTube live stream and/or live chat on your webpage
*
* @link https://nystudio107.com
* @copyright Copyright (c) 2019 nystudio107
*/

namespace nystudio107\youtubeliveembed\controllers;

use nystudio107\youtubeliveembed\YoutubeLiveEmbed;

use Craft;
use craft\web\Controller;

/**
* @author nystudio107
* @package YoutubeLiveEmbed
* @since 1.0.0
*/
class InfoController extends Controller
{
// Protected Properties
// =========================================================================

protected $allowAnonymous = [
'is-live',
'live-viewers',
];

// Public Methods
// =========================================================================


/**
* Returns whether the stream is currently live
*
* @return bool
*/
public function actionIsLive(): bool
{
return YoutubeLiveEmbed::$plugin->embed->isLive();
}

/**
* Returns the number of people currently viewing the live stream
*
* @return int
*/
public function actionLiveViewers(): int
{
return YoutubeLiveEmbed::$plugin->embed->liveViewers();
}
}

0 comments on commit 0eb06a7

Please sign in to comment.