View Single Post
Old 04-28-05, 12:16 PM   #8 (permalink)
OddbOd
Aximsite Minor League
 
OddbOd's Avatar
Member
 
Join Date: Nov 2004
Location: Australia
Posts: 208
Thanked 1 Time in 1 Post
Well after some wailing and cursing I finally fixed the problem.

You were sort of on the right track with the file association idea but the crux of the problem is the way different browsers handle http headers. The desktop browsers work with Netjuke because the filename passed to them in the header is the one that is actually used, unfortunately Pocket IE does things completely differently and tries to guess the filetype based on the extension it sees (in this case .php). My first attempt at a fix was to use NetFront 3.1 which did work as it correctly changes the filename to .m3u and can be configured to open a file using a helper app, but, even when configured correctly you still have to go through a pointless save dialog to get the file to play.

The second way I tried was to make Netjuke work with PocketIE like so, just open the play.php file and change line 165 from this:
Code:
header ("Content-type: audio/x-mpegurl\r\nContent-Disposition: inline; filename=netjuke-".substr(time(),-7).".m3u" );
to this:
Code:
header ("Content-type: audio/x-mpegurl\r\nContent-Disposition: attachment; filename=netjuke-".substr(time(),-7).".m3u" );
The problem with doing this is you now have to manually open the .m3u file on both your PPC and your desktop machine which I did not consider acceptable as it fixes 1 problem and creates 2 more.

Before I show you how to solve this problem lets take a minute to fix up Pocket IE/Betaplayer so that we can play a file from the web instead of saving it to disk. You will need a WinCE registry editor for this bit so if you don't have one already grab PHM Registry Editor and install it on your Axim. Now open your registry and navigate to \HKEY_CLASSES_ROOT\Betaplayer there should be a value already there named Default containing the value Betaplayer. On the Edit menu tap "New DWORD Value" and for Value Name enter EditFlags, change the Base to Hexadecimal and enter 10010000 in the Value Data box. Tap OK and now there should be two values in the lower pane, Pocket IE will now open any file on the web that is associated with Betaplayer directly in Betaplayer without showing the usual save dialog.

You can do the same for GSPlayer by adding the same key and value at \HKEY_CLASSES_ROOT\GSPlayer Playlist but this is unecessary as Betaplayer can handle HTTP streams perfectly well.

Now to fix play.php properly, open it up and insert the following code at line 371:
Code:
######################################

function IsIE4CE() {

 # Check if the server is being accessed by Pocket IE for Windows CE as it
 # handles the content-disposition header differently to desktop browsers
 
   $out = false;
   $client = strtoupper($_SERVER['HTTP_USER_AGENT']);

   if( eregi('MSIE 4.01',$client) && eregi('WINDOWS CE',$client) ) $out = true;           
   return $out;
};
Now replace line 164 with these two lines:
Code:
	if (IsIE4CE()) header ("Content-type: audio/x-mpegurl\r\nContent-Disposition: attachment; filename=netjuke-".substr(time(),-7).".m3u" );
	else header ("Content-type: audio/x-mpegurl\r\nContent-Disposition: inline; filename=netjuke-".substr(time(),-7).".m3u" );
And that's it! You don't have to restart Apache as the changes will occur next time you try to play a file. The above code change tricks Pocket IE into downloading the playlist with the correct name while leaving desktop browsers to handle the download as per the original script.

Happy streaming!

P.S. Don't forget to clear out the playlist files from 'My Documents' every so often as they can make a mess.

Last edited by OddbOd; 04-30-05 at 04:04 AM.
OddbOd is offline   Reply With Quote