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 subfolder play #1175

Open
wants to merge 7 commits into
base: develop
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
39 changes: 39 additions & 0 deletions htdocs/api/playlist/foldershuffle.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php
namespace JukeBox\Api;

/**
* Enables or disabled shuffle for a playlist.
*/
include('../common.php');

if ($_SERVER['REQUEST_METHOD'] === 'PUT') {
$body = file_get_contents('php://input');
$json = json_decode(trim($body), TRUE);
if (validateRequest($json)) {
$playlist = $json['playlist'];
$foldershuffle = $json['foldershuffle'];
if ($foldershuffle === 'true') {
execScript("shuffle_folder.sh -c=enableshuffle -d='{$playlist}'");
} else {
execScript("shuffle_folder.sh -c=disableshuffle -d='{$playlist}'");
}
}
} else {
http_response_code(405);
}


function validateRequest($json) {
if ($json['playlist'] == null) {
http_response_code(400);
echo "playlist attribute missing";
return false;
} else if ($json['foldershuffle'] == null) {
http_response_code(400);
echo "foldershuffle attribute missing";
return false;
}
return true;
}

?>
39 changes: 39 additions & 0 deletions htdocs/api/playlist/foldersingle.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php
namespace JukeBox\Api;

/**
* Enables or disabled single folder play.
*/
include('../common.php');

if ($_SERVER['REQUEST_METHOD'] === 'PUT') {
$body = file_get_contents('php://input');
$json = json_decode(trim($body), TRUE);
if (validateRequest($json)) {
$playlist = $json['playlist'];
$foldersingle = $json['foldersingle'];
if ($foldersingle === 'true') {
execScript("shuffle_folder.sh -c=enablesinglefolder -d='{$playlist}'");
} else {
execScript("shuffle_folder.sh -c=disablesinglefolder -d='{$playlist}'");
}
}
} else {
http_response_code(405);
}


function validateRequest($json) {
if ($json['playlist'] == null) {
http_response_code(400);
echo "playlist attribute missing";
return false;
} else if ($json['foldersingle'] == null) {
http_response_code(400);
echo "foldersingle attribute missing";
return false;
}
return true;
}

?>
39 changes: 39 additions & 0 deletions htdocs/api/playlist/folderskip.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php
namespace JukeBox\Api;

/**
* Enables or disabled shuffle for a playlist.
*/
include('../common.php');

if ($_SERVER['REQUEST_METHOD'] === 'PUT') {
$body = file_get_contents('php://input');
$json = json_decode(trim($body), TRUE);
if (validateRequest($json)) {
$playlist = $json['playlist'];
$folderskip = $json['folderskip'];
if ($folderskip === 'true') {
execScript("shuffle_folder.sh -c=enableskipfolder -d='{$playlist}'");
} else {
execScript("shuffle_folder.sh -c=disableskipfolder -d='{$playlist}'");
}
}
} else {
http_response_code(405);
}


function validateRequest($json) {
if ($json['playlist'] == null) {
http_response_code(400);
echo "playlist attribute missing";
return false;
} else if ($json['folderskip'] == null) {
http_response_code(400);
echo "folderskip attribute missing";
return false;
}
return true;
}

