-
-
Notifications
You must be signed in to change notification settings - Fork 227
Technical Overview of LibreTime under the hood
Robb edited this page Nov 29, 2017
·
3 revisions
This is a rough outline of LibreTime and documentation of how the application functions - anyone is welcome to edit it with details from a walkthrough of the code but it will be lacking breadth until this happens for most parts
How playlists are added to shows
- Via UI ->
- an Ajax call is sent to the ShowBuilder controller w/ json containing $mediaItems listing what is to be added and $scheduleItems the existing file it should schedule after
- scheduleAddAction is called defined via addActionContext ('schedule-add')
- a new Schedule is instanced and scheduleAfter is called w/ the item parameters from above $adjustSched is set to true by default and is always true in all uses in the codebase (yet is still passed)
- insertAfter runs in the schedule - the filesToInsert parameter is always null (unless being called by moveItem w/ uses it) and this is explicitly cleared unless the $moveAction parameter is also called ) this results in a forLoop retrieiving the mediaItems with retrieveMediaFiles
- retrieveMediaFiles - branches based upon 4 types (audioclip, playlist, stream, and block)
- for playlists A new playlist object is constructed based upon the id and getContents is ran
- getContents is a gnarly SQL query that results in an array of Rows gets the entire playlist as a two dimensional array, sorted in order of play.
- If it's type 2 item it's a block and then it looks through the content (if it's static otherwise it pulls dynamic files which pulls getListOfFilesUnderLimit
- GetListOfFilesUnderLimit -> first gets a list of files that meet the criteria which creates a PropelOnDemandCollection based upon a SQL query determined by the Criteria set the list of files under limit is added to an InsertList until the algorithm criteria for the block being full is finished.
- Types - stored in the Type field in the database - type 0 is a playlist with only media files
Library
The library shows "all" of the files in the database.
- It uses a javascript library called datatables and we are currently dependent upon a legacy version that has been customized by previous developers. Most of the custom library code is in the js/airtime/library/library.js file.
- It does a ajax query to Library/contents-feed which is part of the LibraryController.
- This calls the searchLibraryFiles function on the StoredFile object and does some query building it calls DataTables.findEntries
- findEntries adds the WHERE clause to the query with the AdvSearch and cycles through the terms and returns an array of matching tracks.