2 * Copyright 2007 ZXing authors
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package com.google.zxing.client.j2me;
19 import javax.microedition.media.Controllable;
22 * <p>This class encapsulates optional multimedia-related operations that the device
23 * may support, like setting focus and zoom. This implementation itself will do nothing.
24 * It will attempt to dynamically instantiate {@link com.google.zxing.client.j2me.AdvancedMultimediaManager}
25 * which has methods that call JSR-234 APIs to actually set focus, zoom, etc. If successful,
26 * this class will delegate to that implementation. But if the phone does not support these
27 * APIs, instantiation will simply fail and this implementation will do nothing.</p>
29 * <p>Credit to Paul Hackenberger for the nice workaround</p>
31 * @author Sean Owen (srowen@google.com)
32 * @author Paul Hackenberger
34 class DefaultMultimediaManager implements MultimediaManager {
36 private MultimediaManager advancedMultimediaManager;
38 DefaultMultimediaManager() {
40 advancedMultimediaManager = (MultimediaManager)
41 Class.forName("com.google.zxing.client.j2me.AdvancedMultimediaManager").newInstance();
42 } catch (ClassNotFoundException cnfe) {
44 } catch (IllegalAccessException iae) {
46 } catch (InstantiationException ie) {
51 public void setFocus(Controllable player) {
52 if (advancedMultimediaManager != null) {
53 advancedMultimediaManager.setFocus(player);
57 public void setZoom(Controllable player) {
58 if (advancedMultimediaManager != null) {
59 advancedMultimediaManager.setZoom(player);
63 public void setExposure(Controllable player) {
64 if (advancedMultimediaManager != null) {
65 advancedMultimediaManager.setExposure(player);