01: /*
02: * Jacareto Copyright (c) 2002-2005
03: * Applied Computer Science Research Group, Darmstadt University of
04: * Technology, Institute of Mathematics & Computer Science,
05: * Ludwigsburg University of Education, and Computer Based
06: * Learning Research Group, Aachen University. All rights reserved.
07: *
08: * Jacareto is free software; you can redistribute it and/or
09: * modify it under the terms of the GNU General Public
10: * License as published by the Free Software Foundation; either
11: * version 2 of the License, or (at your option) any later version.
12: *
13: * Jacareto is distributed in the hope that it will be useful,
14: * but WITHOUT ANY WARRANTY; without even the implied warranty of
15: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16: * General Public License for more details.
17: *
18: * You should have received a copy of the GNU General Public
19: * License along with Jacareto; if not, write to the Free
20: * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21: *
22: */
23:
24: package jacareto.replay.mediaplayer;
25:
26: import jacareto.track.block.BlockType;
27:
28: /**
29: * Implementation of the MediaPlayerFactory interface to create different players.
30: *
31: * @author Oliver Specht
32: * @version $revision$
33: */
34: public class DefaultMediaPlayerFactory implements MediaPlayerFactory {
35: /** The factory instance */
36: private static final DefaultMediaPlayerFactory INSTANCE = new DefaultMediaPlayerFactory();
37:
38: private DefaultMediaPlayerFactory() {
39: }
40:
41: /**
42: * Returns the only instance of DefaultMediaPlayerFactory
43: *
44: * @return DefaultMediaPlayerFactory
45: */
46: public static DefaultMediaPlayerFactory getInstance() {
47: if (DefaultMediaPlayerFactory.INSTANCE == null) {
48: return new DefaultMediaPlayerFactory();
49: }
50:
51: return DefaultMediaPlayerFactory.INSTANCE;
52: }
53:
54: /**
55: * {@inheritDoc}
56: */
57: public MediaPlayer createPlayer(BlockType type) {
58: if (type.equals(BlockType.AUDIO)) {
59: return new AudioPlayer();
60: } else if (type.equals(BlockType.VIDEO)) {
61: return new VideoPlayer();
62: }
63:
64: return null;
65: }
66:
67: /**
68: * {@inheritDoc}
69: */
70: public MediaPlayer createPlayer(BlockType type, String filename) {
71: if (type.equals(BlockType.AUDIO)) {
72: return new AudioPlayer(filename);
73: } else if (type.equals(BlockType.VIDEO)) {
74: return new VideoPlayer(filename);
75: }
76:
77: return null;
78: }
79: }
|