1 /*
2 * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
149
150 if (!platforms.isEmpty()) {
151 for (Platform platty : platforms) {
152 if (Logger.canLog(Logger.DEBUG)) {
153 Logger.logMsg(Logger.DEBUG, "Getting content types from platform: "+platty);
154 }
155 String[] npt = platty.getSupportedContentTypes();
156 if (npt != null) {
157 for (String type : npt) {
158 if (!outTypes.contains(type)) {
159 outTypes.add(type);
160 }
161 }
162 }
163 }
164 }
165
166 return outTypes;
167 }
168
169 public MetadataParser createMetadataParser(Locator source) {
170 for (Platform platty : platforms) {
171 MetadataParser parser = platty.createMetadataParser(source);
172 if (parser != null) {
173 return parser;
174 }
175 }
176
177 return null;
178 }
179
180 // FIXME: Make Media non-platform specific, it doesn't need to be
181 public Media createMedia(Locator source) {
182 String mimeType = source.getContentType();
183 // go down the list until we get one that can be created
184 for (Platform platty : platforms) {
185 if (platty.canPlayContentType(mimeType)) {
186 Media outMedia = platty.createMedia(source);
187 if (null != outMedia) {
188 return outMedia;
189 }
190 }
191 }
192
193 return null;
194 }
195
196 public MediaPlayer createMediaPlayer(Locator source) {
197 String mimeType = source.getContentType();
198 // go down the list until we get one that can be created
199 for (Platform platty : platforms) {
200 if (platty.canPlayContentType(mimeType)) {
201 MediaPlayer outPlayer = platty.createMediaPlayer(source);
202 if (null != outPlayer) {
203 return outPlayer;
204 }
205 }
206 }
207
208 return null;
209 }
210 }
|
1 /*
2 * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
149
150 if (!platforms.isEmpty()) {
151 for (Platform platty : platforms) {
152 if (Logger.canLog(Logger.DEBUG)) {
153 Logger.logMsg(Logger.DEBUG, "Getting content types from platform: "+platty);
154 }
155 String[] npt = platty.getSupportedContentTypes();
156 if (npt != null) {
157 for (String type : npt) {
158 if (!outTypes.contains(type)) {
159 outTypes.add(type);
160 }
161 }
162 }
163 }
164 }
165
166 return outTypes;
167 }
168
169 public List<String> getSupportedProtocols() {
170 ArrayList<String> outProtocols = new ArrayList<String>();
171
172 if (!platforms.isEmpty()) {
173 for (Platform platty : platforms) {
174 String[] npt = platty.getSupportedProtocols();
175 if (npt != null) {
176 for (String p : npt) {
177 if (!outProtocols.contains(p)) {
178 outProtocols.add(p);
179 }
180 }
181 }
182 }
183 }
184
185 return outProtocols;
186 }
187
188 public MetadataParser createMetadataParser(Locator source) {
189 for (Platform platty : platforms) {
190 MetadataParser parser = platty.createMetadataParser(source);
191 if (parser != null) {
192 return parser;
193 }
194 }
195
196 return null;
197 }
198
199 // FIXME: Make Media non-platform specific, it doesn't need to be
200 public Media createMedia(Locator source) {
201 String mimeType = source.getContentType();
202 String protocol = source.getProtocol();
203 // go down the list until we get one that can be created
204 for (Platform platty : platforms) {
205 if (platty.canPlayContentType(mimeType) && platty.canPlayProtocol(protocol)) {
206 Media outMedia = platty.createMedia(source);
207 if (null != outMedia) {
208 return outMedia;
209 }
210 }
211 }
212
213 return null;
214 }
215
216 public MediaPlayer createMediaPlayer(Locator source) {
217 String mimeType = source.getContentType();
218 String protocol = source.getProtocol();
219 // go down the list until we get one that can be created
220 for (Platform platty : platforms) {
221 if (platty.canPlayContentType(mimeType) && platty.canPlayProtocol(protocol)) {
222 MediaPlayer outPlayer = platty.createMediaPlayer(source);
223 if (null != outPlayer) {
224 return outPlayer;
225 }
226 }
227 }
228
229 return null;
230 }
231 }
|