Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Random item #4

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions pluginInfo.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
{
"repoName": "show-on-demand",
"name": "Show On Demand",
"author": "Joe Harrison (joeharrison714)",
"repoName": "show-on-demand-edit",
"name": "Show On Demand-Edit",
"author": "Joe Harrison (joeharrison714), edited by 104Zero for randomization",
"description": "This allows the show to be started on demand via text message",
"homeURL": "https://github.com/joeharrison714/show-on-demand-plugin",
"srcURL": "https://github.com/joeharrison714/show-on-demand-plugin.git",
"homeURL": "https://github.com/104Zero/show-on-demand-plugin",
"srcURL": "https://github.com/104Zero/show-on-demand-plugin.git",
"bugURL": "https://github.com/joeharrison714/show-on-demand-plugin/issues",
"allowUpdates": 1,
"versions": [
{
"minFPPVersion": "4.0",
"maxFPPVersion": "0",
"branch": "master",
"branch": "RandomItem",
"sha": "",
"dependencies": {
"plugins": [
Expand Down
2 changes: 1 addition & 1 deletion scripts/postStart.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/sh

/usr/bin/php /home/fpp/media/plugins/show-on-demand/show_on_demand_bg.php &
/usr/bin/php /home/fpp/media/plugins/show-on-demand-edit/show_on_demand_bg.php &
17 changes: 17 additions & 0 deletions show_on_demand.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@
$madeChange = true;
}

#Add code for addition of Random Playlist Item selection
if (strlen(urldecode($pluginSettings['random_playlist_item']))<1){
WriteSettingToFile("random_playlist_item",urlencode("false"),$pluginName);
$madeChange = true;
}

if ($madeChange) {
$pluginSettings = parse_ini_file($pluginConfigFile);
}
Expand Down Expand Up @@ -159,6 +165,17 @@
</td>
</tr>


<tr>
<th style="text-align: left">Select Random Item from Playlist</th>
<td>
<?
//Code to show checkbox for selecting a random item from the playlist
PrintSettingCheckbox("Pick Random Item From Playlist", "random_playlist_item", $restart = 1, $reboot = 0, "true", "false", $pluginName = $pluginName, $callbackName = "", $defaultValue = 0, $desc = "", $sData = Array());
?>
</td>
</tr>

</table>


Expand Down
19 changes: 17 additions & 2 deletions show_on_demand_bg.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
$sodEnabled = $pluginSettings['show_on_demand_enabled'];
$sodEnabled = $sodEnabled == "true" ? true : false;

#Add code to allow selection of a random item from the playlist
$randomItemEnabled = $pluginSettings['random_playlist_item'];
$randomItemEnabled = $randomItemEnabled == "true" ? true : false;

$api_base_path = "https://voip.ms/api/v1";
$oldest_message_age = 180;

Expand Down Expand Up @@ -53,6 +57,9 @@
throw new Exception('No start command specified.');
}

#Add code to print if "random item" is selected
logEntry("Random Item " . $randomItemEnabled);

logEntry("Success message: " . $messageSuccess);
logEntry("Not-started message: " . $messageNotStarted);

Expand Down Expand Up @@ -116,9 +123,17 @@

function startShow(){
global $mainPlaylist;

global $randomItemEnabled;

$url = "http://127.0.0.1/api/command/Insert Playlist Immediate/" . $mainPlaylist ."/0/0/true";
#Code to adjust the API request depending on if random item is selected or not
if ($randomItemEnabled == 1){
$url = "http://127.0.0.1/api/command/Insert Random Item From Playlist/" . $mainPlaylist ."/true";
logEntry("Selecting Random Item from Playlist");
}
else{
$url = "http://127.0.0.1/api/command/Insert Playlist Immediate/" . $mainPlaylist ."/0/0/true";
}

$url = str_replace(' ', '%20', $url);

logEntry("Triggering main playlist: " . $url);
Expand Down