MainLoaderTask.brs (1585B)
1 '******************************************************************** 2 '** Home Media Server Application - MainLoaderTask 3 '** Copyright (c) 2022 Brian C. Lane All Rights Reserved. 4 '******************************************************************** 5 sub Init() 6 print "MainLoaderTask->Init()" 7 8 m.top.functionName = "GetContent" 9 end sub 10 11 ' GetContent is executed when m.contentTask.control = "run" from MainScene 12 sub GetContent() 13 print "MainLoaderTask->GetContent()" 14 print m.top.serverurl 15 16 m.top.categories = getSortedCategoryTitles(m.top.serverurl) 17 end sub 18 19 '****************************************************** 20 ' Return a roArray of just the category names 21 '****************************************************** 22 Function catTitles(categories As Object) As Object 23 titles = CreateObject("roArray", categories.Count(), false) 24 for i = 0 to categories.Count()-1 25 titles.Push(getLastElement(categories[i][0])) 26 end for 27 return titles 28 End Function 29 30 '****************************************************** 31 '** Get a sorted roArray of category titles 32 '****************************************************** 33 Function getSortedCategoryTitles(url as String) As Object 34 ' Build list of Category Names from the top level directories 35 listing = getDirectoryListing(url) 36 if listing = invalid then 37 return invalid 38 end if 39 categories = displayFiles(listing, {}, true) 40 Sort(categories, function(k) 41 return LCase(k[0]) 42 end function) 43 return catTitles(categories) 44 End Function