/    Sign up×
Community /Pin to ProfileBookmark

Using wimpy player – need to have a certain image show according to the time of day

Hi,

I am new to web dev and I am currently working on a college assignment for which I need to create an audio player that uses PHP to show different images according to the time of day. The website is for a radio station, and the audio player shows an image that would correspond to which radio program should be playing when the user is on the website.

For example:

If it is greater than or equal to 1am, and less than 5am, the audio player should show a certain image that corresponds with the radio show that would be on at that time.

All the audio player seem to do is show the first image on the list every time, no matter what time of day it is..

I have emailed wimpy player support team, and consulted my teacher, but I am not having much luck… so I hope someone can help!!

Please see code below:

<!– Wimpy Player –>
<div id=”wimpyplayer” style=”width:100%;height:100%;” data-wimpyplayer data-skin=”/Rad.tsv” data-coverArt=”<?php

$hour = date(‘G’);

switch ($hour) {

case ($hour >= 1 && $hour < 5);
echo “http://www.zwebdesigns.info/public_html/wimpy/audio-player-files/the-early-shift.jpg“;
break;
case ($hour >= 5 && $hour < 7);
echo “http://www.zwebdesigns.info/public_html/wimpy/audio-player-files/sunrise-show.jpg“;
break;
case ($hour >= 7 && $hour < 10);
echo “http://www.zwebdesigns.info/public_html/wimpy/audio-player-files/the-breakfast-show.jpg“;
break;
case ($hour >= 10 && $hour < 12);
echo “http://www.zwebdesigns.info/public_html/wimpy/audio-player-files/coffee-club.jpg“;
break;
case ($hour >= 12 && $hour < 15);
echo “http://www.zwebdesigns.info/public_html/wimpy/audio-player-files/midday-music.jpg“;
break;
case ($hour >= 15 && $hour < 18);
echo “http://www.zwebdesigns.info/public_html/wimpy/audio-player-files/drive-by-show.jpg“;
break;
case ($hour >= 18 && $hour < 19);
echo “http://www.zwebdesigns.info/public_html/wimpy/audio-player-files/news-hour.jpg“;
break;
case ($hour >= 19 && $hour < 20);
echo “http://www.zwebdesigns.info/public_html/wimpy/audio-player-files/sports-hour.jpg“;
break;
case ($hour >= 20 && $hour < 22);
echo “http://www.zwebdesigns.info/public_html/wimpy/audio-player-files/the-wind-down.jpg“;
break;
case ($hour >= 22 && $hour < 1);
echo “http://www.zwebdesigns.info/public_html/wimpy/audio-player-files/night-sounds.jpg“;
break;

default: echo “No image to display”;

}
?>”data-responsive=1 data-startUpText=”Click play to listen live” data-loop=2 data-volume=0.5 data-linkEnable=1 data-disableControls=”pause,coverPlayPause,rewind,playlist” data-media='[{“title”:”The Early Shift”,”file”:”http://zwebdesigns.info/wimpy/audio-player-files/crack-rock.mp3″,”image”:”/wimpy/audio-player-files/the-early-shift.jpg”,”artist”:”Hosted By Frank Ocean”,”date”:”1458020443″},{“title”:”Sunrise Show”,”file”:”http://zwebdesigns.info/wimpy/audio-player-files/lay-it-all-on-me.mp3″,”image”:”/wimpy/audio-player-files/sunrise-show.jpg”,”artist”:”Hosted By Sarah Williams”},{“title”:”Breakfast Show”,”file”:”http://zwebdesigns.info/wimpy/audio-player-files/make-me-feel-better.mp3″,”image”:”/wimpy/audio-player-files/the-breakfast-show.jpg”,”artist”:”Hosted By Alex Adair”},{“title”:”Coffee Club”,”file”:”http://zwebdesigns.info/wimpy/audio-player-files/sundream.mp3″,”image”:”/wimpy/audio-player-files/coffee-club.jpg”,”artist”:”Hosted By Rufus”},{“title”:”Midday Music”,”file”:”http://zwebdesigns.info/wimpy/audio-player-files/tongue-tied.mp3″,”image”:”/wimpy/audio-player-files/midday-music.jpg”,”artist”:”Hosted By Rubes”},{“title”:”Drive By Show”,”file”:”http://zwebdesigns.info/wimpy/audio-player-files/you-and-me.mp3″,”image”:”/wimpy/audio-player-files/drive-by-show.jpg”,”artist”:”Hosted By Mark Logan”},{“title”:”News Hour”,”file”:”http://zwebdesigns.info/wimpy/audio-player-files/is-this-how-you-feel.mp3″,”image”:”/wimpy/audio-player-files/news-hour.jpg”,”artist”:”Hosted By Paige Karatha”},{“title”:”Sports Hour”,”file”:”http://zwebdesigns.info/wimpy/audio-player-files/d&#39;yer-mak&#39;er.mp3″,”image”:”/wimpy/audio-player-files/sports-hour.jpg”,”artist”:”Hosted By Gary Somers”},{“title”:”The Wind Down”,”file”:”http://zwebdesigns.info/wimpy/audio-player-files/stay-with-me.mp3″,”image”:”/wimpy/audio-player-files/the-wind-down.jpg”,”artist”:”Hosted By Kat”},{“title”:”Night Sounds”,”file”:”http://zwebdesigns.info/wimpy/audio-player-files/give-up.mp3″,”image”:”/wimpy/audio-player-files/night-sounds.jpg”,”artist”:”Hosted By Arthur Beech”}]’

>

</div>

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@ginerjmJun 16.2016 — First thing I would do is echo the $hour value to be sure it is what I think it is.
Copy linkTweet thisAlerts:
@NogDogJun 16.2016 — And if not what you expect, you may need to [url=http://php.net/date_default_timezone_set]date_default_timezone_set()[/url].
×

Success!

Help @zb4885 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.5,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...