osx
HTML5 Media, Seeking and the Buffered Attribute
It can be very exciting playing with new technologies, HTML5 media being a case in point. The spec is still evolving and although native audio and video have only been about for little over a year in any useable form, we are already seeing browsers makers pushing the envelope and developers rushing to create new libraries.
We aim to incorporate features into the jPlayer library as they become available. Recently we have been looking at browser’s ability to jump to a point in a track that has not yet downloaded. A seeking of sorts. All the major HTML5 supporting browsers allow this type of seek (with the exception of Safari for Windows), but at the moment it seems only Chrome and Safari (both mobile and desktop versions) have taken this a step further by implementing the buffered attribute, although Firefox 4 also does, it is still in beta.
The buffered attribute allows us to determine what parts of a media track have been buffered so that we can seek or skip directly to that part without the need to pause.
More info on the buffered attribute can be found in this article HTML5 video ‘buffered’ property available in Firefox 4
Mark B
Configuring Apache with Tomcat on OSX Leopard
Note that to start serving Java and run Java based web applications it is not essential to use Apache. Tomcat is a perfectly good http server and is even used by many in a production environment, however it is more common to separate concerns, leaving Apache to deal with the serving of static pages and Tomcat to deal with any application logic. This set up can also more easily facilitate load-balancing. Add to this the increasing popularity of using Apache’s .htaccess files to transform querystrings to more search engine readable URLs and you might find yourself with compelling reasons to get Apache and Tomcat talking.
For those interested in the debate – Do I still need Apache Httpd? is worth a read.
You will need to have Tomcat already installed – fortunately there are already various excellent tutorials on how to do this scattered around the web.
To start with, it may be worth detailing where the various parts of the pre-installed Apache system are in OSX.
(I’m running Mac OS X Version 10.5.6 – Leopard)
Web root (htdocs) : |
/Library/Webserver/Documents |
Configuration file : |
/private/etc/apache2/http.conf |
Apache Log files : |
/private/var/log/apache2/ |
System Log file : |
/private/var/log/system.log |
Modules : |
/usr/libexec/apache2/ |
Apache Binary : |
/usr/sbin/apachectl |
Root in a browser : |
http://localhost/ |
You might also find it useful to log in as root unless you are happy using sudo.
It also might be an idea to show hidden files in finder, to do this type:
defaults write com.apple.Finder AppleShowAllFiles YES
at a command line and restart Finder.
To start / restart apache:
Apple menu -> System Preferences -> Sharing -> Web Sharing (tickbox)
Activating / deactivating the tickbox effectively starts and stops Apache.
Or at the command line you can type any of the following:
apachectl start apachectl stop apachectl restart
You can verify that Apache has started by going to http://localhost/ in your browser and checking that the Apache default page appears.
So what do we have to do to get Apache and Tomcat talking to each other? First we need a connector. Currently there is a lot of discussion in the community over whether to use mod_jk or mod_proxy.
I’m going to start with mod_jk
Unfortunately the version available at the apache site (1.2.25) for Mac OSX is not compatible with Leopard.
If you want to create a version that is, you will need to build your own or download a pre-compiled version for Leopard – as kindly provided here – although you do this at your own risk.
Once you have downloaded/created a compatible version of mod_jk, rename the file mod_jk.so place in the modules directory and change the permissions to 755 with:
chmod mod_jk.so 755
(you will need to place sudo in front of this if you are not logged in as root).
Next, create a folder for the mod_jk log file to be written to. I created a directory : private/var/log/mod_jk
Open the http.conf (Note you may want to make a backup of this file before editing it). Locate the area in the file where the modules are loaded. (You should find may lines starting with the text LoadModule). Append your own LoadModule line :
LoadModule jk_module libexec/apache2/mod_jk.so
add to this the location of the log file:
JkLogFile /private/var/log/mod_jk/mod_jk.log
(This is assuming that your modules reside in libexec/apache2/ otherwise you will need to specify your own modules directory.)
Next it might be prudent to check that Apache is still working, so start it or restart it and point your browser at http://localhost/ If you are no longer seeing the apache page you should check /private/var/log/system.log and/or /private/var/log/apache2/error.log for clues.
Also, check that the mod_jk.log file has been created.
Now we need to define a workers.properties file and put this in /private/etc/apache2/mod_jk/
A workers.properties file is effectively a listener for Apache which tells it when to redirect requests to Tomcat. Mine looks like this:
workers.tomcat_home=/Library/tomcat/tomcat55 workers.java_home=/System/Library/Frameworks/JavaVM.framework/Versions/Current worker.list=ajp13 worker.ajp13.port=8009 worker.ajp13.host=localhost worker.ajp13.type=ajp13
Note that I often have different versions of Tomcat installed on my system which is why my workers.tomcat_home points at /Library/tomcat/tomcat55 but you should point at it a wherever you have installed Tomcat on your system.
Finally, tell Apache about your workers.properties file and a few other things so replace the lines you have added to httpd.conf with the following:
# mod_jk configuration LoadModule jk_module libexec/apache2/mod_jk.so # path to workers.properties file JkWorkersFile /etc/apache2/mod_jk/workers.properties # path to mod_jk log file JkLogFile /private/var/log/mod_jk/mod_jk.log # mod_jk log level [debug/error/info] JkLogLevel info # mod_jk log format JkLogStampFormat "[%a %b %d %H:%M:%S %Y] " # patterns for mounting JkMount /servlet/* ajp13 JkMount /*.jsp ajp13 # end mod_jk configuration
Restart Apache and you should be in business!
I’ll maybe come back and tackle mod_proxy but for now I’ll point you towards Michael Scepaniak’s recent article mod_jk fail, mod_proxy success.
MarkB
Configuring Leopard’s Apache to work with all Rewrite Rules
Although there are a few blog posts out there detailing how to enable .htaccess on Mac OSX 10.5. I didn’t find anything that could help me with a problem I had with a specific RewriteRule.
This post isn’t specific to Leopard but maybe useful to users of this OS due to the default values that it’s pre-installed Apache’s httpd.conf comes set with.
Say for SEO reasons you wanted to rewrite
product.php?id=17
as
product/toaster/17.html
You could use the following rewrite rule:
RewriteRule ^product/([a-zA-Z0-9_-]+)/([0-9]+)\.html$ product.php?id=$2
In other blogs it will tell you that you will need to change AllowOverride None to AllowOverride All in the <Directory “/Library/Webserver/Documents”> of /private/etc/apache2/httpd.conf and perhaps also in any conf files found in /private/etc/apache2/users. (This is not enabled by default on Leopard).
What they won’t neccesarily tell you is that to get rewrite rules like the above working you need to remove MultiViews from your Options list, leaving you with something like this :
<Directory "/Library/Webserver/Documents"> Options Indexes FollowSymLinks AllowOverride All Order allow,deny Allow from all </Directory>
I hope this saves someone the trouble I went through this morning trying to figure it out.
For a quick explanation see the short but sweet Apache Multiviews are evil
MarkB
Previous Posts
- The Hyperaudio Pad – Next Steps and Media Literacy
- Breaking Out – The Making Of
- Breaking Out – Web Audio and Perceptive Media
- Altrepreneurial vs Entrepreneurial and Why I am going to Work with Al Jazeera
- HTML5 Audio APIs – How Low can we Go?
- Hyperaudio at the Mozilla Festival
- The Hyperaudio Pad – a Software Product Proposal
- Introducing the Hyperaudio Pad (working title)
- Accessibility, Community and Simplicity
- Build First, Ask Questions Later
- Further Experimentation with Hyper Audio
- Hyper Audio – A New Way to Interact
- P2P Web Apps – Brace yourselves, everything is about to change
- A few HTML5 questions that need answering
- Drumbeat Demo – HTML5 Audio Text Sync
Tag Cloud
-
Add new tag
AJAX
apache
Audio
band
buffered
Canvas
CDN
chrome
community
custom tags
firefox
gig
HTC
HTML5
Hyper Audio
internet explorer
java
javascript
journalism
jPlayer
jQuery
jscript
LABjs
leopard
media
Mozilla
MVP
opera
opera mini
osx
P2P
Popcorn.js
poster
prototyping
rewrite
safari
Scaling
simplicity
SoundCloud
timers
tomcat
video
Web Apps
web design