64 return true;
65 }
66 return (enabledPlatforms.indexOf(name.toLowerCase()) != -1);
67 }
68
69 private static final class PlatformManagerInitializer {
70 private static final PlatformManager globalInstance = new PlatformManager();
71 }
72
73 public static PlatformManager getManager() {
74 return PlatformManagerInitializer.globalInstance;
75 }
76
77 private final List<Platform> platforms;
78
79 private PlatformManager() {
80 platforms = new ArrayList<Platform>();
81
82 Platform platty;
83
84 // Now "universal" platform(s)
85 if (isPlatformEnabled("JavaPlatform")) {
86 platty = JavaPlatform.getPlatformInstance();
87 if (null != platty) {
88 platforms.add(platty);
89 }
90 }
91
92 if (!HostUtils.isIOS() && isPlatformEnabled("GSTPlatform")) {
93 platty = GSTPlatform.getPlatformInstance();
94 if (null != platty) {
95 platforms.add(platty);
96 }
97 }
98
99 // Add after GSTPlatform so it's used as a fallback
100 if (HostUtils.isMacOSX() && isPlatformEnabled("OSXPlatform")) {
101 platty = OSXPlatform.getPlatformInstance();
102 if (null != platty) {
103 platforms.add(platty);
104 }
105 }
106
107 if (HostUtils.isIOS() && isPlatformEnabled("IOSPlatform")) {
108 platty = IOSPlatform.getPlatformInstance();
109 if (null != platty) {
110 platforms.add(platty);
111 }
112 }
113
114 if (Logger.canLog(Logger.DEBUG)) {
115 StringBuilder sb = new StringBuilder("Enabled JFXMedia platforms: ");
116 for (Platform p : platforms) {
117 sb.append("\n - ");
118 sb.append(p.getClass().getName());
119 }
120 Logger.logMsg(Logger.DEBUG, sb.toString());
121 }
122 }
123
124 public synchronized void preloadPlatforms() {
125 for (Platform platty : platforms) {
126 platty.preloadPlatform();
127 }
128 }
129
130 public synchronized void loadPlatforms() {
131 // Use an iterator so we can remove on failure
132 Iterator<Platform> iter = platforms.iterator();
133 while (iter.hasNext()) {
134 Platform platty = iter.next();
135 if (!platty.loadPlatform()) {
136 if (Logger.canLog(Logger.DEBUG)) {
137 Logger.logMsg(Logger.DEBUG, "Failed to load platform: "+platty);
138 }
139 // remove it so it can't be reused
140 iter.remove();
141 }
142 }
143 }
144
145 public List<String> getSupportedContentTypes() {
146 ArrayList<String> outTypes = new ArrayList<String>();
147
148 if (!platforms.isEmpty()) {
149 for (Platform platty : platforms) {
150 String[] npt = platty.getSupportedContentTypes();
151 if (npt != null) {
152 for (String type : npt) {
153 if (!outTypes.contains(type)) {
154 outTypes.add(type);
155 }
156 }
157 }
158 }
159 }
160
161 return outTypes;
162 }
163
164 public MetadataParser createMetadataParser(Locator source) {
165 for (Platform platty : platforms) {
166 MetadataParser parser = platty.createMetadataParser(source);
167 if (parser != null) {
168 return parser;
169 }
|
64 return true;
65 }
66 return (enabledPlatforms.indexOf(name.toLowerCase()) != -1);
67 }
68
69 private static final class PlatformManagerInitializer {
70 private static final PlatformManager globalInstance = new PlatformManager();
71 }
72
73 public static PlatformManager getManager() {
74 return PlatformManagerInitializer.globalInstance;
75 }
76
77 private final List<Platform> platforms;
78
79 private PlatformManager() {
80 platforms = new ArrayList<Platform>();
81
82 Platform platty;
83
84 /*
85 * We don't want to fully initialize the platforms here for performance
86 * reasons but some platforms may be dependent on native resources that
87 * need to be loaded, those platforms need to be given a chance to load
88 * those resources (without initializing) and determine if the natives
89 * are available.
90 */
91
92 // Now "universal" platform(s)
93 if (isPlatformEnabled("JavaPlatform")) {
94 platty = JavaPlatform.getPlatformInstance();
95 if (null != platty) {
96 platforms.add(platty);
97 }
98 }
99
100 if (!HostUtils.isIOS() && isPlatformEnabled("GSTPlatform")) {
101 platty = GSTPlatform.getPlatformInstance();
102 if (null != platty) {
103 platforms.add(platty);
104 }
105 }
106
107 // Add after GSTPlatform so it's used as a fallback
108 if (HostUtils.isMacOSX() && isPlatformEnabled("OSXPlatform")) {
109 platty = OSXPlatform.getPlatformInstance();
110 if (null != platty) {
111 platforms.add(platty);
112 }
113 }
114
115 if (HostUtils.isIOS() && isPlatformEnabled("IOSPlatform")) {
116 platty = IOSPlatform.getPlatformInstance();
117 if (null != platty) {
118 platforms.add(platty);
119 }
120 }
121
122 if (Logger.canLog(Logger.DEBUG)) {
123 StringBuilder sb = new StringBuilder("Enabled JFXMedia platforms: ");
124 for (Platform p : platforms) {
125 sb.append("\n - ");
126 sb.append(p.getClass().getName());
127 }
128 Logger.logMsg(Logger.DEBUG, sb.toString());
129 }
130 }
131
132 public synchronized void loadPlatforms() {
133 // Use an iterator so we can remove on failure
134 Iterator<Platform> iter = platforms.iterator();
135 while (iter.hasNext()) {
136 Platform platty = iter.next();
137 if (!platty.loadPlatform()) {
138 if (Logger.canLog(Logger.DEBUG)) {
139 Logger.logMsg(Logger.DEBUG, "Failed to load platform: "+platty);
140 }
141 // remove it so it can't be reused
142 iter.remove();
143 }
144 }
145 }
146
147 public List<String> getSupportedContentTypes() {
148 ArrayList<String> outTypes = new ArrayList<String>();
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 }
|