FileDocCategorySizeDatePackage
TrackListModel.javaAPI Docmp4parser 1.0-RC-172203Wed Dec 19 20:10:21 GMT 2012com.coremedia.iso.gui

TrackListModel

public class TrackListModel extends AbstractListModel

Fields Summary
com.coremedia.iso.IsoFile
isoFile
com.coremedia.iso.boxes.MovieBox
movieBox
List
trackFragmentBoxList
Set
trackIds
Constructors Summary
public TrackListModel(com.coremedia.iso.IsoFile isoFile)


       
        this.isoFile = isoFile;
        final List<MovieBox> movieBoxList = isoFile.getBoxes(MovieBox.class);
        if (movieBoxList.isEmpty()) {
            trackFragmentBoxList = isoFile.getBoxes(TrackFragmentBox.class, true);
            if (trackFragmentBoxList != null) {
                for (TrackFragmentBox trackFragmentBox : trackFragmentBoxList) {
                    trackIds.add(trackFragmentBox.getTrackFragmentHeaderBox().getTrackId());
                }
            }
        } else {
            movieBox = movieBoxList.get(0);
            final long[] trackNumbers = movieBox.getTrackNumbers();
            for (long trackNumber : trackNumbers) {
                trackIds.add(trackNumber);
            }
        }
    
Methods Summary
public java.lang.ObjectgetElementAt(int index)

        if (movieBox != null) {
            return movieBox.getBoxes(TrackBox.class).get(index);
        } else {
            for (TrackFragmentBox trackFragmentBox : trackFragmentBoxList) {
                //todo we always return the first one - that's not perfect
                final TrackFragmentHeaderBox trackFragmentHeaderBox = trackFragmentBox.getTrackFragmentHeaderBox();
                if (trackFragmentHeaderBox.getTrackId() == trackIds.toArray(new Long[trackIds.size()])[index]) {
                    return trackFragmentBox;
                }
            }
        }
        return null;
    
public intgetSize()

        if (movieBox == null) {
            return trackIds.size();
        } else {
            return movieBox.getBoxes(TrackBox.class).size();
        }