1

我是网络开发新手,最近发布了关于使用 PHP 代码尝试根据一天中的时间在我的 Wimpy 播放器组件上显示特定图像的帖子。(用于大学作业的广播电台网站)我已经解决了这个问题,但是当我点击播放时,它只是恢复到代码中列表中的第一个媒体......

如何根据一天中的时间获得要显示的正确标题、曲目和图像?例如 - 如果是早上 5 点,但不到 7 点,音频播放器应该显示“Sunrise Show”,播放“Lay it all on me”并显示 Sunrise Show 图像(当用户点击播放时)。

链接是:http ://www.zwebdesigns.info/test.php

这是我的代码:

<!DOCTYPE html>
<html lang="en">
<head>
<title>Home - Bay FM - 99.9</title>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="bayfm.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-      awesome/4.5.0/css/font-awesome.min.css">
<meta name="viewport" content="initial-scale=1.0"/>
<script src="/wimpy/wimpy.js"></script>

</head>
<body>



 <div id="container">
    <header>

        <div id="logo"><a href="index.php"><img src="new-bayfm-logo400x120.png" alt="logo"></a></div>




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

date_default_timezone_set('Australia/Sydney');                                                                                                          
$hour = date('G');



switch ($hour) {

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

</html>
4

0 回答 0