| 1 |
package perf; |
| 2 |
|
| 3 |
import java.util.ArrayList; |
| 4 |
import java.util.List; |
| 5 |
|
| 6 |
public class MediaItem |
| 7 |
{ |
| 8 |
public Media media; |
| 9 |
public List<Image> images; |
| 10 |
|
| 11 |
public MediaItem() { } |
| 12 |
|
| 13 |
public MediaItem addPhoto(Image i) { |
| 14 |
if (images == null) { |
| 15 |
images = new ArrayList<Image>(); |
| 16 |
} |
| 17 |
images.add(i); |
| 18 |
return this; |
| 19 |
} |
| 20 |
|
| 21 |
static MediaItem buildItem() |
| 22 |
{ |
| 23 |
Media content = new Media(); |
| 24 |
content.player = Player.JAVA; |
| 25 |
content.uri = "http://javaone.com/keynote.mpg"; |
| 26 |
content.title = "Javaone Keynote"; |
| 27 |
content.width = 640; |
| 28 |
content.height = 480; |
| 29 |
content.format = "video/mpeg4"; |
| 30 |
content.duration = 18000000L; |
| 31 |
content.size = 58982400L; |
| 32 |
content.bitrate = 262144; |
| 33 |
content.copyright = "None"; |
| 34 |
content.addPerson("Bill Gates"); |
| 35 |
content.addPerson("Steve Jobs"); |
| 36 |
|
| 37 |
MediaItem item = new MediaItem(); |
| 38 |
item.media = content; |
| 39 |
|
| 40 |
item.addPhoto(new Image("http://javaone.com/keynote_large.jpg", "Javaone Keynote", 1024, 768, Size.LARGE)); |
| 41 |
item.addPhoto(new Image("http://javaone.com/keynote_small.jpg", "Javaone Keynote", 320, 240, Size.SMALL)); |
| 42 |
|
| 43 |
return item; |
| 44 |
} |
| 45 |
} |
| 46 |
|
| 47 |
enum Size { SMALL, LARGE }; |
| 48 |
|
| 49 |
class Image |
| 50 |
{ |
| 51 |
public Image() { } |
| 52 |
public Image(String uri, String title, int w, int h, Size s) { |
| 53 |
this.uri = uri; |
| 54 |
this.title = title; |
| 55 |
width = w; |
| 56 |
height = h; |
| 57 |
size = s; |
| 58 |
} |
| 59 |
|
| 60 |
public String uri; |
| 61 |
public String title; |
| 62 |
public int width, height; |
| 63 |
public Size size; |
| 64 |
} |
| 65 |
|
| 66 |
enum Player { JAVA, FLASH; } |
| 67 |
|
| 68 |
class Media { |
| 69 |
|
| 70 |
public String uri; |
| 71 |
public String title; // Can be unset. |
| 72 |
public int width; |
| 73 |
public int height; |
| 74 |
public String format; |
| 75 |
public long duration; |
| 76 |
public long size; |
| 77 |
public int bitrate; // Can be unset. |
| 78 |
// public boolean hasBitrate; |
| 79 |
|
| 80 |
public List<String> persons; |
| 81 |
|
| 82 |
public Player player; |
| 83 |
|
| 84 |
public String copyright; // Can be unset. |
| 85 |
|
| 86 |
public Media addPerson(String p) { |
| 87 |
if (persons == null) { |
| 88 |
persons = new ArrayList<String>(); |
| 89 |
} |
| 90 |
persons.add(p); |
| 91 |
return this; |
| 92 |
} |
| 93 |
} |