Listing 1 may help you with a concrete example of querying user agent.
The concept of "media queries", where the browser reports properties such as screen size, is also introduced as a way of moving beyond querying for every possible user agent string.
Hope you find the article and some of the concepts useful for your project.
As far as any other advice, if delivering video to iPad, not Flash capable, you may also be interested in this article regarding a workaround using object tags.