package com.sola.instagram.model;

import java.util.List;

import org.json.JSONException;
import org.json.JSONObject;

import com.sola.instagram.model.Media;

public class VideoMedia extends Media {

	/** 
	 * Low resolution version of the media's video
	 */
	protected Video lowResolutionVideo;
	
	/**
	 * Standard resolution version of the media's video
	 */
	protected Video standardResolutionVideo;
	
	public VideoMedia(JSONObject obj, String accessToken) throws JSONException {
		super(obj, accessToken);
		
		JSONObject videos = obj.getJSONObject("videos");
	 	this.setLowResolutionVideo(this.new Video(videos.getJSONObject("low_resolution")));
	 	this.setStandardResolutionVideo(this.new Video(videos.getJSONObject("standard_resolution")));
	}

	public Video getLowResolutionVideo() {
		return lowResolutionVideo;
	}

	protected void setLowResolutionVideo(Video lowResolutionVideo) {
		this.lowResolutionVideo = lowResolutionVideo;
	}

	public Video getStandardResolutionVideo() {
		return standardResolutionVideo;
	}

	protected void setStandardResolutionVideo(Video standardResolutionVideo) {
		this.standardResolutionVideo = standardResolutionVideo;
	}

	/**
	 * Object for a media video
	 * with the JSON representation
	 * <pre>
	 * 		{
	 * 			"url":"",
	 * 			"width":0,
	 * 			"height":0
	 * 		}
	 * </pre>
	 * @author Sola Ogunsakin
	 * @version 2013-08-17
	 */
	public class Video {
		/**
		 * Link to this image
		 */
		String uri;
		
		/**
		 * Width of this image
		 */
		int width;
		
		/**
		 * Height of this image
		 */
		int heigth;
	
	    /**
	     * Makes a new Video object out of a JSONObject
	     * @param obj json object used to create this video
	     * @throws JSONException
	     */
		public Video(JSONObject obj) throws JSONException {
			this.setUri(obj.getString("url"));
			this.setWidth(obj.getInt("width"));
			this.setHeigth(obj.getInt("height"));
		}
		
	    /**
	     * Returns the url link to this image
	     * @return The url link to this image 
	     */
		public String getUri() {
			return uri;
		}

	    /**
	     * Sets this image's url
	     * @param url url for this image 
	     */
		protected void setUri(String uri) {
			this.uri = uri;
		}
	
	    /**
	     * Returns the width of this image
	     * @return The width of this image 
	     */
		public int getWidth() {
			return width;
		}
		
	    /**
	     * Sets this image's width
	     * @param width width of this image 
	     */
		protected void setWidth(int width) {
			this.width = width;
		}
		
	    /**
	     * Returns the height of this image
	     * @return The height of this image 
	     */
		public int getHeigth() {
			return heigth;
		}
		
	    /**
	     * Sets this image's height
	     * @param height height of this image 
	     */
		protected void setHeigth(int heigth) {
			this.heigth = heigth;
		}

	    /**
	     * Checks if two image objects are equal
	     * @param o The object to be compared 
	     * @return True of the two objects are equal, false otherwise
	     */
		public boolean equals(Object o) {
			if(o == null) return false;
			if(o == this) return true;
			if(o.getClass() != this.getClass()) return false;
			return ((VideoMedia.Video)o).getUri().equals(getUri());
		}
	}
}

@@ -1412,29 +1412,29 @@
 ink to this 
-image
+video
 %0A%09%09 */%0A%09%09Str
@@ -1462,37 +1462,37 @@
 * Width of this 
-image
+video
 %0A%09%09 */%0A%09%09int wid
@@ -1524,21 +1524,21 @@
 of this 
-image
+video
 %0A%09%09 */%0A%09
@@ -1931,29 +1931,29 @@
 ink to this 
-image
+video
 %0A%09     * @re
@@ -1974,29 +1974,29 @@
 ink to this 
-image
+video
  %0A%09     */%0A%09
@@ -2068,21 +2068,21 @@
 ts this 
-image
+video
 's url%0A%09
@@ -2108,29 +2108,29 @@
 rl for this 
-image
+video
  %0A%09     */%0A%09
@@ -2226,37 +2226,37 @@
 e width of this 
-image
+video
 %0A%09     * @return
@@ -2266,37 +2266,37 @@
 e width of this 
-image
+video
  %0A%09     */%0A%09%09pub
@@ -2367,21 +2367,21 @@
 ts this 
-image
+video
 's width
@@ -2408,37 +2408,37 @@
 h width of this 
-image
+video
  %0A%09     */%0A%09%09pro
@@ -2545,21 +2545,21 @@
 of this 
-image
+video
 %0A%09     *
@@ -2578,37 +2578,37 @@
  height of this 
-image
+video
  %0A%09     */%0A%09%09pub
@@ -2681,21 +2681,21 @@
 ts this 
-image
+video
 's heigh
@@ -2733,21 +2733,21 @@
 of this 
-image
+video
  %0A%09     
@@ -2855,13 +2855,13 @@
 two 
-image
+video
  obj

fix comments