├── vid
└── video.mp4
├── img
├── poster.jpg
├── poster.psd
└── resize.png
├── swf
└── vidobject.swf
├── vidobject_source
├── VidObject.fla
└── com
│ └── johnpolacek
│ ├── events
│ ├── TrackEvent.as
│ └── UIEvent.as
│ ├── shapes
│ ├── Frame.as
│ ├── Line.as
│ ├── BitmapNoiseRectangle.as
│ ├── ArrowHead.as
│ ├── ArrowBlock.as
│ ├── EllipseShape.as
│ ├── RectangleShape.as
│ └── RectangleGradientShape.as
│ ├── display
│ ├── ContentDisplay.as
│ ├── ImageDisplay.as
│ ├── VideoDisplay.as
│ ├── AudioDisplay.as
│ └── ContentDisplayCreator.as
│ ├── utils
│ ├── StringUtils.as
│ └── DisplayUtils.as
│ ├── ui
│ ├── BasicButton.as
│ ├── PlayPauseButton.as
│ ├── VolumeControl.as
│ ├── FullScreenButton.as
│ ├── ProgressBar.as
│ └── FullScreenScrollbar.as
│ └── media
│ ├── VidObject.as
│ └── VideoStreamPlayer.as
├── README.md
├── css
└── main.css
├── index.html
└── js
└── simplevid.js
/vid/video.mp4:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/johnpolacek/SimpleVid/HEAD/vid/video.mp4
--------------------------------------------------------------------------------
/img/poster.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/johnpolacek/SimpleVid/HEAD/img/poster.jpg
--------------------------------------------------------------------------------
/img/poster.psd:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/johnpolacek/SimpleVid/HEAD/img/poster.psd
--------------------------------------------------------------------------------
/img/resize.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/johnpolacek/SimpleVid/HEAD/img/resize.png
--------------------------------------------------------------------------------
/swf/vidobject.swf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/johnpolacek/SimpleVid/HEAD/swf/vidobject.swf
--------------------------------------------------------------------------------
/vidobject_source/VidObject.fla:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/johnpolacek/SimpleVid/HEAD/vidobject_source/VidObject.fla
--------------------------------------------------------------------------------
/vidobject_source/com/johnpolacek/events/TrackEvent.as:
--------------------------------------------------------------------------------
1 | package com.johnpolacek.events {
import flash.events.Event;
/**
* TrackEvent is used to dispatch google analytics tracking info
*
* @version 15 Jun 2010
* @author John Polacek, john@johnpolacek.com
*/
public class TrackEvent extends Event {
public var trackAction:String;
public var trackLabel:String;
public static const TRACK:String = "TRACK";
public function TrackEvent(type:String, action:String, label:String, bubbles:Boolean = true, cancelable:Boolean = false) {
super(type, bubbles,cancelable);
trackAction = action;
trackLabel = label;
}
public override function clone():Event
{
return new TrackEvent(type, this.trackAction, this.trackLabel, bubbles, cancelable);
}
}
}
--------------------------------------------------------------------------------
/vidobject_source/com/johnpolacek/shapes/Frame.as:
--------------------------------------------------------------------------------
1 | package com.johnpolacek.shapes {
import flash.display.Sprite;
import flash.display.Shape;
import flash.display.LineScaleMode;
import flash.display.JointStyle;
/**
* The Frame class is used to quickly create Rectangle sprites with a line, but no fill
*
* @example
*
* Create a 50x50 frame with a 3-pixel black line.
* var frame:Frame = new Frame(50);
*
* Create a 200x50 frame with a 1-pixel red line.
* var frame:Frame = new Frame(200, 50, 0xFF0000, 1);
*
* @author John Polacek, john@johnpolacek.com
*/
public class Frame extends Sprite {
public function Frame (w:Number, h:Number = 0, color:uint = 0x000000, thickness:int = 3)
{
var shape:Shape = new Shape();
addChild(shape);
shape.graphics.lineStyle(thickness, color, 1, false, LineScaleMode.NONE);
shape.graphics.lineTo(w, 0);
shape.graphics.lineTo(w, h);
shape.graphics.lineTo(0, h);
shape.graphics.lineTo(0, 0);
shape.x = shape.y = -.5;
}
}
}
--------------------------------------------------------------------------------
/vidobject_source/com/johnpolacek/display/ContentDisplay.as:
--------------------------------------------------------------------------------
1 | package com.johnpolacek.display {
import flash.events.Event;
import flash.events.IOErrorEvent;
import flash.display.Sprite;
/**
* Abstract class for displaying various types of content (audio, video, images, flash)
* in various ways (audio players, image slideshows, etc.)
*
* @see com.johnpolacek.display.ContentDisplayCreator
*
* @version
* 16 Apr 2010 Improved error handling
* 7 Mar 2010
* @author John Polacek, john@johnpolacek.com
*/
public class ContentDisplay extends Sprite {
public function ContentDisplay()
{
}
/** Dispatches Event.COMPLETE */
public function onLoadComplete(event:Event):void
{
dispatchEvent(new Event(Event.COMPLETE));
}
/** Catches IOError Events for broken filepaths */
public function onIOError(event:IOErrorEvent):void
{
dispatchEvent(event);
trace("ContentDisplay Error: "+event.text);
}
/** Remove event listeners and clear children */
public function destroy():void
{
while (this.numChildren > 0)
removeChildAt(0);
}
}
}
--------------------------------------------------------------------------------
/vidobject_source/com/johnpolacek/shapes/Line.as:
--------------------------------------------------------------------------------
1 | package com.johnpolacek.shapes {
import flash.display.Sprite;
import flash.display.Shape;
import flash.display.LineScaleMode;
import flash.display.JointStyle;
/**
* The Line class is used to quickly create Line sprites
*
* @example
*
* Create a line 700 pixels wide.
* var line:Line = new Line(700);
*
* Create a red line 700 pixels wide with a thickness of 3 pixels
* and 50% transparency that is aligned to center.
* var line:Line = new Line(700, 3, 0xFF0000, .5, true);
*
* @author John Polacek, john@johnpolacek.com
*/
public class Line extends Sprite {
public function Line (w:Number,
strokeThickness:int = 1,
strokeColor:uint = 0x000000,
strokeAlpha:Number = 1,
alignToCenter:Boolean = false)
{
var shape:Shape = new Shape();
addChild(shape);
if (strokeThickness > 0)
shape.graphics.lineStyle(strokeThickness, strokeColor, strokeAlpha, false, LineScaleMode.NONE, null, JointStyle.MITER);
shape.graphics.lineTo(w, 0);
if (alignToCenter) shape.x -= w/2;
}
}
}
--------------------------------------------------------------------------------
/vidobject_source/com/johnpolacek/shapes/BitmapNoiseRectangle.as:
--------------------------------------------------------------------------------
1 | package com.johnpolacek.shapes {
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.BitmapDataChannel;
import flash.display.Sprite;
import flash.display.Shape;
import flash.display.LineScaleMode;
import flash.display.JointStyle;
/**
* BitmapNoiseRectangle class is used to quickly create rectangles filled with Bitmap noise
*
* @example
*
* Create a 80x50 rectangle filled with some noise
* var noiseRect:BitmapNoiseRectangle = new BitmapNoiseRectangle(80, 50, 2);
*
* @author John Polacek, john@johnpolacek.com
*/
/**
* @param w Width of rectangle
* @param h Width of rectangle
* @param n Noise level of rectangle. Default 1
*/
public class BitmapNoiseRectangle extends Sprite {
public function BitmapNoiseRectangle (w:Number,
h:Number,
n:Number = 1)
{
var bmd:BitmapData = new BitmapData(w / 2, h / 2);
bmd.noise(1, 0, 0xFFFFFF, BitmapDataChannel.ALPHA, false);
var bitmap:Bitmap = new Bitmap(bmd);
bitmap.alpha = .04 * n;
bitmap.scaleX = bitmap.scaleY = 2;
addChild(bitmap);
}
}
}
--------------------------------------------------------------------------------
/vidobject_source/com/johnpolacek/shapes/ArrowHead.as:
--------------------------------------------------------------------------------
1 | package com.johnpolacek.shapes {
import flash.display.Sprite;
import flash.display.Shape;
import flash.display.LineScaleMode;
import flash.display.JointStyle;
/**
* ArrowHead class is used to quickly create arrowhead shapes
*
* @example
*
* Create a 10x20 arrowhead shape
* var arrowHead:ArrowHead = new ArrowHead(10, 20);
*
* Create a 10x20 6-pixel thick, red arrowhead shape,
* with 50% transparency, aligned to center
* var arrowHead:ArrowHead = new ArrowHead(10, 20, 6, 0xFF0000, .5, true);
*
* @author John Polacek, john@johnpolacek.com
*/
public class ArrowHead extends Sprite {
public function ArrowHead (w:Number,
h:Number,
strokeThickness:int = 3,
strokeColor:uint = 0x000000,
strokeAlpha:Number = 1,
alignToCenter:Boolean = false)
{
var line:Shape = new Shape();
line.graphics.lineStyle(strokeThickness, strokeColor);
line.graphics.lineTo(w, h/2);
line.graphics.lineTo(0, h);
line.alpha = strokeAlpha;
addChild(line);
if (alignToCenter)
{
line.x = -w/2;
line.y = -h/2;
}
}
}
}
--------------------------------------------------------------------------------
/vidobject_source/com/johnpolacek/utils/StringUtils.as:
--------------------------------------------------------------------------------
1 | package com.johnpolacek.utils {
/**
* Utilities for working with Strings
*
* @author John Polacek, john@johnpolacek.com
*/
public class StringUtils {
/** Capitalizes the initial character of each word of a given string. */
public static function toTitleCase(str:String):String
{
var words:Array = str.split(" ");
var n:int = words.length;
for (var i:int = 0; i < n; i++)
{
words[i] = toInitialCap(words[i]);
}
return (words.join(" "));
}
/** Capitalizes the initial character of the given string. */
public static function toInitialCap(original:String):String
{
return original.charAt(0).toUpperCase() + original.substr(1).toLowerCase();
}
/** Returns the characters after the last (.) of a given string (e.g. .jpg). */
public static function getFileExtension(fileName:String):String
{
var ext:String = fileName.substr(fileName.lastIndexOf(".")+1);
return ext;
}
/** Removes line breaks from string and then returns the string. */
public static function removeLineBreaks(txt:String):String
{
var lineBreaks:RegExp = /\n/g;
txt = txt.replace(lineBreaks, "");
return txt;
}
}
}
--------------------------------------------------------------------------------
/vidobject_source/com/johnpolacek/shapes/ArrowBlock.as:
--------------------------------------------------------------------------------
1 | package com.johnpolacek.shapes {
import flash.display.Sprite;
import flash.display.Shape;
import flash.display.LineScaleMode;
import flash.display.JointStyle;
/**
* ArrowHead class is used to quickly create arrowhead shapes
*
* @example
*
* Creates an arrow that fits in a square
* var arrowBlock:ArrowBlock = new ArrowBlock(10);
*
* Create a 20x20 3-pixel thick, red arrow,
* with 50% transparency, aligned to center
* var arrowBlock:ArrowBlock = new ArrowBlock(20, 3, 0xFF0000, .5, true);
*
* @author John Polacek, john@johnpolacek.com
*/
public class ArrowBlock extends Sprite {
public function ArrowBlock (size:Number,
strokeThickness:int = 3,
strokeColor:uint = 0x000000,
strokeAlpha:Number = 1,
alignToCenter:Boolean = false)
{
var head:Shape = new Shape();
head.graphics.lineStyle(strokeThickness, strokeColor);
head.graphics.lineTo(size, 0);
head.graphics.lineTo(size, size);
head.alpha = strokeAlpha;
addChild(head);
var line:Shape = new Shape();
line.graphics.lineStyle(strokeThickness, strokeColor);
line.graphics.moveTo(0, size);
line.graphics.lineTo(size, 0);
line.alpha = strokeAlpha;
addChild(line);
if (alignToCenter)
line.x = line.y = head.x = head.y = -size/2;
}
}
}
--------------------------------------------------------------------------------
/vidobject_source/com/johnpolacek/events/UIEvent.as:
--------------------------------------------------------------------------------
1 | package com.johnpolacek.events {
import flash.events.Event;
/**
* A UIEvent object is generated by media display components and can be used
* to pass number values (e.g. progress percent)
*
* @version 4 Apr 2010
* @author John Polacek, john@johnpolacek.com
*/
public class UIEvent extends Event {
/** Number passed via the UIEvent */
public var value:Number;
public static const PROGRESS_UPDATE:String = "progressUpdate";
public static const LOAD_COMPLETE:String = "loadComplete";
public static const VOLUME_ADJUST:String = "volumeAdjust";
public static const PLAY_CLICK:String = "playClick";
public static const PAUSE_CLICK:String = "pauseClick";
public static const PLAYBACK_START:String = "playbackStart";
public static const PLAYBACK_FINISH:String = "playbackFinish";
public static const SCROLLBAR_MOVE:String = "scrollbarMove";
public static const BUTTON_SELECT:String = "buttonSelect";
public static const DROPDOWN_SELECT:String = "dropdownSelect";
public static const FULL_SCREEN_CONTENT:String = "fullScreenContent";
public static const FULL_SCREEN_CONTENT_ENTER:int = 1;
public static const FULL_SCREEN_CONTENT_EXIT:int = 0;
public function UIEvent(type:String, val:Number = 0, bubbles:Boolean = true, cancelable:Boolean = false) {
super(type, bubbles,cancelable);
value = val;
}
public override function clone():Event
{
return new UIEvent(type, this.value, bubbles, cancelable);
}
}
}
--------------------------------------------------------------------------------
/vidobject_source/com/johnpolacek/shapes/EllipseShape.as:
--------------------------------------------------------------------------------
1 | package com.johnpolacek.shapes {
import flash.display.Sprite;
import flash.display.Shape;
import flash.display.LineScaleMode;
import flash.display.JointStyle;
/**
* EllipseShape class is used to quickly create Elliptical sprites
*
* @example
*
* Create a 50x50 circle
* var circle:EllipseShape = new EllipseShape(50);
*
* Create a 200x50 ellipse with a 50% transparent black fill,
* a 3-pixel red stroke, aligned to center
* var ellipse:EllipseShape = new EllipseShape(200, 50, 0x000000, .5, 3, 0xFF0000, 1, true);
*
* @author John Polacek, john@johnpolacek.com
*/
public class EllipseShape extends Sprite {
public function EllipseShape (w:Number,
h:Number = 0,
fillColor:uint = 0x000000,
fillAlpha:Number = 1,
strokeThickness:int = 0,
strokeColor:uint = 0x000000,
strokeAlpha:Number = 1,
alignToCenter:Boolean = false)
{
var shape:Shape = new Shape();
if (h==0)
h = w;
addChild(shape);
if (strokeThickness > 0)
shape.graphics.lineStyle(strokeThickness, strokeColor, strokeAlpha, false, LineScaleMode.NONE, null, JointStyle.MITER);
shape.graphics.beginFill(fillColor, fillAlpha);
shape.graphics.drawEllipse(alignToCenter ? -w/2 : 0, alignToCenter ? -h/2 : 0, w, h);
shape.graphics.endFill();
}
public function alignToCenter():void
{
var shape:Shape = Shape(this.getChildAt(0));
shape.x = -shape.width/2;
shape.y = -shape.height/2;
}
}
}
--------------------------------------------------------------------------------
/vidobject_source/com/johnpolacek/display/ImageDisplay.as:
--------------------------------------------------------------------------------
1 | package com.johnpolacek.display {
import flash.display.Sprite;
import flash.display.Loader;
import flash.display.Bitmap;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.events.IOErrorEvent;
import flash.events.ProgressEvent;
import flash.net.URLRequest;
import flash.net.navigateToURL;
import flash.system.LoaderContext;
/**
* Loads and displays images. (.jpg, .gif, .png)
*
* @version
* 1 Apr 2010 Added contentInfo object property
* 7 Mar 2010
* @author John Polacek, john@johnpolacek.com
*/
public class ImageDisplay extends ContentDisplay
{
/** Object that can be used to store variables */
public var contentInfo = {};
private var imageLoader:Loader = new Loader();
/**
* @param filepath url of the image.
**/
public function ImageDisplay(filepath:String)
{
trace("ImageDisplay "+filepath);
var loaderContext:LoaderContext = new LoaderContext();
loaderContext.checkPolicyFile = true;
imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoadComplete);
imageLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, onIOError);
//imageLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgress);
imageLoader.load(new URLRequest(filepath), loaderContext);
}
/** Enables bitmap smoothing and dispatches Event.COMPLETE */
override public function onLoadComplete(event:Event):void
{
trace("ImageDisplay.onLoadComplete");
var bit:Bitmap = Bitmap(imageLoader.content);
if (bit != null)
{
addChild(bit);
bit.smoothing = true;
}
dispatchEvent(new Event(Event.COMPLETE));
}
}
}
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | #Responsive Video
2 |
3 | jQuery Plugin for a video player that scales to fit its container
4 |
5 | ##How to Use
6 |
7 | Add video element to your html inside a container div that is styled to scale with the size of the browser window
8 |
9 |
var square:RectangleShape = new RectangleShape(50);
*
* Create a 200x50 rectangle with a 50% transparent black fill,
* a 3-pixel red stroke that has 18-pixel rounded corners, aligned to center
* var rect:RectangleShape = new RectangleShape(200, 50, 0x000000, .5, 3, 0xFF0000, 1, true, 18);
*
* @author John Polacek, john@johnpolacek.com
*/
public class RectangleShape extends Sprite {
public function RectangleShape (w:Number,
h:Number = 0,
fillColor:uint = 0x000000,
fillAlpha:Number = 1,
strokeThickness:int = 0,
strokeColor:uint = 0x000000,
strokeAlpha:Number = 1,
alignToCenter:Boolean = false,
roundedCornerAmount = 0)
{
var shape:Shape = new Shape();
addChild(shape);
if (h==0)
h = w;
if (strokeThickness > 0)
shape.graphics.lineStyle(strokeThickness, strokeColor, strokeAlpha, false, LineScaleMode.NONE, null, JointStyle.MITER);
shape.graphics.beginFill(fillColor, fillAlpha);
if (roundedCornerAmount == 0)
shape.graphics.drawRect(alignToCenter ? -w/2 : 0, alignToCenter ? -h/2 : 0, w, h);
else
shape.graphics.drawRoundRect(alignToCenter ? -w/2 : 0, alignToCenter ? -h/2 : 0, w, h, roundedCornerAmount);
shape.graphics.endFill();
}
public function alignToCenter():void
{
var shape:Shape = Shape(this.getChildAt(0));
shape.x = -shape.width/2;
shape.y = -shape.height/2;
}
}
}
--------------------------------------------------------------------------------
/vidobject_source/com/johnpolacek/shapes/RectangleGradientShape.as:
--------------------------------------------------------------------------------
1 | package com.johnpolacek.shapes {
import flash.display.GradientType;
import flash.display.JointStyle;
import flash.display.LineScaleMode;
import flash.display.Shape;
import flash.display.Sprite;
import flash.geom.Matrix;
/**
* RectangleGradientShape class is used to quickly create Rectangle sprites with simple linear gradients.
*
* @example
* var gradRect:RectangleGradientShape = new RectangleGradientShape(80, 50, 0xFFFFFF, 0xCCCCCC, 1, 1, 2, 0xAAAAAA, 1, false, Math.PI/2, 18);
*
* @author John Polacek, john@johnpolacek.com
*/
public class RectangleGradientShape extends Sprite {
public function RectangleGradientShape (w:Number,
h:Number = 0,
fillColor1:uint = 0x000000,
fillColor2:uint = 0xFFFFFF,
fillAlpha1:Number = 1,
fillAlpha2:Number = 1,
strokeThickness:int = 0,
strokeColor:uint = 0x000000,
strokeAlpha:Number = 1,
alignToCenter:Boolean = false,
rotation:Number = Math.PI/2,
roundedCornerAmount = 0)
{
var shape:Shape = new Shape();
addChild(shape);
if (h==0)
h = w;
if (strokeThickness > 0)
shape.graphics.lineStyle(strokeThickness, strokeColor, strokeAlpha, false, LineScaleMode.NONE, null, JointStyle.MITER);
var colors:Array = [fillColor1, fillColor2];
var alphas:Array = [fillAlpha1, fillAlpha2];
var ratios:Array = [0, 255];
var matr:Matrix = new Matrix();
matr.createGradientBox(w, h, rotation);
shape.graphics.beginGradientFill(GradientType.LINEAR, colors, alphas, ratios, matr);
if (roundedCornerAmount == 0)
shape.graphics.drawRect(alignToCenter ? -w/2 : 0, alignToCenter ? -h/2 : 0, w, h);
else
shape.graphics.drawRoundRect(alignToCenter ? -w/2 : 0, alignToCenter ? -h/2 : 0, w, h, roundedCornerAmount);
shape.graphics.endFill();
}
public function alignToCenter():void
{
var shape:Shape = Shape(this.getChildAt(0));
shape.x = -shape.width/2;
shape.y = -shape.height/2;
}
}
}
--------------------------------------------------------------------------------
/css/main.css:
--------------------------------------------------------------------------------
1 | body {
2 | color: #333;
3 | padding: 0;
4 | margin: 0;
5 | font-family: Georgia, serif;
6 | }
7 |
8 | #wrapper {
9 | margin: 0 auto;
10 | padding: 40px 40px 30px;
11 | width: 75%;
12 | text-align: center;
13 | }
14 |
15 | #container {
16 | width: 90%;
17 | background-color: #111;
18 | margin: 0 auto;
19 | }
20 |
21 | /* Remove firefox dotted focus outline */
22 | a, a:hover, a:active, a:focus, object, embed {
23 | outline: 0;
24 | }
25 |
26 | h1, h2, h3 {
27 | margin: 5px 0;
28 | padding: 0;
29 | }
30 |
31 | h1 a, h2 a {
32 | text-decoration: none;
33 | }
34 |
35 | h1 {
36 | font-size: 40px;
37 | }
38 |
39 | h2 {
40 | font-size: 20px;
41 | }
42 |
43 | h2 small a {
44 | color: #999;
45 | font-weight: normal;
46 | text-decoration: underline;
47 | }
48 |
49 | h3 {
50 | font-size: 20px;
51 | font-weight: normal;
52 | font-style: italic;
53 | }
54 |
55 | h4 {
56 | font-size: 30px;
57 | text-align: center;
58 | }
59 |
60 | a {
61 | font-style: italic;
62 | color: #222;
63 | }
64 |
65 | .demo {
66 | border-top: dashed 1px #ccc;
67 | border-bottom: dashed 1px #ccc;
68 | }
69 |
70 | .demo p {
71 | padding: 20px;
72 | }
73 |
74 | .description {
75 | margin: 30px 0;
76 | }
77 |
78 | .guide {
79 | margin: 30px 0;
80 | }
81 |
82 | .parameters {
83 | list-style: none;
84 | font-size: 14px;
85 | text-align: left;
86 | width: 400px;
87 | margin: 0 auto;
88 | }
89 |
90 | blockquote {
91 | margin: 10px 0;
92 | text-align: left;
93 | padding: 10px 0 10px 20px;
94 | border: solid 1px #ddd;
95 | }
96 |
97 | pre {
98 | white-space: pre-wrap;
99 | white-space: -moz-pre-wrap;
100 | white-space: -pre-wrap;
101 | white-space: -o-pre-wrap;
102 | }
103 |
104 | .thanks {
105 | margin: 80px 0 20px;
106 | }
107 | .download, .github, .authors {
108 | margin: 40px 0 20px;
109 | font-size: 14px;
110 | font-style: italic;
111 | }
112 |
113 | .download-link, .github-link, .author-link {
114 | font-size: 18px;
115 | padding: 10px;
116 | color: #888;
117 | }
118 |
119 | .footer {
120 | border-top: dashed 1px #ccc;
121 | margin: 60px -30px 0;
122 | }
123 |
124 | .footer a, footer a:visited {
125 | color: #bbb;
126 | font-size: 36px;
127 | line-height: 1.6;
128 | padding: 20px;
129 | }
130 |
131 | .footer a:hover {
132 | color: #aaa;
133 | }
134 |
135 | #resize-graphic {
136 | position: fixed;
137 | bottom: 0;
138 | right: 0;
139 | opacity: .6;
140 | }
--------------------------------------------------------------------------------
/vidobject_source/com/johnpolacek/ui/BasicButton.as:
--------------------------------------------------------------------------------
1 | package com.johnpolacek.ui {
import flash.display.BlendMode;
import flash.display.Sprite;
import flash.events.MouseEvent;
import com.greensock.TweenLite;
import com.greensock.plugins.TweenPlugin;
import com.greensock.plugins.ColorTransformPlugin;
/**
* The BasicButton class is used to create basic buttons that
* contain a buttonValue property that can be used to store a string value.
*
* For example, use BasicButton objects for creating a menu and on
* click events use the buttonValue property to load new sections.
* Or assign a filename to the buttonValue property to initiate lightbox content.
*
* By default, BasicButtons have MOUSE_OUT and MOUSE_OVER events
* which toggle the transparency between .8(out) and 1(over) which
* is deactivated if the select(true); method is called.
*
* @example
* import com.johnpolacek.ui.BasicButton;
* import com.johnpolacek.shapes.RectangleShape;
*
* var exampleButton:BasicButton = new BasicButton("A string stored by the button");
* var buttonShape:Sprite = new RectangleShape(50);
* exampleButton.addChild(buttonShape);
*
*
* @author John Polacek, john@johnpolacek.com
*/
public class BasicButton extends Sprite
{
public var buttonValue:String;
public var baseAlpha:Number = .9;
public var rolloverAlpha:Number = 1;
public var rolloverColor:String;
public var selectColor:String;
private var isSelected:Boolean = false;
public function BasicButton(val:String = "",
enableSimpleRollovers:Boolean = true,
ba:Number = .9,
ra:Number = 1,
rc:String = null,
sc:String = null)
{
TweenPlugin.activate([ColorTransformPlugin]);
buttonValue = val;
this.buttonMode = true;
this.blendMode = BlendMode.LAYER;
if (enableSimpleRollovers)
addSimpleRollovers(ba, ra, rc, sc);
}
public function addSimpleRollovers(ba:Number = .9, ra:Number = 1, rc:String = null, sc:String = null):void
{
baseAlpha = ba;
rolloverAlpha = ra;
rolloverColor = rc;
selectColor = sc;
this.alpha = baseAlpha;
addEventListener(MouseEvent.MOUSE_OVER,onOver);
addEventListener(MouseEvent.MOUSE_OUT,onOut);
}
private function onOver(event:MouseEvent):void
{
this.alpha = rolloverAlpha;
if (rolloverColor)
{
TweenLite.to(this, 0, {colorTransform:{tint:uint(rolloverColor)}});
}
}
private function onOut(event:MouseEvent):void
{
if (!isSelected)
this.alpha = baseAlpha;
if (rolloverColor)
TweenLite.to(this, 0, {colorTransform:{tintAmount:0}});
}
public function select(sel:Boolean = true):void
{
isSelected = sel;
if (isSelected)
{
this.alpha = rolloverAlpha;
if (selectColor)
TweenLite.to(this, 0, {colorTransform:{tint:uint(selectColor)}});
}
else
{
this.alpha = baseAlpha;
if (selectColor)
TweenLite.to(this, 0, {colorTransform:{tintAmount:0}});
}
}
}
}
--------------------------------------------------------------------------------
/vidobject_source/com/johnpolacek/display/VideoDisplay.as:
--------------------------------------------------------------------------------
1 | package com.johnpolacek.display {
import flash.display.Sprite;
import flash.display.Loader;
import flash.events.Event;
import flash.events.IOErrorEvent;
import flash.net.URLRequest;
import flash.net.navigateToURL;
import com.johnpolacek.media.VideoStreamPlayer;
/**
* Loads and displays video via NetStream (flv and h264)
*
* @example
* import com.johnpolacek.display.VideoDisplay;
* var video:VideoDisplay = new VideoDisplay();
* video.loadVideo("example.flv");
*
* Example with styling:
*
* import com.johnpolacek.display.VideoDisplay;
* var video:VideoDisplay = new VideoDisplay();
* video.autoPlay = false;
* video.autoRewind = true;
* video.buttonColor = 0xFFCC99;
* video.backgroundColor = 0x333355;
* video.loadVideo("example.flv");
* video.addPoster("poster.jpg");
* addChild(video);
*
*
* @see com.johnpolacek.media.VideoStreamPlayer;
* @version
* 8 Mar 2010
* @author John Polacek, john@johnpolacek.com
*/
public class VideoDisplay extends ContentDisplay
{
/** The video player */
public var player:VideoStreamPlayer;
/** Boolean for video controls visibility. Default is true. */
public var showControls:Boolean = true;
/** Player button color. Default is 0xFFFFFF */
public var buttonColor:uint = 0xFFFFFF;
/** Player background color. Default is 0x000000 */
public var backgroundColor:uint = 0x000000;
/** Player accent color. Default is 0x000000 */
public var accentColor:uint = 0x999999;
/** Default is true. */
public var autoPlay:Boolean = true;
/** Default is false. */
public var autoRewind:Boolean = false;
/** @param videoURL url of the video. **/
public function VideoDisplay()
{
player = new VideoStreamPlayer();
player.addEventListener(IOErrorEvent.IO_ERROR, onIOError);
}
/** @param videoURL url of the video. **/
public function loadVideo(videoURL:String)
{
player.autoRewind = autoRewind;
player.buttonColor = buttonColor;
player.backgroundColor = backgroundColor;
player.accentColor = accentColor;
player.loadVideo(videoURL, autoPlay);
if (showControls)
player.addController();
player.addEventListener(Event.COMPLETE, onLoadComplete);
addChild(player);
if (showControls)
player.addController(); // adds default controls to player
}
/** Dispatches Event.COMPLETE */
override public function onLoadComplete(event:Event):void
{
dispatchEvent(new Event(Event.COMPLETE));
player.removeEventListener(IOErrorEvent.IO_ERROR, onIOError);
player.removeEventListener(Event.COMPLETE, onLoadComplete);
}
/** @param posterURL url of the poster. **/
public function addPoster(posterURL:String):void
{
player.autoRewind = true;
player.autoPlay = false;
player.addPoster(posterURL);
}
override public function destroy():void
{
if (player)
player.destroy();
while (this.numChildren > 0)
removeChildAt(0);
player = null;
}
}
}
--------------------------------------------------------------------------------
/vidobject_source/com/johnpolacek/ui/PlayPauseButton.as:
--------------------------------------------------------------------------------
1 | package com.johnpolacek.ui {
import flash.events.MouseEvent;
import flash.display.Shape;
import flash.display.Sprite;
import com.johnpolacek.events.UIEvent;
import com.johnpolacek.shapes.RectangleShape;
/**
* Play/Pause Toggle Button UI Component
*
* @sends UIEvent.PAUSE_CLICK # On pause button click
* @sends UIEvent.PLAY_CLICK # On play button click
*
* @author John Polacek, john@johnpolacek.com
*/
public class PlayPauseButton extends Sprite {
private var playIcon:Sprite = new Sprite();
private var pauseIcon:Sprite = new Sprite();
private var playState:Boolean = true;
/**
* @param w Width (in pixels) of the PlayPauseButton sprite
* @param h Height (in pixels) of the PlayPauseButton sprite
* @param backgroundColor Background color of the PlayPauseButton sprite. Default 0x000000
* @param buttonColor Button color of the PlayPauseButton sprite. Default 0xFFFFFF
*/
public function PlayPauseButton(w:Number, h:Number, backgroundColor:uint = 0x000000, buttonColor:uint = 0xFFFFFF)
{
this.buttonMode = true;
this.addEventListener(MouseEvent.CLICK, onClick);
this.addEventListener(MouseEvent.MOUSE_OVER, onOver);
this.addEventListener(MouseEvent.MOUSE_OUT, onOut);
var bgr:Sprite = new RectangleShape(w, h, backgroundColor);
var triangle:Shape = new Shape();
triangle.graphics.beginFill(buttonColor);
triangle.graphics.lineTo(w/3, h/6);
triangle.graphics.lineTo(0, w/3);
triangle.graphics.lineTo(0,0);
triangle.graphics.endFill();
triangle.x = -triangle.width/2;
triangle.y = -triangle.height/2;
playIcon.addChild(triangle);
var rect1:Sprite = new RectangleShape(w/12, h/3, buttonColor);
var rect2:Sprite = new RectangleShape(w/12, h/3, buttonColor);
rect1.x = - rect1.width * 1.5;
rect2.x = rect1.x + rect1.width * 2;
rect1.y = rect2.y = -rect1.height/2;
pauseIcon.addChild(rect1);
pauseIcon.addChild(rect2);
pauseIcon.x = playIcon.x = w/2;
pauseIcon.y = playIcon.y = h/2;
addChild(bgr);
addChild(playIcon);
addChild(pauseIcon);
pauseIcon.alpha = playIcon.alpha = .9;
pauseIcon.visible = false;
}
/** Toggles play/pause button visibility (does not transmit UIEvent) */
public function toggle():void
{
pauseIcon.visible = !pauseIcon.visible;
playIcon.visible = !pauseIcon.visible;
}
/** Sets play state. A value of true shows pause button (does not transmit UIEvent) */
public function setPlayState(ps:Boolean):void
{
playState = ps;
if (playState)
{
pauseIcon.visible = true;
playIcon.visible = false;
}
else
{
pauseIcon.visible = false;
playIcon.visible = true;
}
}
/** Gets play state. A value of true means playback is occuring */
public function getPlayState():Boolean
{
return playState;
}
private function onOver(event:MouseEvent):void
{
pauseIcon.alpha = playIcon.alpha = 1;
}
private function onOut(event:MouseEvent):void
{
pauseIcon.alpha = playIcon.alpha = .9;
}
private function onClick(event:MouseEvent):void
{
if (playIcon.visible)
dispatchEvent(new UIEvent(UIEvent.PLAY_CLICK));
else
dispatchEvent(new UIEvent(UIEvent.PAUSE_CLICK));
}
}
}
--------------------------------------------------------------------------------
/vidobject_source/com/johnpolacek/ui/VolumeControl.as:
--------------------------------------------------------------------------------
1 | package com.johnpolacek.ui {
import flash.events.MouseEvent;
import flash.display.Sprite;
import com.johnpolacek.events.UIEvent;
import com.johnpolacek.shapes.RectangleShape;
/**
* Volume Control UI Component
*
* @sends UIEvent.VOLUME_ADJUST # Transmits volume percentage value (from 0 to 1) on user interaction
*
* @author John Polacek, john@johnpolacek.com
*/
public class VolumeControl extends Sprite {
private var container:Sprite = new Sprite();
private var volumeIcon:Sprite = new Sprite();
private var volumeBarsOn:Sprite = new Sprite();
private var volumeBarsOff:Sprite = new Sprite();
private var volumeMask:Sprite = new Sprite();
private var hotSpot:Sprite = new Sprite();
/**
* @param w Width (in pixels) of the VolumeControl sprite
* @param h Height (in pixels) of the VolumeControl sprite
* @param backgroundColor Background color of the VolumeControl sprite. Default 0x000000
* @param buttonColor Button color of the VolumeControl sprite. Default 0xFFFFFF
*/
public function VolumeControl(w:Number, h:Number, backgroundColor:uint = 0x000000, buttonColor:uint = 0xFFFFFF, accentColor:uint = 0xFFFFFF)
{
var bgr:Sprite = new RectangleShape(w, h, backgroundColor);
var blockSize:Number = h/6;
var volumeIconSquare1:RectangleShape = new RectangleShape(blockSize, blockSize, buttonColor);
var volumeIconSquare2:RectangleShape = new RectangleShape(blockSize, blockSize * 2, buttonColor);
volumeIconSquare2.x = volumeIconSquare1.width + 2;
volumeIconSquare2.y = -blockSize/2;
volumeIcon.addChild(volumeIconSquare1);
volumeIcon.addChild(volumeIconSquare2);
for (var i:int = 0; i < 7; i++)
{
var volumeSquareOff:RectangleShape = new RectangleShape(blockSize, blockSize, buttonColor, .5);
volumeSquareOff.x = (blockSize+1)*i;
volumeBarsOff.addChild(volumeSquareOff);
var volumeSquareOn:RectangleShape = new RectangleShape(blockSize, blockSize, accentColor);
volumeSquareOn.x = (blockSize+1)*i;
volumeBarsOn.addChild(volumeSquareOn);
}
volumeMask = new RectangleShape(volumeBarsOn.width, volumeBarsOn.height);
volumeBarsOn.x = volumeBarsOff.x = volumeMask.x = blockSize * 3;
volumeBarsOn.mask = volumeMask;
addChild(bgr);
addChild(container);
container.addChild(volumeIcon);
container.addChild(volumeBarsOff);
container.addChild(volumeBarsOn);
container.addChild(volumeMask);
hotSpot = new RectangleShape(volumeBarsOn.width, h, backgroundColor, 0);
hotSpot.x = volumeBarsOn.x + (blockSize * 2.5);
container.x = (w - container.width)/2;
container.y = (h - blockSize)/2;
addChild(hotSpot);
hotSpot.addEventListener(MouseEvent.MOUSE_DOWN, onDown);
hotSpot.buttonMode = true;
trace("h: "+h);
trace("height: "+this.height);
}
/** Sets volume
* @param v Volume level between 0 (mute) and 1 (max)
*/
public function setVolume(v:Number):void
{
if (v < 0)
v = 0;
if (v > 1)
v = 1;
volumeMask.scaleX = v;
dispatchEvent(new UIEvent(UIEvent.VOLUME_ADJUST, v));
}
private function onDown(event:MouseEvent):void
{
var newVolume:Number = event.localX/(hotSpot.width*.8);
if (newVolume < .2)
newVolume = 0;
if (newVolume > .9)
newVolume = 1;
setVolume(newVolume);
}
}
}
--------------------------------------------------------------------------------
/vidobject_source/com/johnpolacek/ui/FullScreenButton.as:
--------------------------------------------------------------------------------
1 | package com.johnpolacek.ui {
import flash.events.MouseEvent;
import flash.display.Shape;
import flash.display.Sprite;
import com.johnpolacek.shapes.ArrowBlock;
import com.johnpolacek.shapes.EllipseShape;
import com.johnpolacek.shapes.Line;
import com.johnpolacek.shapes.RectangleShape;
/**
* FullScreen Toggle Button UI Component
*
* Requires adding MouseEvent and handler to go full screen
*
* @author John Polacek, john@johnpolacek.com
*/
public class FullScreenButton extends Sprite {
private var growIcon:Sprite = new Sprite();
private var shrinkIcon:Sprite = new Sprite();
private var fullScreenState:Boolean = false;
private var iconSize:Number;
private var iconColor:uint;
private var blockSize:Number;
/**
* @param w Width (in pixels) of the PlayPauseButton sprite
* @param h Height (in pixels) of the PlayPauseButton sprite. Optimized for 30 pixels.
* @param backgroundColor Background color of the PlayPauseButton sprite. Default 0x000000
* @param buttonColor Button color of the PlayPauseButton sprite. Default 0xFFFFFF
*/
public function FullScreenButton(w:Number, h:Number, backgroundColor:uint = 0x000000, buttonColor:uint = 0xFFFFFF)
{
this.buttonMode = true;
var bgr:Sprite = new RectangleShape(w, h, backgroundColor);
buildGrowIcon(w/10);
buildShrinkIcon(w/10);
growIcon.x = shrinkIcon.x = w/2;
growIcon.y = shrinkIcon.y = h/2 - 1;
addChild(bgr);
addChild(growIcon);
addChild(shrinkIcon);
shrinkIcon.visible = false;
}
private function buildGrowIcon(arrowSize:Number):void
{
var ulArrow:ArrowBlock = new ArrowBlock(arrowSize, 1, 0xFFFFFF, 1, true);
ulArrow.rotation = -90;
ulArrow.x = -arrowSize * 1.2;
ulArrow.y = -arrowSize * 1.2;
var urArrow:ArrowBlock = new ArrowBlock(arrowSize, 1, 0xFFFFFF, 1, true);
urArrow.x = arrowSize * 1.2;
urArrow.y = -arrowSize * 1.2;
var llArrow:ArrowBlock = new ArrowBlock(arrowSize, 1, 0xFFFFFF, 1, true);
llArrow.rotation = 180;
llArrow.x = -arrowSize * 1.2;
llArrow.y = arrowSize * 1.2;
var lrArrow:ArrowBlock = new ArrowBlock(arrowSize, 1, 0xFFFFFF, 1, true);
lrArrow.rotation = 90;
lrArrow.x = arrowSize * 1.2;
lrArrow.y = arrowSize * 1.2;
var center:EllipseShape = new EllipseShape(2, 2, 0xFFFFFF, 1, 0, 0, 0, true);
growIcon.addChild(ulArrow);
growIcon.addChild(urArrow);
growIcon.addChild(llArrow);
growIcon.addChild(lrArrow);
growIcon.addChild(center);
}
private function buildShrinkIcon(arrowSize:Number):void
{
var ulArrow:ArrowBlock = new ArrowBlock(arrowSize, 1, 0xFFFFFF, 1, true);
ulArrow.rotation = 90;
ulArrow.x = -arrowSize * 1.2;
ulArrow.y = -arrowSize * 1.2;
var urArrow:ArrowBlock = new ArrowBlock(arrowSize, 1, 0xFFFFFF, 1, true);
urArrow.rotation = 180;
urArrow.x = arrowSize * 1.2;
urArrow.y = -arrowSize * 1.2;
var llArrow:ArrowBlock = new ArrowBlock(arrowSize, 1, 0xFFFFFF, 1, true);
llArrow.x = -arrowSize * 1.2;
llArrow.y = arrowSize * 1.2;
var lrArrow:ArrowBlock = new ArrowBlock(arrowSize, 1, 0xFFFFFF, 1, true);
lrArrow.rotation = -90;
lrArrow.x = arrowSize * 1.2;
lrArrow.y = arrowSize * 1.2;
var center:EllipseShape = new EllipseShape(2, 2, 0xFFFFFF, 1, 0, 0, 0, true);
shrinkIcon.addChild(ulArrow);
shrinkIcon.addChild(urArrow);
shrinkIcon.addChild(llArrow);
shrinkIcon.addChild(lrArrow);
shrinkIcon.addChild(center);
}
/** Toggles full screen display state. */
public function toggleFullScreenState():void
{
setFullScreenState(!fullScreenState);
}
/** Sets play state. A value of true shows grow icon. (does not transmit UIEvent) */
public function setFullScreenState(fsState:Boolean):void
{
fullScreenState = fsState;
if (fullScreenState)
{
growIcon.visible = false;
shrinkIcon.visible = true;
}
else
{
growIcon.visible = true;
shrinkIcon.visible = false;
}
}
}
}
--------------------------------------------------------------------------------
/vidobject_source/com/johnpolacek/display/AudioDisplay.as:
--------------------------------------------------------------------------------
1 | package com.johnpolacek.display {
import flash.display.Sprite;
import flash.events.Event;
import flash.events.IOErrorEvent;
import flash.text.Font;
import flash.text.TextFormat;
import com.johnpolacek.media.AudioPlayer;
import com.johnpolacek.media.AudioPlayerMenu;
/**
* The AudioDisplay class creates audio players that load and
* play mp3 files with optional title and subtitle text fields.
* Includes a SoundSpectrum class that animates during playback.
*
* @example
* import com.johnpolacek.display.AudioDisplay;
* var filepaths:Array = ["example1.mp3","example2.mp3","example3.mp3"];
* var songs:Array = ["Song Title 1","Song Title 2","Song Title 3"];
* var artists:Array = ["Artist Name 1","Artist Name 2","Artist Name 3"];
* var mp3player:AudioDisplay = new AudioDisplay();
* mp3player.loadAudio(filepaths, songs, artists);
* addChild(mp3player);
*
*
* @see com.johnpolacek.media.AudioPlayer
* @see com.johnpolacek.media.AudioPlayerMenu
* @version
* 12 Jul 2010 Added autoPlay parameter.
*
* @see com.johnpolacek.display.VideoDisplay
* @see com.johnpolacek.display.VideoStreamPlayer
*
* @version
* 29 Mar 2010
25 |
26 |
27 | Generally it is best to use services like YouTube, Vimeo or a CDN for hosting video, but sometimes it isn’t an option. SimpleVid is a free and easy way to host and embed your own fluid videos. It uses flash to for browsers that don’t support h.264, so you can encode once as a baseline h.264 mp4 and play anywhere.
37 | (Try FitVids.js if your video is on YouTube, etc.)
Add video to your html in a container div styled to scale as you like.
49 |55 |50 | <div id="container"> 51 | <video id="myVideo" width="640" height="360" poster="img/poster.jpg" controls> 52 | <source src="vid/video.mp4" type="video/mp4" /> 53 | </video> 54 | </div>
Link to jQuery and then simplevid.js. Then, initialize the plugin with the settings you want. Last, use the plugin to target video elements on the page.
56 |
57 | <script src="http://code.jquery.com/jquery-1.7.min.js"></script>
58 | <script src="js/simplevid.js"></script>
59 | <script>
60 | var simplevid = new $.simplevid({
61 | player: 'swf/vidobject.swf',
62 | buttonColor: '#FFFFFF',
63 | accentColor: '#BBBBBB',
64 | backgroundColor: '#111111',
65 | scaleVideo: true,
66 | fullScreen: true
67 | });
68 | simplevid.embed("myVideo");
69 | </script>
70 |
71 | Parameters are:
72 |83 | Download Plugin: 84 | zip 85 | tar 86 |
87 | 88 |89 | Thanks to swfobject.js for some code, and Chris Coyier for inspiration. 90 |
91 | 92 |93 | Other stuff by me: 94 | johnpolacek.github.com 95 |
96 | 97 | 103 |
106 |
107 |
108 |
109 |
110 |
111 |
122 |
123 |
134 |
135 |
136 |