Understanding the Station and Now Playing modules and what gets displayed for current program block.

Events happening in the community are now at Drupal community events on www.drupal.org.
frederickjh's picture

Hi All!

I am working on a website for a radio station and I am trying to get a handle on the logic behind the current program block. I have the station and the now playing modules installed on my development system. I understand that the now playing module can be setup to take the songs that are playing from a shoutcast server in addition to the schedules that are setup. How does the block determine whether to use the songs from the shoutcast stream or the schedule?

I also see that there is a setting "Default schedule:" and that the current program block follows that schedule. I am wondering if it would be possible to move the setting of which schedule is showing to the block configuration. The reason I ask is the station has an AM and an FM station that would like to display both schedules on the page.

These stations both have music segments but also longer prerecorded programs.The way I would like it all to function in the end is to have the two currently playing blocks one for each station. If there is a program scheduled in the schedule that it shows it as playing but when there is not it displays the music currently playing from the shoutcast if nothing is available from it then the default message. A am currently studying PHP to see if I can make or modify modules to make this happen.

Any feedback would be appreciated.

Frederick

Comments

How does the block determine

thumb's picture

How does the block determine whether to use the songs from the shoutcast stream or the schedule?

It doesn't know anything about the schedule. They are completely separate. You can filter out program's that will display in the schedule block by adding them to the Song filters section under the Now Playing admin form.

I currently don't have any plans (or time) to integrate Now Playing to work with multiple schedules. I do plan on adding tracks to a log table to display extended lists, provide search for a song played, and possibly charting. Unfortunately, this has fallen down several spots on my priority list.

frederickjh's picture

I am not sure how you can say the Current Program Block doesn't know anything about the schedule. It displays the schedule that is selected by the setting Default Schedule so it must in some way know about (access) it. I have tried it with two different schedules and changing the schedule that is set in the Default Schedule definitely changes what is displayed in the Current Program Block.

In any case I was not looking for someone else to do the work on on setting up the module to work with multiple schedules. I am programming a radio station website and the dual schedule is a feature that they want. I guess I should have better asked the question,

Is this something that you are interested in having in the station module or is it something that you do not want in the module? In the latter case, would it be ok for me to use the current module code as a starting point to build a new module?

I guess I was just trying to get a little background on the code to point me in the right direction. Is my guess correct that you wrote some or all of the Station module or the Now Playing modules or both? Thanks in advance for any help you can give.

Are we talking about the same

thumb's picture

Are we talking about the same thing here? When you mentioned that had the now playing module installed

I have the station and the now playing modules installed on my development system.

I thought you were talking about this: http://groups.drupal.org/node/47840

I understand that the now playing module can be setup to take the songs that are playing from a shoutcast server in addition to the schedules that are setup. How does the block determine whether to use the songs from the shoutcast stream or the schedule?

The first statement you make above is partially correct, the now playing module can be setup to display songs from a shoutcast server. This part — "in addition to the schedules that are setup" — isn't accurate, the now playing block does not provide schedule information, the schedule module does that.

I've only written the Now Playing module, and can answer questions specific to it. You might try asking other station module questions in a separate thread.

$default_schedule_nid

frederickjh's picture

Ok, At least now I know who I am communicating with. Yes we are talking about the same Now Playing Module that you linked to.

The now playing module is grabbing the setting for the now playing block from the station schedule module.

From:
station_nowplaying.admin.inc

$default_schedule_nid = variable_get('station_schedule_default', 0);

While station_schedule_default is being set over in station_schedule.admin.inc

$form['bc']['station_schedule_default'] = array(
'#type' => 'select',
'#title' => t('Default schedule'),
'#default_value' => variable_get('station_schedule_default', 0),
'#options' => $schedules,
'#description' => t("This you select the schedule that will be used as the default for backwards compatibility."),
);

My question is why can in not be set like the Block title in station_nowplaying.admin.inc so that each block could have a different schedule?

$form['block']['station_nowplaying_block_subject'] = array(
'#type' => 'textfield',
'#title' => t('Block Title'),
'#default_value' => variable_get('station_nowplaying_block_subject', t('Recently Played')),
'#size' => 32,
'#maxlength' => 32,
'#description' => t('The title of the recently played block.'),
'#required' => TRUE,
);

