Archive

Archive for the ‘Techy Stuff’ Category

My XBMC Multi Room audio challenge.

March 8th, 2010 James No comments

Recently I have successfully migrated away from SKY HD and from Freeview+ to an entirely XBMC based solution.  Most importantly this solution currently has a very high WAF .  My setup is built using XBMC live in an overly powerful PC in a rather nice silverstone media center case.

My current problem is now I have relegated all of my media to the lounge,  using the ipod dock in the kitchen with a meagre 16GB Ipod seems positively lacking when, your media centre is connected directly to a 5Tb NAS.  What happens now is you play music in the lounge and turn it way up to a probably neighbour unsuitable level to be to properly enjoy it in the kitchen.  This is why I crave multi room audio, I wrote a while back why I think XBMC is a far better and cheaper solution than the Sonos solution, though Sonos still do have the killer feature present and correct.

So I’m am challenged with building my own solution some how.  My requirement is fairly straight forward:

  • The ability to have the audio playing from the media centre play to another source at the same time.

I have no need for visuals or UI to be present in the other rooms as I can control the xbmc source with the XBMC iphone remote app, and possibly that Archos 7 tablet when its released :) .

Typically it appears the requirement is a very easy thing to say out loud, and yet another thing entirely to actually achieve.  The challenge as I currently understand it, is keeping the music streams to each room in sync.

My current stab in the dark is use a motorola DC800 bluetooth stereo adaptor, and use A2DP to stream the music to the second amp.  This when the adaptor arrives, I can see is going to present a couple of challenges.

  1. Is it even possible to send audio out via the Line / SPdif out at the same time as A2DP ?
  2. if it is, will the audio be in sync?

Answers on a post card, if I get it to work i’ll post the solution (assuming it doesn’t involve purchase of a sonos solution :) )

Categories: Media Centre Tags: , , ,

XBMC Gmail notifications.

February 14th, 2010 James No comments

I have this php script currently running on my nas to let me know if I have any new mail.  It works with gmail.com, googlemail.com and google app address’.  I simply use cron to execute the script every 15 minutes.

