Should be completely iPhone/iPod Touch-friendly now :)
authorDan
Sun, 23 Mar 2008 22:03:57 -0400
changeset 4 cde92f6ec29f
parent 3 e7447a6044ec
child 5 9b96265b5918
Should be completely iPhone/iPod Touch-friendly now :)
functions.php
playlist.php
themes/funkymonkey/style.css
themes/iphone/images/ajax.gif
themes/iphone/images/amarok.gif
themes/iphone/images/next.png
themes/iphone/images/pause.png
themes/iphone/images/play.png
themes/iphone/images/playbar-shadow.gif
themes/iphone/images/playbar.gif
themes/iphone/images/prev.png
themes/iphone/images/src/playbar-shadow.xcf
themes/iphone/images/src/playbar.xcf
themes/iphone/images/stop.png
themes/iphone/images/volume.png
themes/iphone/playlist.tpl
themes/iphone/scrollfix.js
themes/iphone/style.css
webcontrol.php
--- a/functions.php	Sun Mar 23 20:58:51 2008 -0400
+++ b/functions.php	Sun Mar 23 22:03:57 2008 -0400
@@ -132,3 +132,24 @@
   return "$minutes:$seconds";
 }
 
+/**
+ * Loads the specified theme into Smarty
+ * @param string Theme ID
+ * @return object Smarty object
+ */
+
+function load_theme($theme_id)
+{
+  global $httpd;
+  static $smarty = array();
+  if ( !isset($smarty[$theme_id]) )
+  {
+    $smarty[$theme_id] = new Smarty();
+    $smarty[$theme_id]->template_dir = "./themes/$theme_id";
+    $smarty[$theme_id]->compile_dir = "./themes/$theme_id/compiled";
+    $smarty[$theme_id]->cache_dir = "./cache";
+    $smarty[$theme_id]->config_dir = "./config";
+    $httpd->add_handler("themes/$theme_id", 'dir', "./themes/$theme_id");
+  }
+  return $smarty[$theme_id];
+}
--- a/playlist.php	Sun Mar 23 20:58:51 2008 -0400
+++ b/playlist.php	Sun Mar 23 22:03:57 2008 -0400
@@ -11,10 +11,18 @@
 
 function amarok_playlist($server)
 {
-  global $smarty, $theme, $playlist, $allowcontrol;
+  global $theme, $playlist, $allowcontrol;
+  
+  $iphone = ( strpos($_SERVER['HTTP_USER_AGENT'], 'iPhone') ||
+       strpos($_SERVER['HTTP_USER_AGENT'], 'iPod') ||
+       strpos($_SERVER['HTTP_USER_AGENT'], 'BlackBerry') ||
+       isset($_GET['m'])
+       );
+  $theme_id = ( $iphone ) ? 'iphone' : $theme;
+  $smarty = load_theme($theme_id);
   
   $active = dcop_action('playlist', 'getActiveIndex');
-  $smarty->assign('theme', $theme);
+  $smarty->assign('theme', $theme_id);
   $smarty->assign('playlist', $playlist);
   $smarty->assign('active', $active);
   $smarty->assign('scripts', array(
--- a/themes/funkymonkey/style.css	Sun Mar 23 20:58:51 2008 -0400
+++ b/themes/funkymonkey/style.css	Sun Mar 23 22:03:57 2008 -0400
@@ -87,6 +87,7 @@
   margin-right: 1px;
   background-color: #33395d;
   border: 1px solid #909090;
+  text-decoration: none;
 }
 
 a.volume_button_active {
Binary file themes/iphone/images/ajax.gif has changed
Binary file themes/iphone/images/amarok.gif has changed
Binary file themes/iphone/images/next.png has changed
Binary file themes/iphone/images/pause.png has changed
Binary file themes/iphone/images/play.png has changed
Binary file themes/iphone/images/playbar-shadow.gif has changed
Binary file themes/iphone/images/playbar.gif has changed
Binary file themes/iphone/images/prev.png has changed
Binary file themes/iphone/images/src/playbar-shadow.xcf has changed
Binary file themes/iphone/images/src/playbar.xcf has changed
Binary file themes/iphone/images/stop.png has changed
Binary file themes/iphone/images/volume.png has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/themes/iphone/playlist.tpl	Sun Mar 23 22:03:57 2008 -0400
@@ -0,0 +1,85 @@
+{**
+ * Template file for default Funky Monkey theme
+ * Web control interface script for Amarok
+ * Written by Dan Fuhry - 2008
+ *
+ * This script is in the public domain. Use it for good, not evil.
+ *}
+
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
+<html>
+  <head>
+    <title>AmaroK playlist</title>
+    <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
+    <!-- iPhone viewport hack from jailbreakme.com -->
+    <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
+    <link rel="stylesheet" type="text/css" href="/themes/{$theme|escape}/style.css" />
+    <link rel="favorite icon" type="image/ico" href="/favicon.ico" />
+    <script type="text/javascript">
+    var img_play = '/themes/{$theme|escape}/images/play.png';
+    var img_pause = '/themes/{$theme|escape}/images/pause.png';
+    var img_ajax = '/themes/{$theme|escape}/images/ajax.gif';
+    var class_current = 'current';
+    var allow_control = {if $allow_control}true{else}false{/if};
+    </script>
+    {foreach from=$scripts item=script}
+    <script type="text/javascript" src="/scripts/{$script}"></script>
+    {/foreach}
+    <script type="text/javascript" src="/themes/{$theme|escape}/scrollfix.js"></script>
+  </head>
+  <body>
+    <div id="playbar">
+      <div class="playbar-inner">
+        <img alt=" " id="ajax_status" style="display: none; position: absolute; top: 5px; right: 5px;" src="about:blank" />
+        {if $allow_control}
+        <a href="#action:prev" onclick="player_action('prev'); return false;"><img alt="&laquo; PrevTrk" src="/themes/{$theme|escape}/images/prev.png" style="position: relative; top: -8px;" /></a>
+        <a href="#action:play" onclick="player_action('play'); return false;" id="btn_playpause"><img alt="Play" src="/themes/{$theme|escape}/images/play.png" /></a>
+        <a href="#action:next" onclick="player_action('next'); return false;"><img alt="NextTrk &raquo;" src="/themes/{$theme|escape}/images/next.png" style="position: relative; top: -8px;" /></a>
+        <br />
+        {/if}
+        <span id="playmeter">--:--/--:--</span><br />
+        {if $allow_control}
+        <img hspace="4" alt="Volume: " src="/themes/{$theme|escape}/images/volume.png" />
+        <span id="volume_wrap"><a
+          class="volume_button" href="#volume:0"   onmouseover="volume_over(0);"   onmouseout="volume_out();" id="volbtn_0"   onclick="set_volume(0);   return false;">&nbsp;</a><a
+          class="volume_button" href="#volume:10"  onmouseover="volume_over(10);"  onmouseout="volume_out();" id="volbtn_10"  onclick="set_volume(10);  return false;">&nbsp;</a><a
+          class="volume_button" href="#volume:20"  onmouseover="volume_over(20);"  onmouseout="volume_out();" id="volbtn_20"  onclick="set_volume(20);  return false;">&nbsp;</a><a
+          class="volume_button" href="#volume:30"  onmouseover="volume_over(30);"  onmouseout="volume_out();" id="volbtn_30"  onclick="set_volume(30);  return false;">&nbsp;</a><a
+          class="volume_button" href="#volume:40"  onmouseover="volume_over(40);"  onmouseout="volume_out();" id="volbtn_40"  onclick="set_volume(40);  return false;">&nbsp;</a><a
+          class="volume_button" href="#volume:50"  onmouseover="volume_over(50);"  onmouseout="volume_out();" id="volbtn_50"  onclick="set_volume(50);  return false;">&nbsp;</a><a
+          class="volume_button" href="#volume:60"  onmouseover="volume_over(60);"  onmouseout="volume_out();" id="volbtn_60"  onclick="set_volume(60);  return false;">&nbsp;</a><a
+          class="volume_button" href="#volume:70"  onmouseover="volume_over(70);"  onmouseout="volume_out();" id="volbtn_70"  onclick="set_volume(70);  return false;">&nbsp;</a><a
+          class="volume_button" href="#volume:80"  onmouseover="volume_over(80);"  onmouseout="volume_out();" id="volbtn_80"  onclick="set_volume(80);  return false;">&nbsp;</a><a
+          class="volume_button" href="#volume:90"  onmouseover="volume_over(90);"  onmouseout="volume_out();" id="volbtn_90"  onclick="set_volume(90);  return false;">&nbsp;</a><a
+          class="volume_button" href="#volume:100" onmouseover="volume_over(100);" onmouseout="volume_out();" id="volbtn_100" onclick="set_volume(100); return false;">&nbsp;</a>
+        </span>
+        {/if}
+      </div>
+    </div>
+    <div class="tblholder" id="playlist">
+      <table border="0" cellspacing="1" cellpadding="4">
+        <tr>
+          <th>Track</th>
+        </tr>
+        {foreach key=tid item=track from=$playlist}
+        {strip}
+        <tr class="{cycle values="row1,row2"}{if $active == $tid} current{/if}" id="track_{$tid}" amarok:length_sec="{$track.length_int}">
+          <td>
+            <a class="tracklink" href="#action:jump;tid:{$tid}" onclick="jump_to_song({$tid}); return false;">
+              {$track.title|escape}
+            </a>
+          </td>
+        </tr>
+        {/strip}
+        {/foreach}
+      </table>
+    </div>
+    <div id="footer">
+      <img alt="AmaroK web control" src="/themes/{$theme|escape}/images/amarok.gif" /><br />
+    </div>
+    <script type="text/javascript">
+      fix_scroll();
+    </script>
+  </body>
+</html>
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/themes/iphone/scrollfix.js	Sun Mar 23 22:03:57 2008 -0400
@@ -0,0 +1,26 @@
+function getScrollOffset()
+{
+  var position;
+  if (self.pageYOffset)
+  {
+    position = self.pageYOffset;
+  }
+  else if (document.documentElement && document.documentElement.scrollTop)
+  {
+    position = document.documentElement.scrollTop;
+  }
+  else if (document.body)
+  {
+    position = document.body.scrollTop;
+  }
+  return position;
+}
+
+var fix_scroll = function()
+{
+  var div = document.getElementById('playbar');
+  div.style.top = ( String(getScrollOffset()) ) + 'px';
+}
+
+window.onscroll = fix_scroll;
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/themes/iphone/style.css	Sun Mar 23 22:03:57 2008 -0400
@@ -0,0 +1,104 @@
+/**
+ * Based upon the AmaroK WebControl interface by:
+ *    Jonas Christian Drewsen ( kde at xspect dot dk )
+ *    André Kelpe ( fs111 at web dot de )
+ *    Peter C. Ndikuwera ( pndiku at gmail dot com )
+ */
+
+body {
+  font-family: sans-serif;
+  background-color: #9cb2cd;
+  color: #ffffff;
+  margin: 0;
+  padding: 0;
+  width: 320px;
+}
+
+div.tblholder {
+  padding: 1px;
+  background-color: #ffffff;
+  border: 1px solid #000000;
+}
+
+div.tblholder table {
+  background-color: #596082;
+}
+
+tr th {
+  background-color: #697092;
+}
+
+tr.row1 td {
+  background-color: #394062;
+}
+
+tr.row2 td {
+  background-color: #202050;
+}
+
+tr.current td {
+  background-color: #495072;
+  color: #ffff00;
+}
+
+div#playbar {
+  width: 320px;
+  padding: 0;
+  margin: 0 0 10px 0;
+  background-image: url(images/playbar.gif);
+  background-repeat: repeat-x;
+  background-color: #383f61;
+  border-bottom: 1px solid #000000;
+  text-align: center;
+  position: absolute;
+  top: 0px;
+  left: 0px;
+}
+
+div.playbar-inner {
+  padding: 5px;
+  line-height: 22px;
+}
+
+a img {
+  border-width: 0;
+}
+
+div#playlist {
+  margin: 138px 8px 0 8px;
+}
+
+a.tracklink {
+  text-decoration: none;
+  color: white;
+}
+
+div#playlist tr.current a.tracklink {
+  color: #ffff00;
+}
+
+span#playmeter, span#volume_wrap {
+  position: relative;
+  top: -7px;
+}
+
+a.volume_button {
+  padding-right: 18px;
+  margin-right: 1px;
+  background-color: #33395d;
+  border: 1px solid #909090;
+  text-decoration: none;
+}
+
+a.volume_button_active {
+  background-color: #9090c2;
+  border-color: #d0d0d0;
+}
+
+div#footer {
+  background-image: url(images/playbar.gif);
+  background-repeat: repeat-x;
+  text-align: center;
+  margin-top: 10px;
+  padding: 5px;
+}
--- a/webcontrol.php	Sun Mar 23 20:58:51 2008 -0400
+++ b/webcontrol.php	Sun Mar 23 22:03:57 2008 -0400
@@ -8,7 +8,7 @@
  */
 
 $public = true;
-$allowcontrol = false;
+$allowcontrol = true;
 $theme = 'funkymonkey';
 
 @ini_set('display_errors', 'on');