Then theoretically you could have two now playing blocks using the MultiBlock module.

Sounds good? Have you tested?

thumb's picture

I don't have a multi-schedule instance of Drupal to test this. I'm all for this if you can test, verify, and submit a patch.

Add a check for multiblock

thumb's picture

frederickjh, if you can roll a patch for this, that'd be great. Please consider adding a check to see if multiblock is installed and switch between the existing block code and the multiblock code you propose.

Can you guys file a feature

tim.plunkett's picture

Can you guys file a feature request and post some of the relevant code?
I'm going to have a big chunk of time to devote to the station module soon, I'd love to take a look at this.

I've been considering putting

thumb's picture

I've been considering putting the Now Playing code up on Github. I'll do this in the next few days.

Feature Request Question

frederickjh's picture

Hi tim.plunkett!

What exactly are you looking for in a feature request? I can try and write up what I have figured out so far and what I am looking to add as a feature. Is that what you are looking for?

Now Playing posted to Github

thumb's picture

I've posted what I have so far to http://github.com/ckieffer/drupal-station

@frederickjh feel free to fork, make your change, and send me a pull request.

Github modules, Nowplaying, Log, and Stream

frederickjh's picture

Hi thumb!

I did a test today with a shoutcast server and the nowplaying module (Looks to be the same version as your github judging from the info file.) I was not able to get the stream meta data to import. I could watch the /played.html change as songs were played. Question is is this still working or am I doing something wrong?

I also took a quite look at the Log and Stream modules. Correct me if I have it wrong but it looks like the Log module is going to pull the data from the admin XML stats file on a shoutcast server and add it to the station archive. Stream appears to try and pull the current title from the stream server.

Just trying to understand how the pieces all fit together and what they each do.

Frederick

You're correct

thumb's picture

Hi frederickjh. The Log and Stream modules replace the Now Playing module and you've accurately described what they do. I had written the Now Playing module as a quick way to display tracks played in a block for a stream to which I didn't have admin access. After moving to a new stream provider with admin access, I set up the Log and Stream modules and they do just what you say.

So, if you have admin access, don't bother with Now Playing. Use Steam and Log instead.

I should add that Now Playing

thumb's picture

I should add that Now Playing didn't store any track information. The Log module will not only save tracks played to the database, but it also provides a block and page to show recently played.

Thanks thumb!

frederickjh's picture

Thanks thumb for all the replies! I been busy with other parts of the site for now but I will get to this

Thanks thumb!

frederickjh's picture

Thanks thumb for all the replies! I been busy with other parts of the site for now but I will get to this

frederickjh's picture

@thumb and @drewish

I recently spent some time digging in the source code after teaching myself some php and Drupal API. I started looking at the function station_block in station.module. I figured out how to add a configure op but then could not figure out where to store the settings for each block.

I then started looking at modules that have blocks for ideas and came across the Aggregator module from core (D6). This gave me a good example of what I wanted to do and how it was implemented. For each feed the module creates a block that can be enabled in the blocks administration page (/admin/build/block).

This is what I would like to do first for the block in the station module and then later on for the Now Playing module as well.

This approach avoids having to store settings that tell the block which schedule you want. Multi-block will not work for this as it only saves a "new copy" of the block settings in the block table, so all blocks would be of the same schedule.

I hope to get some patches out for this soon.

Sounds like a reasonable

thumb's picture

Sounds like a reasonable approach!

Ok, another change of plans ...

frederickjh's picture

php does not seem that hard. The Drupal API a bit harder but the hardest of all is debugging or setting up a proper debugging environment for Drupal and php. I come from a background in programming where in a bash script you can add a

set -x

and watch what happens. Maybe I have been spoiled.

Thankfully there is Views. I have figured out that I can create a lot of what I want, if not all, with views. Once I get it all tweaked out I will try and export the views so others can use them and add some documentation.

Still trying to figure out why when the block refresh module refreshes blocks it adds a n/a to the end of the output. The block refreshes ok but the added n/a is annoying as it is after the </div> tag and ends up on a new line and shoves all the other content down the page.

Radio

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds:

Hot content this week