i.e. (0,15,30,45 17-23 * * * php /var/www/checkgmail.php > /dev/null   #Check Gmail)

   1: <?php

   2: $emailaddress = 'someemailaddress@gmail.com'; // i.e. bob@gmail.com or bob@bobsdomain.com if you use google apps

   3: $password = 'somepassword'; // email password

   4: $xbmcaddress = '192.168.1.1'; // IP or hostname of your xbmc

   5: $xbmcport = '8080'; // port the xbmc web server is running on.

   6:

   7:

   8: $domain = explode('@',$emailaddress);

   9: if ($domain['1'] == 'gmail.com' || $domain['1'] == 'googlemail.com')

  10:     {

  11:     $use_googleapps = false;

  12:     } else {

  13:     $use_googleapps = true;

  14:     }

  15: if ($use_googleapps == true)

  16:     {

  17:     $url = 'https://mail.google.com/a/'.$domain['1'].'/feed/atom';

  18:     } else {

  19:     $url = 'https://mail.google.com/mail/feed/atom';

  20:     }

  21:

  22:

  23:     $ch = curl_init ($url);

  24:     curl_setopt($ch, CURLOPT_HEADER, 0);

  25:     curl_setopt($ch, CURLOPT_PROTOCOLS,CURLPROTO_HTTPS);

  26:     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

  27:     curl_setopt($ch, CURLOPT_BINARYTRANSFER,1);

  28:     $curllogin = $emailaddress.':'.$password;

  29:     curl_setopt($ch, CURLOPT_USERPWD,$curllogin);

  30:     $rawdata=curl_exec($ch);

  31:     curl_close ($ch);

  32:

  33: $array = xml2array($rawdata);

  34: $array = $array['feed'];

  35: //print_r($array);

  36:

  37: if ($array['fullcount'] < 1)

  38:     {

  39:     echo ' no new mail ';

  40:     } else {

  41:     if ($array['fullcount'] == 1)

  42:         {

  43:         fopen("http://".$xbmcaddress.":".$xbmcport."/xbmcCmds/xbmcHttp?command=ExecBuiltIn(Notification(".$emailaddress.",You%20Have%20A%20New%20Email!))",r);

  44:         } else {

  45:         fopen("http://".$xbmcaddress.":".$xbmcport."/xbmcCmds/xbmcHttp?command=ExecBuiltIn(Notification(".$emailaddress.".",You%20Have%20".$array['fullcount']."%20New%20Emails!))",r);

  46:         }

  47:

  48:

  49:     }

  50:

  51:

  52:

  53: function xml2array($contents, $get_attributes=1, $priority = 'tag') {

  54:     if(!$contents) return array();

  55:

  56:     if(!function_exists('xml_parser_create')) {

  57:         //print "'xml_parser_create()' function not found!"; 

  58:         return array();

  59:     }

  60:

  61:     //Get the XML parser of PHP - PHP must have this module for the parser to work

  62:     $parser = xml_parser_create('');

  63:     xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, "UTF-8"); # http://minutillo.com/steve/weblog/2004/6/17/php-xml-and-character-encodings-a-tale-of-sadness-rage-and-data-loss 

  64:     xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);

  65:     xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);

  66:     xml_parse_into_struct($parser, trim($contents), $xml_values);

  67:     xml_parser_free($parser);

  68:

  69:     if(!$xml_values) return;//Hmm...

  70:

  71:     //Initializations

  72:     $xml_array = array();

  73:     $parents = array();

  74:     $opened_tags = array();

  75:     $arr = array();

  76:

  77:     $current = &$xml_array; //Refference

  78:

  79:     //Go through the tags.

  80:     $repeated_tag_index = array();//Multiple tags with same name will be turned into an array

  81:     foreach($xml_values as $data) {

  82:         unset($attributes,$value);//Remove existing values, or there will be trouble

  83:

  84:         //This command will extract these variables into the foreach scope

  85:         // tag(string), type(string), level(int), attributes(array).

  86:         extract($data);//We could use the array by itself, but this cooler.

  87:

  88:         $result = array();

  89:         $attributes_data = array();

  90:

  91:         if(isset($value)) {

  92:             if($priority == 'tag') $result = $value;

  93:             else $result['value'] = $value; //Put the value in a assoc array if we are in the 'Attribute' mode

  94:         }

  95:

  96:         //Set the attributes too.

  97:         if(isset($attributes) and $get_attributes) {

  98:             foreach($attributes as $attr => $val) {

  99:                 if($priority == 'tag') $attributes_data[$attr] = $val;

 100:                 else $result['attr'][$attr] = $val; //Set all the attributes in a array called 'attr'

 101:             }

 102:         }

 103:

 104:         //See tag status and do the needed.

 105:         if($type == "open") {//The starting of the tag '<tag>' 

 106:             $parent[$level-1] = &$current;

 107:             if(!is_array($current) or (!in_array($tag, array_keys($current)))) { //Insert New tag

 108:                 $current[$tag] = $result;

 109:                 if($attributes_data) $current[$tag. '_attr'] = $attributes_data;

 110:                 $repeated_tag_index[$tag.'_'.$level] = 1;

 111:

 112:                 $current = &$current[$tag];

 113:

 114:             } else { //There was another element with the same tag name

 115:

 116:                 if(isset($current[$tag][0])) {//If there is a 0th element it is already an array

 117:                     $current[$tag][$repeated_tag_index[$tag.'_'.$level]] = $result;

 118:                     $repeated_tag_index[$tag.'_'.$level]++;

 119:                 } else {//This section will make the value an array if multiple tags with the same name appear together

 120:                     $current[$tag] = array($current[$tag],$result);//This will combine the existing item and the new item together to make an array

 121:                     $repeated_tag_index[$tag.'_'.$level] = 2;

 122:

 123:                     if(isset($current[$tag.'_attr'])) { //The attribute of the last(0th) tag must be moved as well

 124:                         $current[$tag]['0_attr'] = $current[$tag.'_attr'];

 125:                         unset($current[$tag.'_attr']);

 126:                     }

 127:

 128:                 }

 129:                 $last_item_index = $repeated_tag_index[$tag.'_'.$level]-1;

 130:                 $current = &$current[$tag][$last_item_index];

 131:             }

 132:

 133:         } elseif($type == "complete") { //Tags that ends in 1 line '<tag />' 

 134:             //See if the key is already taken. 

 135:             if(!isset($current[$tag])) { //New Key 

 136:                 $current[$tag] = $result;

 137:                 $repeated_tag_index[$tag.'_'.$level] = 1;

 138:                 if($priority == 'tag' and $attributes_data) $current[$tag. '_attr'] = $attributes_data;

 139:

 140:             } else { //If taken, put all things inside a list(array) 

 141:                 if(isset($current[$tag][0]) and is_array($current[$tag])) {//If it is already an array... 

 142:

 143:                     // ...push the new element into that array. 

 144:                     $current[$tag][$repeated_tag_index[$tag.'_'.$level]] = $result;

 145:

 146:                     if($priority == 'tag' and $get_attributes and $attributes_data) {

 147:                         $current[$tag][$repeated_tag_index[$tag.'_'.$level] . '_attr'] = $attributes_data;

 148:                     }

 149:                     $repeated_tag_index[$tag.'_'.$level]++;

 150:

 151:                 } else { //If it is not an array... 

 152:                     $current[$tag] = array($current[$tag],$result); //...Make it an array using using the existing value and the new value 

 153:                     $repeated_tag_index[$tag.'_'.$level] = 1;

 154:                     if($priority == 'tag' and $get_attributes) {

 155:                         if(isset($current[$tag.'_attr'])) { //The attribute of the last(0th) tag must be moved as well 

 156:

 157:                             $current[$tag]['0_attr'] = $current[$tag.'_attr'];

 158:                             unset($current[$tag.'_attr']);

 159:                         }

 160:

 161:                         if($attributes_data) {

 162:                             $current[$tag][$repeated_tag_index[$tag.'_'.$level] . '_attr'] = $attributes_data;

 163:                         }

 164:                     }

 165:                     $repeated_tag_index[$tag.'_'.$level]++; //0 and 1 index is already taken 

 166:                 }

 167:             }

 168:

 169:         } elseif($type == 'close') { //End of tag '</tag>' 

 170:             $current = &$parent[$level-1];

 171:         }

 172:     }

 173:

 174:     return($xml_array);

 175: }

 176: ?>

