0

CSV playlist with Custom Script

Hi Scripters,

i need some help with this project i'm building.

i'm working on a smartphone App for remote control.
I'll try to explain what the app can do and what i'm going to implements.

  • open and search by UDP all BrightSign (with my custom autorun). WORKS
  • get files (in SD:/CONTENT/). WORKS
  • Play, Loop, Stop, Pause files. WORKS
  • Change ViewMode and save in file for future power on. WORKS
  • playlist MISSING

i'd like to send by http (i can do it) a csv file and save on storage at a certain location, in order to save the playlist.

the .csv file i like to be in this format:
<fileType>;<fileName>;<Duration>

my pseudocode is this:
file = readAsciiFile()
commandRows = file.tokenize("\n") --> here i will have an array of rows
for each row in commandRows
     fields = row.tokenize(";") --> here i will have an array of fields [fileType,fileName,Duration]
     if fields[0] = "IMAGE" then
          DisplayImage(fields[1])
          sleep(fields[2]) --> this interrupt other input events
     else
          playFile(fields[1])
          wait for "end of file" --> can't imagine how to implement...
next
send("END PLAYLIST")

 

that's it.

if someone have another solution, i'll be very happy to try it.

thanks, Luca

5 comments

  • 0
    Avatar
    Lyndon

     

    I'm not sure what you're asking for help with. Does your script have a list command to return a list of files on the storage? 

    Or, are you trying to send a list to the player?

  • 0
    Avatar
    Luca Ceccato

    Hi Lyndon,

    on my storage I have a folder with all my images, video or audio.

    My autorun.brs is a modified version of the script found here: https://brightsign.zendesk.com/hc/en-us/articles/218066697-How-do-I-control-the-BrightSign-using-serial-or-UDP-Crestron-AMX-smartphones-tablets-etc- 
    I added a Node.js server and some functions taken from the default autorun.brs

     

    my idea is to create a .csv file (formatted like above) and save in the storage in main path (storage/SD:) 

    the player script, once i send "Play Playlist <filename.csv>" command (via HTTP, I learned how to handle it), will read the file and start playing files, meanwhile listen other possibles commands (via udp or HTTP)

  • 0
    Avatar
    Lyndon

     

    I don't have a simple csv parser function handy.  What part of the parser have you already built out? have you already added the ability to your script to add timers so you can exit playback when your duration expires?

  • 0
    Avatar
    Luca Ceccato

    What part of the parser have you already built out?
    My parser can divide the file into rows and each row in "fields"
    how? --> split the file_content_string by '\n' for obtaining row
              --> split the row by ';' for obtaining fields

    have you already added the ability to your script to add timers?
    I think my script already has it.
    at the and of play, the player send me a udp message "ENDP" indicates that the file is finished.

     

    in the script i found an unused PLAYFILES() that play all files in a directory, but it stops the Events Handler, so i cannot send commands until the PlayFiles() is terminated

     

    i need to run this PlayFiles() and also keep the player on listening events... i've no idea how to implements this!

  • 0
    Avatar
    Luca Ceccato

    UPDATE!

    I simplified the .cvs file for debugging. (tested and working for now)

    I created a VIDEO ONLY playlist. the .csv file contains only video file name like:
       video1.mp4
       video2.mov
       video3.ts

    i create global variables Playlist = roList, PlayListIndex = integer

    my brightscript function reads the file and store it into a "roList"
    then i Play immediately the file in position 0 (the first playlist's file)

    now, when the video is ended, the player catch a "roVideoEvent" with code 8
    here. 
    if the PlayListIndex = Playlist.count(), the playlist is finished, otherwise i increment the index and play the next video

     

    for now, my Playlist Controller works. only for videos.

     

    the next target is add images (with timeToDisplay) to playlist

Please sign in to leave a comment.