public BLMovie(String filename) throws BMovieException, IOException, FileNotFoundException {
		
		this.isGzip = GZIPDetector.isGZIPFile(new File(filename));
		if (this.isGzip) {
			System.out.println("movie appears to be gzip!");
		} else {
			System.out.println("move is not gzip");
		}
		frames = new LinkedList<Frame>();
		
		if(filename.length() < 5) {
			System.out.println("BLMovie filename is invalid: " + filename);
			return;
		}
		
		String suffix;
		if (filename.toLowerCase().endsWith(".gz")) {
			suffix = filename.substring(filename.length() - 6, filename.length()-3);			
		} else {
			suffix = filename.substring(filename.length() - 3, filename.length());
		}
		
		// FIXME: this is not a good way to detect the file type!
		if(suffix.toUpperCase().equals("BLM")) {
			parseLegacyMovie(filename);
		}
		// FIXME: this is not a good way to detect the file type!		
		else if(suffix.toUpperCase().equals("BML")) {
			ElementParser ep = new ElementParser(frames);
			SAXParserFactory spf = SAXParserFactory.newInstance();
			SAXParser sp = null;

				try {
					sp = spf.newSAXParser();
					InputStream input;
					if (this.isGzip) {
						input = new GZIPInputStream(new FileInputStream(filename));
					} else {
						input = new FileInputStream(filename);
					}
					sp.parse(input, ep);
					input.close();
				} catch (ParserConfigurationException e) {
					throw new BMovieException(e);
				} catch (SAXException e) {
					throw new BMovieException(e);
				} catch (IOException e) {
					throw new BMovieException(e);
				}
		}
		else {
			System.err.println("file format not supported: " + suffix);
		}
	}