1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: Manager.java,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
32 import com
.sun
.star
.uno
.UnoRuntime
;
33 import com
.sun
.star
.uno
.XComponentContext
;
34 import com
.sun
.star
.uno
.AnyConverter
;
35 import com
.sun
.star
.uno
.IQueryInterface
;
36 import com
.sun
.star
.lang
.XInitialization
;
39 import com
.sun
.star
.media
.*;
41 public class Manager
implements com
.sun
.star
.lang
.XServiceInfo
,
42 com
.sun
.star
.lang
.XTypeProvider
,
43 com
.sun
.star
.media
.XManager
46 private com
.sun
.star
.lang
.XMultiServiceFactory maFactory
;
48 // -------------------------------------------------------------------------
50 public Manager( com
.sun
.star
.lang
.XMultiServiceFactory aFactory
)
59 public com
.sun
.star
.media
.XPlayer
createPlayer( String aURL
)
61 javax
.media
.Player aPlayer
= null;
65 aPlayer
= javax
.media
.Manager
.createRealizedPlayer( new java
.net
.URL( aURL
) );
67 catch( java
.net
.MalformedURLException e
)
70 catch( java
.io
.IOException e
)
73 catch( javax
.media
.NoPlayerException e
)
76 catch( javax
.media
.CannotRealizeException e
)
79 catch( java
.lang
.Exception e
)
85 return new Player( maFactory
, aPlayer
, aURL
);
95 private static final String s_implName
= "com.sun.star.comp.media.Manager_Java";
96 private static final String s_serviceName
= "com.sun.star.media.Manager_Java";
98 public synchronized String
getImplementationName()
103 // -------------------------------------------------------------------------
105 public synchronized String
[] getSupportedServiceNames()
107 return new String
[] { s_serviceName
};
110 // -------------------------------------------------------------------------
112 public synchronized boolean supportsService( String serviceName
)
114 return serviceName
.equals( s_serviceName
);
120 protected byte[] maImplementationId
;
122 public com
.sun
.star
.uno
.Type
[] getTypes()
124 com
.sun
.star
.uno
.Type
[] retValue
= new com
.sun
.star
.uno
.Type
[ 3 ];
126 retValue
[ 0 ]= new com
.sun
.star
.uno
.Type( com
.sun
.star
.lang
.XServiceInfo
.class );
127 retValue
[ 1 ]= new com
.sun
.star
.uno
.Type( com
.sun
.star
.lang
.XTypeProvider
.class );
128 retValue
[ 2 ]= new com
.sun
.star
.uno
.Type( com
.sun
.star
.media
.XManager
.class );
133 // -------------------------------------------------------------------------
135 synchronized public byte[] getImplementationId()
137 if( maImplementationId
== null)
139 maImplementationId
= new byte[ 16 ];
141 int hash
= hashCode();
143 maImplementationId
[ 0 ] = (byte)(hash
& 0xff);
144 maImplementationId
[ 1 ] = (byte)((hash
>>> 8) & 0xff);
145 maImplementationId
[ 2 ] = (byte)((hash
>>> 16) & 0xff);
146 maImplementationId
[ 3 ] = (byte)((hash
>>>24) & 0xff);
149 return maImplementationId
;