Adding volume control for the displays

It’s Open Source. Ultimately you can do whatever you like to your CMS.

A webservice is NOT the way to accomplish live event handling as you describe. You need something that can push commands direct to the Player. I’ve suggested some technologies. I’m afraid I can’t offer you more help than that.

Thank you alex :slight_smile: we will try with the way you suggest

Hi Dan/Alex

We added the sliders in the display page as you said and now we are facing an issue in retrieving the corresponding displayname for the slider.
How can we take the display name for each slider from that table? Could you please help us in this ?

Thank you :smile:

How do you want to take it? In JavaScript or PHP (server side) ?

Thank you Dan :slight_smile: We are trying with PHP.

Hi Dan,
This is the code we have written for adding the volume slider , for getting the volume and its corresponding display. We want to pass these JS variables to the DB. So for that used ajax method to convert the JS variables to PHP. But the value is not getting passed from the Display.class.php.

Below is the code we have written in table_render.php file

 <td><?php if (Theme::Get('volume') == 'DisplayGrid') { ?> 
    		<form name="display_form" method="POST">
    					<input type="hidden" name="display_name" id="display_name"/>
    					<input name="slider" id="<?php echo $icount;?>"  type="range" min="0" max="100" step="10" list="numbers" style="width:150px"  onchange="set_volume(<?php echo $icount;?>)" /> 
    					<span name ="volume" id="span1<?php echo $icount;?>" style="visibility:hidden">0</span>
    					</form>
    					<script type="text/javascript">
    					
    					function set_volume(newvalue)
    					{
    						
    						 var tbl = document.getElementById("table_displays");
    						 if (tbl != null)
    							{
    								var display_name = tbl.rows[newvalue].cells[2].innerHTML;
    								document.getElementById('display_name').innerHTML=tbl.rows[newvalue].cells[2].innerHTML;
    								//alert(display_name);
    								 
    							}
    						//document.getElementById('span1'+newvalue).innerHTML = document.getElementById(newvalue).value;
    						var volume=document.getElementById(newvalue).value;
    						$.ajax({
    								url: 'index.php?p=display',
    								data: {display_named: display_name,
    										volume: volume},
    								type: 'POST',
    								success: function(data)
    								{
    									alert("success!");
    									<?php $disp_name=Theme::Get('disp_name');?>
    									<?php $vol=Theme::Get('vol');?>
    									alert(<?php echo $vol;?>);
    									//update volume_info starts here
    									alert(<?php echo $disp_name;?>);
    									<?php 
    									$dbh = PDOConnect::init();
    									$sth = $dbh->prepare('update `volume_info` set `volume`=:vol where `display` =:display');
    									$sth-execute(array('display'=>$disp_name,'vol'=>$vol));															
    									?>				
    									//update volume_info ends here
    								}
    								});										
    					}					 				
    					</script> 
    					<?php $icount++; ?>
    </td>

Now the corresponding code we have written in display.class.php is below

                $display_name= $_POST['display_named']; 
		$volume1=$_POST['volume'];		
		Theme::Set('disp_name',$display_name);
		Theme::Set('vol',$volume1);

Could you please help me with this ?

someone please help :’(

Seriously?! You waited 2 hours then bumped your thread because nobody did your development work for you?! :imp:

Hi Alex, I was trying to get it solved by myself. Unfortunately I couldn’t, so I asked again. Sorry if it was a wrong post .

All I’m saying is that you’re developing something, which we’ve said isn’t generally useful to the project in our opinion (because it doesn’t really fit with the project goals due to the way you want to implement it).

If and when Dan has time to help you out with your project then I’m sure he will do, but you have to appreciate that it’s not a priority for us because it’s of no benefit to the project, so waiting 2 hours before grumbling because nobody told you how to write some software you’re developing isn’t really on in my opinion.

Of course Alex, I too want to implement it in some other method but presently, this is the only way I’m having for implementing this feature. Sorry if I was wasting your time.

You’re not wasting anyones time. All I’m asking for is a little understanding and patience from you. We simply don’t have the resources to help everyone within a few minutes of them posting - especially when the question is about writing custom code which will take time to understand before any reasonable feedback can be given.

Ok Alex, I will definitely wait and at the same time I will try from my end. If I get any other way, I will share it in the forum. Thank you for your support.

1 Like

Thanks for your understanding :smile:

1 Like

I think you have misunderstood how JavaScript and PHP interact with each other, JavaScript is client side and PHP is server side, you cannot have an UPDATE statement or any PHP in your JavaScript success callback.

You need to have the client read the values from your slider and send them to the server. The server then updates them and responds with a success or failure.

In your client side javascript code you could have something like this:

$.ajax({
  url: 'index.php?p=display&q=UpdateVolume',
  data: {displayId: displayId, volume: volume},
  type: 'POST'
);

q=UpdateVolume is important because it will map to your displayDAO controller class method name. So in PHP you would have something like this in the displayDAO class:

function UpdateVolume()
{
   try {
      $dbh = PDOConnect::init();
      $sth = $dbh->prepare('UPDATE `display` SET volume = :volume WHERE displayId = :id');
      $sth->exec(['id' => $_POST['displayId'], 'volume' => $_POST['volume']);
   }
   catch (PDOException $e) {
       header('HTTP/1.1 500 Internal Server Error');
       die(json_encode(['error' => true, 'message' => $e->getMessage()]);
   }
}

Obviously you’d have to do the appropriate sanitization and validate your volume figure was correct. I’d also recommend catching the error condition in your JavaScript handler.

Hi Dan

Thanks a lot for your help :slight_smile: . But still when I tried doing like this I get a blank white screen page on click of display menu while opening in chrome and I get an error stating “HTTP 500 Internal Server Error” while opening in IE. Could please help with this issue ?

Hi Dan,

Now we are able to update the volume when we changed the code like this.

    function UpdateVolume()
    	{
    	
     		 try {
    			 $dbh = PDOConnect::init();
    			$sth = $dbh->prepare('UPDATE `volume_info` SET volume = :volume WHERE display = :id');
    			$id = $_POST['displayId'];
                $volume = $_POST['volume'];			
    			$sth->execute(array(
                        'id' => $id,
                        'volume' => $volume
                    ));
    				
    			}
    		 catch (PDOException $e) {
    			header('HTTP/1.1 500 Internal Server Error');
    		}    
    
    	}

Thanks for your support :smile:

No problem :smiley: I am pleased you have it working!

Coming in here late but here is my suggestion for controlling volume at the player. I currently run a 100 location network in veterinary hospitals. We started in 2004 on Scala but are in the process of migrating to Xibo. One of the things we offer our clients is the ability to run music through Winamp. So music is streaming while the video is playing. The problem is when we have a video with its own audio in the playlist then we need to turn down Winamp until after the AV file plays, then turn it back up. We do this using a small VBS script and it works. We need to figure out how to keep this functionality as we migrate to Xibo.

Scala has a feature on Media Items that support audio called “Audio Ducking”. If enabled, it pauses the main audio and plays the audio from the Media Item. When the Media Item finishes it resumes playback of the main audio. The “main audio” is specified using a special audio-only playlist (Scala’s “Playlist” is roughly equivalent to a Xibo “Layout”).

If the Xibo team were to accomplish something like this, I’d be delighted as the Audio Ducking feature of Scala is one of a few that I’d sorely miss.

In the meantime, we’ll likely follow suit with the post above, using a player like WinAMP and turning it down/up via a Xibo Shell Command before/after videos that contain audio. Not optimal, but workable.