Playlists: Jingles or Spots every xx items UPDATED! New functionality!!!
  • ****Always keep backup of your files before you use the files i attached!! Everything needs testing! Try everything with your responsibility. Have in mind that since you are inserting values in the database, if you use your old pages in the future again then you may experience problems in library (you will need then to delete the records from the db that are inserted from this hack).. you can find a quick n' dirty solution to this HERE****

    UPDATED 16/12/2015 - After the first "version" of this, Many people asked for different things in private messages so i tried to implement most of them and since there are many many changes from the previous version, i desided to give directly the files (since i cleaned everything and started over again to be able to do that).
    Please read EVERYTHING below BEFORE you use the files since there are things that you might need to change to suit you.
    Do your tests in a new block and not an existing one before you make sure that everything works OK!
    Its better if you dont test it in a production environment. After all everything is under development and functionality could change with your feedback.
    Also have in mind that everything is done on airtime 2.5.1 i dont know if this works on other versions (like 2.5.2)
    I have done some bug fixes (some experienced grey window on criteria because of missing Logo, Jingle, Spot files) after i uploaded the files but for some reason i cant delete the old files to upload the new one. Check this post until the end and you will find everything you need

    Features:

    You have Logo, Jingles and Spots
    Logo is the logo of the station (a sound file with the name of the station etc)
    If you take a look at the screenshot, you have the ability to :
    1) You can choose to play the logo at the very start of the block. Logo plays before anything else
    2) You can choose to play the logo every xx items
    3) You can choose either to use one random jingle or all jingles that have a genre that you will choose from a list. This list takes all genres that contain the word Logo. If you choose a random jingle that means than whenever jingles are about to play (according to your settings) only one random jingle will play instead of all.
    4) You can choose if you want jingles at start (always after Logo IF logo is also selected to play at start)
    5) You can choose to play Jingles (or random Jingle) every xx items
    6) You can choose if you want spots at start (always after Jingles IF Jingles are also selected to play at start)
    7) You can choose to play Spots every xx items
    8) You can choose to play the logo after each time jingles (all of them or the random) play
    9) You can choose to play the logo after each time spots (all of them) play

    Since you have the possibility to choose per block the logo, jingle and spot files according to the genre as i describe above, you can have different logo (or even more than one if that is for some reason needed), jingles and spots per show so you can have the power to personalize your shows ... for example in one show called "The Rock Show" (stupid random name) you can choose the genre "Logo" to get the generic logos or you could have "LogoRock" as genre and you could choose that specific logo (or logos) for that show. In that way for example you could say that you would like to have another Logo not only with the name of your station but with the name of that show.
    Also in the same way you could have specific Jingles (for example with genre JingleRock) or even specific Spots so the commercial stations could have other spots every xx items in a show. 

    There are limitations and i am not quite sure how this goes with multiple shows and with many categories of Jingles.. for example if you have files with genre Jingle and a show that choose those files for Jingles and have also files with genre JingleRock, most probably the first show will choose ALSO the JingleRock files since it contains the word Jingle
    To avoid that if this doesnt suit you then you have to change the file Block.php and change the functions getAllLogos, getAllJingles and getAllSpots and change the query not to say WHERE genre like '%$param%' but to say WHERE genre = '$param' so you get the exact files.

    I would really like your opinion on this on what is the best way to do this. What are your needs and your thoughts.

    Also beside the files, just for things to be pretty you can change the following css class in the file styles.css in /usr/share/airtime/public/css
    .sp_text_font{    font-size: 13px;    font-family: Helvetica, Arial, sans-serif;    color: #5B5B5B;    width: 200px;    display: -webkit-inline-box;}
    The final result in the screenshot.

    You will find the files in (ubuntu):
    Block.php -> /usr/share/airtime/application/models/SmartBlockCriteria.php -> /usr/share/airtime/application/formssmart-block-criteria.phtml -> /usr/share/airtime/application/views/scripts/form
    I have the smart-block-criteria.phtml as rar file in order to be able to attach it. Unrar it first :)

    If you experience any issues (like grey window instead of the smart block criteria window) then please take a look at this post:
    https://forum.sourcefabric.org/discussion/comment/33674#Comment_33674


    Post edited by Stathis Simos at 2015-12-18 07:38:34
  • 30 Comments sorted by
  • Not giving code anymore since i have the files attached in the first post...
    Post edited by Stathis Simos at 2015-12-15 18:55:41
  • Not giving code anymore since i have the files attached in the first post...
    Post edited by Stathis Simos at 2015-12-15 18:55:47
  • Not giving code anymore since i have the files attached in the first post...
    Post edited by Stathis Simos at 2015-12-15 18:55:52
  • Not giving code anymore since i have the files attached in the first post...
    Post edited by Stathis Simos at 2015-12-15 18:55:57
  • Not giving code anymore since i have the files attached in the first post...
    Post edited by Stathis Simos at 2015-12-15 18:56:10
  • Not giving code anymore since i have the files attached in the first post...
    610 x 534 - 52K
    Post edited by Stathis Simos at 2015-12-15 18:56:18
  • Not giving code anymore since i have the files attached in the first post...
    Post edited by Stathis Simos at 2015-12-15 18:56:51
  • Not giving code anymore since i have the files attached in the first post...
    Post edited by Stathis Simos at 2015-12-15 18:56:56
  • Vote Up0Vote Down hoerichhoerich
    Posts: 627Member, Airtime Moderator
    awesome work!
    Official Airtime Forum Manager
    --------------------------
    Most of the time an issue is located between keyboard and chair.
  • Find the updated files in first post with many new things! (you can call it version 2)

    Please read all the first post before doing any changes and also please give me your opinions on the matter for Logos,Jingles,Spots that i raise in the first post...

    To sum up, what i need your opinion (in order to make this better) is:
    Right now to make Logo,Jingles and Spots more "dynamic" per show, i am using the genre field.
    When you create a block you can choose from a dropdown specific files.
    For example for Jingles, this dropdown will be filled with all files that have genre that contains the word Jingle and will show all the distinct genre values for you to choose, so if you have two files with genre JingleNews and two files with genre JingleRock then within a show you can choose for Jingles those with JingleRock genre (ofcource you can just have everything with genre Jingle and choose them everywhere if that suits you).

    The issues with this approach is:
    1) we cant choose multiple Jingle categories for a show
    2) we cant have a Jingle with a genre with multiple words inside
    3) If you have a file with genre Jingle and another with genre JingleRock and then have a show that you choose to get all the files with genre "Jingle" then it will get both files because the code looks if the word is CONTAINED (so the word Jingle is contained to both files).

    I know this isnt the best approach and i have many ideas about this but i think its better to hear your opinions because after all this isnt for me (i have everything in my server like i want it) :)
    Post edited by Stathis Simos at 2015-12-16 04:43:15
  • The only thing i noticed as a bug since i am doing my tests is that if there is no file with the word Jingle in genre and the option random jingle is checked then you could experience a crash (gray window instead of criteria window in Library).
    To avoid this in file Block.php

    1) delete the:

    if (isset($storedCrit['jinglesRandom'])) {
                    $jinglesListNew = array_rand($jinglesList, 1);
                } else {
                    $jinglesListNew = $jinglesList;
                }

    Its not needed and you will find it in two places (before while and inside while in function getListOfFilesUnderLimit

    2) Change the line  
    if ($storedCrit['jinglesRandom']['value'] == 1) { 
    to  
    if ($storedCrit['jinglesRandom']['value'] == 1 && count($jinglesList)>0) {

    You will also find this line twice in the same function.

    This way if you dont have any Jingles the option for the random jingle will be ignored.
    Post edited by Stathis Simos at 2015-12-17 20:37:40
  • Also one other thing (and this isnt only for this "hack" but generic)
    An issue with Airtime if that if you have a new criteria and you insert a value for it in database for a specific block, then if you remove those criteria (for example you desided to go back yo your original backup files) then editing or using this block will result in a "nice" grey window since Block.php will crash inside function getCriteria (it will try to get and use criteria from the db that are no longer supported from the code)

    To avoid this a quick solution is to simply add a try/catch inside the for each loop in getCriteria function
    to do this ABOVE the line 
    if ($criteria == "limit") {
    put the line
    try {

    Also BELOW this code:
    } else {
                    $storedCrit["crit"][$criteria][] = array(
                        "criteria"=>$criteria,
                        "value"=>$value,
                        "modifier"=>$modifier,
                        "extra"=>$extra,
                        "display_name"=>$criteriaOptions[$criteria],
                        "display_modifier"=>$modifierOptions[$modifier]);
                }

    and before the next }
    put the code

    } catch (Exception $e) {
                            Logging::info($e);
    }

    So it will look something like


        try {

                if ($criteria == "limit") {
                    $storedCrit["limit"] = array(
    .....
    .....
    .....
        } else {
                    $storedCrit["crit"][$criteria][] = array(
                        "criteria"=>$criteria,
                        "value"=>$value,
                        "modifier"=>$modifier,
                        "extra"=>$extra,
                        "display_name"=>$criteriaOptions[$criteria],
                        "display_modifier"=>$modifierOptions[$modifier]);
                }

                } catch (Exception $e) {
                            Logging::info($e);
                }

            }

            return $storedCrit;

    This way you will be able to do your experiments with no much fear.
    Post edited by Stathis Simos at 2015-12-17 20:40:03
  • First of all, thank you for the hack and helping me to get it working and adding the code for a single random jingle. i tested it on airtime 2.5.1 and 2.5.2.1 and both seem to work with static and dynamic blocks and linked shows, so this really works for me and 1 step closer to running our station on airtime :-) 

    Note: the hack works, only you do need a jingle, a spot and a logo file in your library to get it working or follow this link in this discussion https://forum.sourcefabric.org/discussion/comment/33674#Comment_33674

    so this also happens with logos and spots, when i added the files with genre: Logo and Spot i worked like a charm. I allready had jingle files in the library.  

    This would a be great  feature for airtime. Thanks again Stathis
    Post edited by René Ooms at 2015-12-18 14:59:17
  • Cheers from Greece :) I am glad you got it working and everything is OK :)

    Now for the rest, if a moderator could help me to delete the files and upload new ones in the first post then i would upload the files directly with the fix, but i imagine its not so hard to do it if you refer coment 33674.
  • Thanks Simon, works fine.

    Only by Dynamic goes somthing wrong, plays 10 Jingles and play on Track after that again 10 Jingles.
    Static work very fine for me....

    Is there also a solution for exact every hour play Spot or Logo.... like news or somthing like that.
    Or when your have a evening show than plays only the Jingle "Good evening" and the Morning "Good morning.




    Post edited by Costa Blanca FM at 2015-12-21 08:02:00
  • It plays all your jingles because you probably didnt check the "random jingle only" checkbox.

    The "by the hour" is more complicated since a show can start at any time and have any duration but i will look at it

    Also how do you imagine this? what about if at 17:59 starts a new song that ends at 18:06 ? what should happen at 18:00? should the song stop and "news" start?*** should the news play at 18:06?

    ***by the way the first one, exactly "by the hour" and over the song (song silenced) can be done from liquidsoap also...

    Post edited by Stathis Simos at 2015-12-21 09:31:48
  • By the way i just saw a mistake in the file SmartBlockCriteria.php that i cant change in the files that i attached (since as i said i CANT delete them and add new ones)

    in the function getSpotsOptions
    the lines 
    if(!isset($this->spotOptions)){
                            $this->spotOptions = array(

    should be
    if(!isset($this->spotsOptions)){
                            $this->spotsOptions = array(

    (missing one s from word spotOptions)
    This wont cause any problems if at least one file with genre Spot (capital S) is there but if not you will get a grey window so pleas change this :)

    Also a mistake is that right now the way the code is you need to have the upper letter in genre for Logos/Jingles/Spots in Capital, so a file with genre jingle wont work as a jingle but a file with genre Jingle (capital J) will.
    The solution is simple and it is the code to transform everything in capital. 
    There is no point of giving fixed code again and again so if no admin can help me to delete the old files and upload the new ones then i will reupload them the next couple of days..

    Post edited by Stathis Simos at 2015-12-21 17:48:43
  • Also how do you imagine this? what about if at 17:59 starts a new song that ends at 18:06 ? what should happen at 18:00? should the song stop and "news" start?*** should the news play at 18:06?


    On this moment i use another software on a diverend server, this software calculate exact how long is a show and do so precisely to the end, when  the track is 10 seconds longer he fade out and starts News or Spot. 

    Another thing when you can make a choice by time, some Jingles play only in
    the evening or day.... in that case it would be easy to set a time, maby perhaps for the future.....

    ***by the way the first one, exactly "by the hour" and over the song (song silenced) can be done from liquidsoap also...

    When is posible to make this in the Hack Airtime become what it should be......




    Post edited by Costa Blanca FM at 2015-12-21 19:45:34
  • when  the track is 10 seconds longer he fade out and starts News or Spot.  

    Well there is no way to do that right now (this can easily be done with liquidsoap by the way there are a lot of scripts for exactly what you say) BUT what i did yesterday is the "news by the hour" like that:
    1) You choose for a block if you enable news or not.
    2) If news are enabled for this show then you choose if you want news at the beginning of the show (that isnt always desirable since you might want news every xx:30)
    3) You choose at what minute of each hour you want the news (for example 0 for 17:00, 18:00 etc or 30 for 17:30, 18:30 etc)
    4) When the block is added in a show then it is calculated how many minutes are left until the minute that the news should play, for example if the show starts 17:15 and you have scheduled the news in the block to play 17:30, 18:30 etc then news will play for the first time in 15 minutes and after that in 60 minutes.
    5) The song ISNT cut off.. if news are scheduled for 17:30 and a song starts 17:28 and ends 17:32 then the news will play on 17:32 (i need to do some extra calculations here in order to start counting the next 60 minutes from 17:30 instead)..
    6) Like Jingles/Spots, you can choose different news files for different blocks according to the genre (News word)

    This is already working (i did it yesterday at my little free time) but it needs polishing and testing...
    Would this flow be ok for you guys? Have in mind that with this, the only drawback is that you cant have more than 1 news break per hour (i prefered to use the logic "what minute of the hour" and not "every how many minutes")
    A second drawback (minor for me maybe major for others) is that news can start with a few minutes of delay since the song playing has to end first.. if you donrt mind news starting for example 17:32 and then 18:34 instead of exactly 17:30, 18:30 then this is for you but if you do mind then its better (and alot easier) to do it with liguidsoap.

    Another thing when you can make a choice by time, some Jingles play only in
    the evening or day.... in that case it would be easy to set a time, maby perhaps for the future.....

    You mean use the same Block for a morning and an evening show but add jingles only to the evening show? Yes that could be done but isnt it easier if you create another block for your morning shows without checking the jingles checkbox?
    Post edited by Stathis Simos at 2015-12-22 06:00:24
  • i copy paste the code in the original files from airtime 2.5.2.1 and this works fine , you only have to change the file names because i put 252 behind the names of the files



    You will find the files in (ubuntu):
    Block.php -> /usr/share/airtime/application/models/SmartBlockCriteria.php -> /usr/share/airtime/application/formssmart-block-criteria.phtml -> /usr/share/airtime/application/views/scripts/form
    I have the smart-block-criteria.phtml as rar file in order to be able to attach it. Unrar it first 
  • There are more bug fixes (not important ones.. pretty minor) that are not included in your files so this is not the latest version of this hack :)

    Besides that, i have in my files a working version for "NEWS" but i am not giving it yet because there is one importand thing.. in order to have news working you need SOME of the code i done for the other hack "Option to avoid scheduling repeating tracks for xx time before/after Show Start" (for dynamic blocks) so i dont know if it is better if i give the final working files i have with both hacks inside...
    You could then make new working 2.5.2 files and give them here :)
  • With news there is something else that bothers me (and i cant really test in my production server until i create a development one).
    When you create lets say shows for whole week like i do and dynamically specific jingles are added, the logical thing is not to delete them or change them at least until next week since in any other case the files will be missing at the playback time. (i know its always better to create your schedules daily but most of us dont have the time for this)

    With Hourly news things are more complicated since the News file can change every day or even every few hours. So what happens if you schedule a few days with dynamic blocks and specific News file is added to the shows (the one that was currently there during scheduling) and this file is then changed (even if the name is the same, the length most probably wont be the same and that would be a problem)?

    From what i understand reading another post, if the new file is bigger and the schedule was done with the old one then the news are going to cut off at the specific length of the old file and thats not so desirable...
    I think i have to check this deeper after new year..
  • Ok, well let me nkow when you have then final files of both hacks and i will try them in 2.5.2.1 and edit those files and see if all is working

    what are the small bug fixes so i know what to look for
    Post edited by René Ooms at 2015-12-23 12:40:36
  • that sounds good, concerns News. This is good to hear that you're making forward progress. in my case I have an opening jingle every hour.

    which is perhaps an idea, is to create a possibility that there is a track (instrumental) it may have been used for padding to an end of a show, a maximum length of 2.5 minutes, so that a piece of music does not stop at once for news. We call this a filler ( it closes the gap )

    Another point, is when I make a smart block of 24 hours and incorporated it into a show I always need to manually add 16 minutes. any idea how this is possble to fix.
    Post edited by Costa Blanca FM at 2015-12-23 15:31:03
  • Dear Simos,

    I hope everything goes well with you.
    I have a question about the last update. When I make the choice by

    Only one random Jingle
    Jingles Every 4 items one jingle does not work well.
    Sometimes there is a jingle after 4 tracks, but also after 6 or 7 tracks

    Every jingle have the genre name JingleNormal i have 10 diverend jingles
    and make the choice of 24 hours Dynamic Smart Block.

    I'm doing something wrong?

    Regards
    Alejandro
  • Just tested and i dont see anything strange... You could post a screenshot of the smartblock configuration to understand what exactly you are doing.
  • I found the problem.

    When i use random jingles with genre name JingleMorning ( 10 Jingles) it's works fine after every 3 songs one random jingle.

    after server reset
    this happened,  after 8 songs one radom jingle or after 4 or 3.

    In found out that when i make one new random with genre name Jinglemornig change (M) in small
    than it's works fine  3 tracks and after one random Jinglemorning.

    I think that the cache make the problem,
    he remember that rather he saw JingleMorning
    So now you see in de list
    not existents randoms.


    249 x 363 - 149K
  • Testing the hack and airtime 2.5.1 for almost one month now using dynamic playlists each playlist 24 hours all linked shows with 1 random jingle after every podcast/mix and everything works fine. 

    When i used a ubuntu 32 12.04 32 install i encountered a few problems, like no sound, but with a ubuntu 12.04 64 bit install everything  works great so far.
  • Amazing job! Will try it, for sure.
    Thanks a lot!


  • Post edited by Costa Blanca FM at 2016-02-07 13:15:01