ÿþ/ /   B a t m o s p h e r e   E m b e d d e d   M e d i a   P l a y e r ,   v e r s i o n   2 0 0 6 - 0 5 - 3 1    
 / /   W r i t t e n   b y   D a v i d   B a t t i n o ,   w w w . b a t m o s p h e r e . c o m  
 / /   O K   t o   u s e   i f   t h i s   n o t i c e   i s   i n c l u d e d  
 / /   T h i s   f u n c t i o n   r e a d s   a n   M P 3   U R L   a n d   t i t l e   f r o m   t h e   r e f e r r i n g   p a g e   a n d   g e n e r a t e s   e m b e d d i n g   c o d e   t o   p l a y   b a c k   t h e   a u d i o   f i l e .  
 / /   W i n d o w s   b r o w s e r s   ( e x c e p t   f o r   I n t e r n e t   E x p l o r e r )   w i l l   p l a y   b a c k   t h e   f i l e   w i t h   t h e   W i n d o w s   M e d i a   P l a y e r   * p l u g i n . *   I n t e r n e t   E x p l o r e r   w i l l   u s e   W i n d o w s   M e d i a   P l a y e r .  
 / /   N o n - W i n d o w s   b r o w s e r s   w i l l   p l a y   b a c k   t h e   f i l e   w i t h   t h e i r   s t a n d a r d   a u d i o   h a n d l e r   f o r   t h e   M I M E   t y p e   a u d i o / m p e g .   O n   M a c s ,   t h a t   h a n d l e r   w i l l   u s u a l l y   b e   Q u i c k T i m e .  
  
 v a r   a u d i o F o l d e r   =   " " ;   / /   I f   y o u   h a v e   a   d e f a u l t   a u d i o   d i r e c t o r y ,   e . g . ,   h t t p : / / w w w . y o u r - m e d i a - h o s t i n g - s i t e . c o m / s o u n d s / ,   y o u   c a n   p u t   i t   h e r e   t o   m a k e   l i n k s   o n   t h e   r e f e r r i n g   p a g e   s h o r t e r .  
  
 f u n c t i o n   e m b e d P l a y e r ( M P 3 t i t l e , M P 3 U R L )   {    
       / /   G e t   O p e r a t i n g   S y s t e m    
       v a r   i s W i n   =   n a v i g a t o r . u s e r A g e n t . t o L o w e r C a s e ( ) . i n d e x O f ( " w i n d o w s " )   ! =   - 1 ;  
       i f   ( i s W i n )   {   / /   U s e   M I M E   t y p e   a p p l i c a t i o n / x - m p l a y e r 2  
             v i s i t o r O S = " W i n d o w s " ;  
       }   e l s e   {   / /   U s e   M I M E   t y p e   a u d i o / m p e g ,   a u d i o / x - w a v ,   e t c .  
             v i s i t o r O S = " O t h e r " ;  
       }  
  
       v a r   a u d i o U R L   =   a u d i o F o l d e r   +   M P 3 U R L ;  
       v a r   o b j T y p e T a g   =   " a p p l i c a t i o n / x - m p l a y e r 2 " ;   / /   T h e   M I M E   t y p e   t o   l o a d   t h e   W M P   p l u g i n   i n   n o n - I E   b r o w s e r s   o n   W i n d o w s  
       i f   ( v i s i t o r O S   ! =   " W i n d o w s " )   {   o b j T y p e T a g   =   " a u d i o / m p e g " } ;   / /   T h e   M I M E   t y p e   f o r   M a c s   a n d   L i n u x    
      
       d o c u m e n t . w r i t e l n ( " < d i v > " ) ;  
       d o c u m e n t . w r i t e l n ( " < s t r o n g   s t y l e = ' f o n t - s i z e : 1 8 p x ;   p o s i t i o n : r e l a t i v e ;   t o p : - 2 8 p x ' > "   +   M P 3 t i t l e   +   " & n b s p ; < / s t r o n g > " ) ;     / /   A d j u s t   f o n t   s t y l e   t o   t a s t e  
       d o c u m e n t . w r i t e l n ( " < o b j e c t   w i d t h = ' 2 8 0 '   h e i g h t = ' 6 9 ' > " ) ;   / /   W i d t h   i s   t h e   W M P   m i n i m u m .   H e i g h t   =   4 5   ( W M P   c o n t r o l s )   +   2 4   ( W M P   s t a t u s   b a r )    
       d o c u m e n t . w r i t e l n ( " < p a r a m   n a m e = ' t y p e '   v a l u e = ' "   +   o b j T y p e T a g   +   " ' > " ) ;  
       d o c u m e n t . w r i t e l n ( " < p a r a m   n a m e = ' s r c '   v a l u e = ' "   +   a u d i o U R L   +   " ' > " ) ;  
       d o c u m e n t . w r i t e l n ( " < p a r a m   n a m e = ' a u t o s t a r t '   v a l u e = ' 0 ' > " ) ;  
       d o c u m e n t . w r i t e l n ( " < p a r a m   n a m e = ' s h o w c o n t r o l s '   v a l u e = ' 1 ' > " ) ;  
       d o c u m e n t . w r i t e l n ( " < p a r a m   n a m e = ' s h o w s t a t u s b a r '   v a l u e = ' 1 ' > " ) ;  
       d o c u m e n t . w r i t e l n ( " < e m b e d   s r c   = ' "   +   a u d i o U R L   +   " '   t y p e = ' "   +   o b j T y p e T a g   +   " '   a u t o p l a y = ' f a l s e '   a u t o s t a r t = ' 0 '   w i d t h = ' 2 8 0 '   h e i g h t = ' 6 9 '   c o n t r o l l e r = ' 1 '   s h o w s t a t u s b a r = ' 1 '   b g c o l o r = ' # f f f f f f ' > < / e m b e d > " ) ;    
        
       / /   F i r e f o x   a n d   O p e r a   W i n   r e q u i r e   b o t h   a u t o s t a r t   a n d   a u t o p l a y  
       d o c u m e n t . w r i t e l n ( " < / o b j e c t > " ) ;  
       d o c u m e n t . w r i t e l n ( " < / d i v > " ) ;  
       d o c u m e n t . c l o s e ( ) ;   / /   F i n a l i z e s   t h e   d o c u m e n t  
 } 