?>
50 changes: 49 additions & 1 deletion htdocs/func.php
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,55 @@ function index_folders_print($item, $key)
* settings buttons
*/
// we show the buttons only if there are actual audio files in the folder
if($contentTree[$key]['count_audioFiles'] == 0) {
if($contentTree[$key]['count_subdirs'] > 0) {
print "\n <div><!-- folder settings buttons -->";
// FOLDER SHUFFLE BUTTON
$foundFolderShuffle = "OFF";
if(
file_exists($contentTree[$key]['path_abs']."/folder.conf")
&& strpos(file_get_contents($contentTree[$key]['path_abs']."/folder.conf"),'FOLDERSHUFFLE="ON"') !== false
) {
$foundFolderShuffle = "ON";
}
if( $foundFolderShuffle == "OFF" ) {
// do stuff
print "<a playlist=\"$playlist\" foldershuffle='false' onclick='toggleFoldershuffle(this);' class='btn btn-warning '>".$lang['globalFoldershuffle'].": ".$lang['globalOff']." <i class='mdi mdi-toggle-switch-off-outline' aria-hidden='true'></i></a> ";
} elseif($foundFolderShuffle == "ON") {
print "<a playlist=\"$playlist\" foldershuffle='true' onclick='toggleFoldershuffle(this);' class='btn btn-success '>".$lang['globalFoldershuffle'].": ".$lang['globalOn']." <i class='mdi mdi-toggle-switch' aria-hidden='true'></i></a> ";
}

// FOLDER SINGLE BUTTON
$foundFolderSingle = "OFF";
if(
file_exists($contentTree[$key]['path_abs']."/folder.conf")
&& strpos(file_get_contents($contentTree[$key]['path_abs']."/folder.conf"),'FOLDERSINGLE="ON"') !== false
) {
$foundFolderSingle = "ON";
}
if( $foundFolderSingle == "OFF" ) {
// do stuff
print "<a playlist=\"$playlist\" foldersingle='false' onclick='toggleFoldersingle(this);' class='btn btn-warning '>".$lang['globalFoldersingle'].": ".$lang['globalOff']." <i class='mdi mdi-toggle-switch-off-outline' aria-hidden='true'></i></a> ";
} elseif($foundFolderSingle == "ON") {
print "<a playlist=\"$playlist\" foldersingle='true' onclick='toggleFoldersingle(this);' class='btn btn-success '>".$lang['globalFoldersingle'].": ".$lang['globalOn']." <i class='mdi mdi-toggle-switch' aria-hidden='true'></i></a> ";
}

// FOLDER SKIP BUTTON
$foundFolderSkip = "OFF";
if(
file_exists($contentTree[$key]['path_abs']."/folder.conf")
&& strpos(file_get_contents($contentTree[$key]['path_abs']."/folder.conf"),'FOLDERSKIP="ON"') !== false
) {
$foundFolderSkip = "ON";
}
if( $foundFolderSkip == "OFF" ) {
// do stuff
print "<a playlist=\"$playlist\" folderskip='false' onclick='toggleFolderskip(this);' class='btn btn-warning '>".$lang['globalFolderskip'].": ".$lang['globalOff']." <i class='mdi mdi-toggle-switch-off-outline' aria-hidden='true'></i></a> ";
} elseif($foundFolderSkip == "ON") {
print "<a playlist=\"$playlist\" folderskip='true' onclick='toggleFolderskip(this);' class='btn btn-success '>".$lang['globalFolderskip'].": ".$lang['globalOn']." <i class='mdi mdi-toggle-switch' aria-hidden='true'></i></a> ";
}

print "
</div><!-- / folder settings buttons -->";
} else {
print "\n <div><!-- settings buttons -->";
// RESUME BUTTON
Expand Down
1 change: 1 addition & 0 deletions htdocs/inc.header.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
"DEBUG_rfid_trigger_play_sh",
"DEBUG_shuffle_play_sh",
"DEBUG_single_play_sh",
"DEBUG_shuffle_folder_sh",
);
$debugOptions = array("TRUE", "FALSE");

Expand Down
132 changes: 132 additions & 0 deletions htdocs/index_limited.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
<?php

include("inc.header.php");

/*******************************************
* START HTML
*******************************************/

html_bootstrap3_createHeader("en","Phoniebox",$conf['base_url']);

?>
<style>
.filterDiv {
display: none;
}

.filtershow {
display: block;
}

.filtercontainer {
margin-top: 20px;
overflow: hidden;
}

/* Style the buttons */
.filterbtn {
border: none;
outline: none;
padding: 12px 16px;
margin-bottom: 3px;
background-color: #464545;
color: white;
cursor: pointer;
border-top-right-radius: 4px;
border-top-left-radius: 4px;
border-bottom-right-radius: 4px;
border-bottom-left-radius: 4px;
}

.filterbtn:hover {
background-color: #f1f1f1;
color: black;
}

.filterbtn.active {
background-color: #0ce3ac;
color: white;
}
</style>
<body>
<div class="container">

<?php
//include("inc.navigation.php");

if($debug == "true") {
print "<pre>";
print "_POST: \n";
print_r($_POST);
print "</pre>";
}

?>

<div class="row playerControls">
<div class="col-lg-12">
<?php
/*
* Do we need to voice a warning here?
*/
if(isset($warning)) {
print '<div class="alert alert-warning">'.$warning.'</div>';
}
print '<div id="api-alert" class="alert alert-warning" style="display: none"></div>';
include("inc.controlPlayer.php");
?>
</div><!-- / .col-lg-12 -->
</div><!-- /.row -->
<?php
// show currently played track

print '
<div class="row">
<div class="col-lg-12">';
include("inc.loadedPlaylist.php");
print '
</div><!-- / .col-lg-12 -->
</div><!-- /.row -->';
?>
<div class="row">
<div class="col-lg-12">
<?php
include("inc.setVolume.php");
?>
</div><!-- ./col-lg-12 -->
</div><!-- ./row -->

<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title" id="myModalLabel"><?php print $lang['globalLastUsedCard']; ?></h4>
</div>
<div class="modal-body">
<pre>
<!--?php
print file_get_contents($conf['base_path'].'/shared/latestID.txt', true);
?-->
</pre>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal"><!--?php print $lang['globalClose']; ?--></button>
</div>

</div><!-- / .modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->


</div><!-- /.container -->

</body>

<script src="js/jukebox.js">
</script>
<script>
JUKEBOX.lang = <?php echo json_encode($lang );?>
</script>
</html>
12 changes: 12 additions & 0 deletions htdocs/js/jukebox.js
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,18 @@ function toggleShuffle(element) {
togglePlaylistCommand(element, 'shuffle')
}

function toggleFoldershuffle(element) {
togglePlaylistCommand(element, 'foldershuffle')
}

function toggleFoldersingle(element) {
togglePlaylistCommand(element, 'foldersingle')
}

function toggleFolderskip(element) {
togglePlaylistCommand(element, 'folderskip')
}

function toggleResume(element) {
console.log("toggle resume");
console.log(element);
Expand Down
3 changes: 3 additions & 0 deletions htdocs/lang/lang-de-DE.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@
$lang['globalRelease'] = "Release";
$lang['globalStorage'] = "Speicher";
$lang['globalShuffle'] = "Mischen";
$lang['globalFoldershuffle'] = "Unterverzeichnisse Mischen";
$lang['globalFoldersingle'] = "Single Unterverzeichnisse";
$lang['globalFolderskip'] = "Unterverzeichnisse Wechseln";
$lang['globalReplay'] = "Wiederholung";
$lang['globalRepeat'] = "Wiederholen";
$lang['globalLoop'] = "Schleife";
Expand Down
3 changes: 3 additions & 0 deletions htdocs/lang/lang-en-UK.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@
$lang['globalRelease'] = "Release";
$lang['globalStorage'] = "Storage";
$lang['globalShuffle'] = "Shuffle";
$lang['globalFoldershuffle'] = "Shuffle subfolders";
$lang['globalFoldersingle'] = "Single subfolders";
$lang['globalFolderskip'] = "Skip subfolders";
$lang['globalReplay'] = "Replay";
$lang['globalRepeat'] = "Repeat";
$lang['globalLoop'] = "Loop";
Expand Down
Loading