How do I read a XML and create a list with a preview

Get help using Construct 2

Post » Sun Sep 18, 2016 12:50 pm

I store information in array because I do not want to display full path to video..

let's say you have on server something like this..
Image
Image

you can use list.php to get all sub-folders and files in video folder
Code: Select all
<?php
function listFolderFiles($dir){
    $ffs = scandir($dir);
   
    foreach($ffs as $ff){
        if($ff != '.' && $ff != '..'){
           echo $ff. PHP_EOL;
         if(is_dir($dir.'/'.$ff)) listFolderFiles($dir.'/'.$ff);}}}

listFolderFiles('video');
exit;
?>

so..your ajax data will look like this:
Image

now you can loop through data and populate array and list object..

phpDir2List.capx


if you upload a new videos or delete..even sub-folders in videos/video folder..
you do not have to make any changes in php script or C2 code...
Image
B
65
S
23
G
7
Posts: 1,505
Reputation: 10,896

Post » Mon Sep 19, 2016 10:11 am

Thank you for this solution and for all the explanation, @korbaach.

The problem is that is an offline project (CD/DVD). In this demonstration that I'm developing to a possible client, the user will can see a video or image preview and play sounds, clicking in the list items. They intend to use a program that capture the folder content and convert it to the CSV files that contains "name" and "path", like the file that I have included in the example. This is the main reason that I insisting in to use a CSV file.
B
74
S
13
G
4
Posts: 1,000
Reputation: 8,041

Post » Mon Sep 19, 2016 11:41 pm

Up
B
74
S
13
G
4
Posts: 1,000
Reputation: 8,041

Post » Tue Sep 20, 2016 10:21 am

RBuster wrote:Mon Sep 19, 2016 10:11 pm
The problem is that is an offline project ...

RBuster wrote:Sat Sep 17, 2016 9:18 pm
...because is the file that will be updated on the server ...

...mmm...nevermind...
RBuster wrote: CSV files that contains "name" and "path", like the file that I have included in the example.

Your Example:
Videos.csv (one line..)
Image
"path"= \videos\video.mp4
& anime is "name"..of what? ..folder?..sub-folder?
because it certainly is not the name of the video...
Image
you want to show in list anime & Play video.mp4 ??!

..nevermind..

Here's how to separate CSV data..
listCSV.capx
Image
B
65
S
23
G
7
Posts: 1,505
Reputation: 10,896

Post » Tue Sep 20, 2016 10:32 am

korbaach wrote:
RBuster wrote:Mon Sep 19, 2016 10:11 pm
The problem is that is an offline project ...

korbaach wrote:...because is the file that will be updated on the server ...


Sorry about that. I meant: on the folder.

RBuster wrote: CSV files that contains "name" and "path", like the file that I have included in the example.

korbaach wrote:Your Example:
Videos.csv (one line..)
Image
"path"= \videos\video.mp4
& anime is "name"..of what? ..folder?..sub-folder?
because it certainly is not the name of the video...
Image
you want to show in list anime & Play video.mp4 ??!

..nevermind..


Yes, "anime" is just a name. I would like to show "anime" in the list and play video.mp4 or anime.mp4 when the user click in this item.


korbaach wrote:Here's how to separate CSV data..
listCSV.capx


Thanks. I will give it a try.
B
74
S
13
G
4
Posts: 1,000
Reputation: 8,041

Post » Tue Sep 20, 2016 1:04 pm

I have tested but I only can play the list item if the video was imported to to the project files before. Is it right?
B
74
S
13
G
4
Posts: 1,000
Reputation: 8,041

Post » Tue Sep 20, 2016 7:37 pm

RBuster wrote:Is it right?

No.. if you export with NW.js..you can set path to custom folder
Image
B
65
S
23
G
7
Posts: 1,505
Reputation: 10,896

Post » Wed Sep 21, 2016 9:04 pm

korbaach wrote:
RBuster wrote:Is it right?

No.. if you export with NW.js..you can set path to custom folder


Ok. Thank you for all your help @korbaach
B
74
S
13
G
4
Posts: 1,000
Reputation: 8,041

Post » Mon Oct 10, 2016 10:39 am

korbaach wrote:I store information in array because I do not want to display full path to video..

let's say you have on server something like this..
Image
Image

you can use list.php to get all sub-folders and files in video folder
Code: Select all
<?php
function listFolderFiles($dir){
    $ffs = scandir($dir);
   
    foreach($ffs as $ff){
        if($ff != '.' && $ff != '..'){
           echo $ff. PHP_EOL;
         if(is_dir($dir.'/'.$ff)) listFolderFiles($dir.'/'.$ff);}}}

listFolderFiles('video');
exit;
?>

so..your ajax data will look like this:
Image

now you can loop through data and populate array and list object..

phpDir2List.capx


if you upload a new videos or delete..even sub-folders in videos/video folder..
you do not have to make any changes in php script or C2 code...



Hello @korbaach

I'm still stuck in this demo project. I had to give up the CSV because they don't want to include the data in this file manually. I need to read the files in the folder and create a list with these files and show or play a preview when the user select the item in the list. Can I use this kind of solution that you created for this? I know the php only works in the online projects. But I can use other solution than php?

Thanks in advanced
B
74
S
13
G
4
Posts: 1,000
Reputation: 8,041

Previous

Return to How do I....?

Who is online

Users browsing this forum: evillair, vankizzle and 6 guests