How to Read Playlist dynamically from PHP Web Service

This tutorial will show you how to read play list dynamically from PHP web service. This feature is only available after Version 2.8.

Tasks

  1. Generate play list from PHP web service
  2. Connect HTML5 Gallery to the PHP web service

Step 1 - Set up PHP web service

In the PHP web service, you need to create an array of slides, then use json_encode to output the result to client side. A demo is as following:

<?php
    	// The play list can be dynamically created from database or whatever you like. 
    	$playlist = array(
    		array(
  			"thumbnail" => "http://html5box.com/html5gallery/images/Evening_256.jpg",
  			"file" => "http://html5box.com/html5gallery/images/Evening_1024.jpg",
  			"title" => "Evening",
  			"link" => "http://html5box.com",
  			"linktarget" => "_blank"
    		),
    		array(
  			"thumbnail" => "http://html5box.com/html5gallery/images/Big_Buck_Bunny_1.jpg",
  			"file" => "http://html5box.com/html5gallery/images/Big_Buck_Bunny_1.m4v",
  			"title" => "Big Buck Bunny"
    		),
    		array(
  			"thumbnail" => "http://img.youtube.com/vi/YE7VzlLtp-4/2.jpg",
  			"file" => "http://www.youtube.com/embed/YE7VzlLtp-4",
  			"title" => "Big Buck Bunny - YouTube"
    		),
    		array(
  			"thumbnail" => "http://html5box.com/html5gallery/images/Big_Buck_Bunny_3.jpg",
  			"file" => "https://player.vimeo.com/video/1084537?title=0&amp;byline=0&amp;portrait=0",
  			"title" => "Big Buck Bunny - Vimeo"
    		)
    	);
    	echo json_encode($playlist);
?>

Step 2 - Connect HTML5 Gallery to PHP web service

To connect HTML5 Gallery to the PHP service, you only need to add a data tag data-remote="PHP_SERVICE_ADDRESS", then it's done.

<div class="html5gallery" data-skin="gallery" data-width="480" data-height="270" data-remote="playlist.php"  style="display:none;">
</div>