/*
 * MediaProvider.fx
 *
 * Created on 14.05.2009, 20:48:34
 */

package stack3d.providers;

import java.util.Arrays;
import java.util.List;


/**
 * @author KAM
 */

public abstract class MediaProvider {

    public abstract void requestMedia(long firstId, long lastId, Callback callback);

    public static class Callback {

        public void onMediaLoaded(List<MediaInfo> media) { }

        public void onError(Exception e) { }

        public void onEndOfMedia() { }

        public final void mediaLoaded(final MediaInfo[] media) {
            final List mediaList = Arrays.asList(media);
            onMediaLoaded(mediaList);
        }

        public final void error(final Exception e) {
            onError(e);
        }

        public final void endOfMedia() {
            onEndOfMedia();
        }

    }

}

