package org.jerrymouse.cc.site.view.display;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.jerrymouse.cc.site.bean.Resource;
import org.jerrymouse.cc.site.bean.Type;
import org.jerrymouse.cc.site.web.utils.WebUtil;
import org.jerrymouse.cc.utils.ResourceBuilder;

public class HTML5VideoDisplayer implements Displayer {

	public String getName() {
		return "HTML5Video";
	}

	public List<Type> support() {
		String[] s = { "flv", "mov", "3gp", "mp4", "ogv", "rm", "swf", };
		return Type.createTypes(s);
	}

	public DisplayResult display(Resource resource) {
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("title", resource.getFilename());
		String urlBase = WebUtil.urlBase;
		map.put("url", urlBase + "/user/" + resource.getUser().getUsername()
				+ "/storage/" + resource.getFilename() + "?type=ogv");
		String content = ResourceBuilder.getResourcesBuilder().vm(
				"htmlvideo.htm", map);
		return new DisplayResult(content);
	}

}