Categories: Techy Stuff Tags: , , ,

Iphone 2g MMS on BT Total Broadband Anywhere

July 7th, 2009 James 5 comments
MMS Enable your 2g Iphone

MMS Enable your 2g Iphone

I have succesfully got MMS working on my Iphone 2g with BT Total Broadband anywhere / BTMobile, and have solved the problem where the mms APN settings do not save. Read more…

Using Gmail as a Sendmail Relay

April 7th, 2009 James 19 comments

The revenge this time its personal!

K I just setup sendmail to relay using gmail again,  thought I better post what I have done as my original now out of date post is still getting quite a lot of views.

This is based on my Ubuntu 8.10 Server ( 2.6.27-11-server) all patched up todays date and then I did the below. Read more…

Categories: Techy Stuff Tags: , ,

How to get to Version 1 phpadadmin

January 23rd, 2009 James No comments

Thought its probably worth explaining what I think Version 1 of phpadadmin would look and be able to do. 

Things it needs to be able to do:

  • Allow any user to edit their own Active Directory attributes.  [In Current Release]
    • Allow an administrator to determine which attributes can be edited [In Current Release]
    • Allow an administrator to dictate a range of choices for a field1 [In Current Release]
  • Allow the users access to all that directory information by providing a powerful search
    • Allow the administrator to determine which fields can be used to search on
    • and which fields can be returned in the search.
    • Users contacts details export to vCard format
    • Allow phone number to be formatted in a way that can be picked up by various SIP softphones i.e. phone://<number> etc. Read more…
Categories: phpadadmin Tags: ,

phpadadmin 0.711

January 22nd, 2009 James 1 comment

Not a lot of new functionality added here mainly changing the back end to function better, and allowing you to set your ad password without first having to have you ad password set :S.

The environment checker now tests :

  • If Seamless authentication is enabled correctly in IIS manager
  • If it can connect to the mysql db if php extension is in place
  • and if it can get any info out of AD using your current user. Read more…

phpADadmin update v0.71

January 8th, 2009 James 1 comment

Quick update on progress since I started to rewrite phpadadmin again,  All the config pages are now complete, and am now pulling the adldap config directly out of the DB.  

  • Added a couple of nice new features like being able to force the site to https if such is your want. 
  • Added the encryption functions in for the Self Service password resets.  
  • Done some work on the look of the whole thing ( see screen shot below).

Read more…

Categories: phpadadmin Tags: ,

phpADadmin In Progress again again

January 6th, 2009 James No comments

<farnsworth>”Good news everyone”</farnsworth> I have started to code phpadadmin again, on the back of the experience i have gained from the last couple of php projects I have been doing. This time its going to be better than ever before ( Naturally).  This time I have started with the background config and working up, so to speak. The attribute conifguration is now finished and has a web UI and mysql backend. This makes it alot easier to make changes. Also I have just got ajax forms validation working :) w00t! So you have assign each attribute whether its a required field and a number of others, or none at all such is your want. Read more…

Cheaper Better Sonos Alternative

October 27th, 2008 James 6 comments

For some time now I have looked upon the wireless multi-room audio solution from Sonos with envious eyes. Mentally purchasing most of their offering many times over. However today by chance I spotted that my setup is better than their offering and a lot cheaper.
Read more…

Categories: Techy Stuff Tags: , , ,

All hail the Jesus phone

October 23rd, 2008 James No comments

Oddly the same day I post my MacBook pro to it’s lucky new owner:(. My 2g iPhone arrives in the post. Bit of an inplanned purchase this, bought in a shock eBay bargain moment. I wanted to replace my BT Anywhere HTC620 because as I have said before Windows mobile is terrible.

Anyway once I had my new iPhone all I hah to do was upgrade it to 2.1 and unlock it. This turned out to be slightly more fiddly than the interweb will have you believe.
Read more…

Categories: Apple Mac Tags: , ,