Permalink
Browse files

Updated examples and wrapped up log handling and layout

  • Loading branch information...
1 parent 6a424be commit fe7d5101fefe0e9958ffde5e978f5309a7298880 @newtriks committed Feb 2, 2011
View
@@ -1,9 +1,20 @@
-More PlayaHater code examples to come but for now:
+PlayaHater code examples simply provide the following parameters:
+
+1) Parent container that the player will be loaded into e.g. <em>this</em>
+2) X position of the player within its parent container.
+3) Y position of the player within its parent container.
+4) Name of the media file to load, this is a String within an Array. If the media is to be played progressively then use the full file path and extension e.g. <em>'http://example-nonstreaming.com/mymovie.flv'</em>, alternatively if the media is streamed for example via Flash Media Server then simply provide the file name e.g. <em>'mymovie'</em>.
+5) URL parameter to be supplied if the media content is to be streamed e.g. path to server application: <em>'rtmp://example-streaming.com/app/'</em>. If the content is to be played progressively then simply leave as an empty string.
+6) Log function name e.g. <em>protected function logHandlerMethod(msg:String):void{};</em>.
+7) Autoplay Boolean.
+8) ObjectEncoding for the NetConnection (please read: http://goo.gl/RESQ4).
STREAMING:
-new PlayaHater(this, 0, 0, [mymovie.flv], 'rtmp://example-streaming.com/app/', logHandlerMethod, true, ObjectEncoding.AMF0);
+new PlayaHater(this, 0, 0, [mymovie], 'rtmp://example-streaming.com/app/', logHandlerMethod, true, ObjectEncoding.AMF0);
PROGRESSIVE:
-new PlayaHater(this, 0, 0, ['http://example-nonstreaming.com/mymovie.flv'], '', logHandlerMethod, true, ObjectEncoding.AMF0);
+new PlayaHater(this, 0, 0, ['http://media.newtriks.com/flvs/lif.flv'], '', logHandlerMethod, true, ObjectEncoding.AMF0);
+
+
Binary file not shown.
@@ -89,7 +89,7 @@ package com.newtriks.components
override protected function init():void
{
super.init();
- _logCallbackHandler("PlayaHater :: init");
+ log("PlayaHater :: init");
buildNetConnection();
_soundTransform=new SoundTransform();
// Callbacks for the controls
@@ -102,7 +102,7 @@ package com.newtriks.components
override protected function addChildren():void
{
super.addChildren();
- _logCallbackHandler("PlayaHater :: add children");
+ log("PlayaHater :: add children");
// Feedback label
_feedback=new Label(this, 0, 0);
_feedback.autoSize=true;
@@ -118,13 +118,13 @@ package com.newtriks.components
override public function draw():void
{
super.draw();
- _logCallbackHandler("PlayaHater :: draw");
+ log("PlayaHater :: draw");
var _viewPort:Rectangle=getVideoRect(_video.videoWidth, _video.videoHeight);
// Feedback label positioning
_feedback.move(_viewPort.x+((_viewPort.width-_feedback.width)/2),
_viewPort.y+((_viewPort.height-_feedback.height)/2));
// Set video size
- if(_video.videoWidth) layoutHater();
+ if(_video.width>0) layoutHater();
}
/**
@@ -217,7 +217,7 @@ package com.newtriks.components
public function cleanUp():void
{
- _logCallbackHandler("PlayaHater :: performing cleanup");
+ log("PlayaHater :: performing cleanup");
stage.removeEventListener(Event.ENTER_FRAME, handleCurrentStreamTime);
_video.attachNetStream(null);
_stream.close();
@@ -263,7 +263,7 @@ package com.newtriks.components
_connection.client=_client;
_connection.connect(_url);
- _logCallbackHandler("Making net connection to: "+_url);
+ log("Making net connection to: "+_url);
}
protected function connectStream():void
@@ -319,7 +319,7 @@ package com.newtriks.components
{
_stream.play(_mediaFile.join(","), 0);
_controls.playing=_playing=!_playing;
- _logCallbackHandler("Play stream: ".concat(_mediaFile.join(",")));
+ log("Play stream: ".concat(_mediaFile.join(",")));
}
catch (error:Error)
{
@@ -337,6 +337,12 @@ package com.newtriks.components
return Math.round((value/100)*_duration);
}
+ protected function log(msg:String):void
+ {
+ if(_logCallbackHandler==null) return;
+ _logCallbackHandler(msg);
+ }
+
/**
* EVENT HANDLERS
*/
@@ -348,7 +354,7 @@ package com.newtriks.components
{
case CONNECTED:
{
- _logCallbackHandler("NetConnection :: success");
+ log("NetConnection :: success");
connectStream();
}
break;
@@ -367,7 +373,7 @@ package com.newtriks.components
// Swallow
}
break;
- default: _logCallbackHandler(_status); break;
+ default: log(_status); break;
}
// Dispatch so VideoPlayer instances can still add events + listen
if(dispatchStatusEvents)
@@ -436,7 +442,7 @@ package com.newtriks.components
}
catch(error:Error)
{
- _logCallbackHandler("Error handling mute: ".concat(error.message));
+ log("Error handling mute: ".concat(error.message));
}
}
@@ -449,7 +455,7 @@ package com.newtriks.components
protected function handleEnd():void
{
- _logCallbackHandler("End");
+ log("End");
stage.removeEventListener(Event.ENTER_FRAME, handleCurrentStreamTime);
_stream.seek(0);
handlePlay();
@@ -458,22 +464,21 @@ package com.newtriks.components
// FMS CALLBACK HANDLERS
public function close():void
{
- _logCallbackHandler("Net Connection :: close");
+ log("Net Connection :: close");
}
protected function metaDataHandler(metaData:Object):void
{
_metaData=metaData;
- _duration=Number(parseFloat(metaData['duration'].toFixed(2)));
- layoutHater();
- stage.addEventListener(Event.ENTER_FRAME, handleCurrentStreamTime);
- // Update layout
- stage.dispatchEvent(new Event(Event.RESIZE, true));
- // Log metadata
- for(var propName:String in metaData)
- {
- _logCallbackHandler("Meta data: ".concat(propName, " = ", metaData[propName]));
- }
+ _duration=Number(parseFloat(metaData['duration'].toFixed(2)));
+ stage.dispatchEvent(new Event(Event.RESIZE,true));
+ layoutHater();
+ stage.addEventListener(Event.ENTER_FRAME, handleCurrentStreamTime);
+ // Log metadata
+ for(var propName:String in metaData)
+ {
+ log("Meta data: ".concat(propName, " = ", metaData[propName]));
+ }
}
protected function cuePointHandler(cuePoint:Object):void
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,92 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
+<head>
+ <title>Playa Hater | Progressive Example</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
+ <script type="text/javascript" src="../assets/js/swfobject.js"></script>
+ <script type="text/javascript">
+ var swfVersionStr = "10.0.0";
+ var xiSwfUrlStr = "../assets/swf/expressInstall.swf";
+ var flashvars = {
+ foo:"ello"
+ };
+ var params = {
+ bgcolor: "#FFFFFF",
+ allowfullscreen:"true",
+ allownetworking: "all",
+ allowscriptaccess: "always",
+ base: ".",
+ devicefont: "false",
+ menu: "false",
+ play: "true",
+ quality:"high",
+ salign:"tl",
+ scale:"showall",
+ seamlesstabbing:"false",
+ swliveconnect:"true",
+ wmode:"window"
+ };
+ var attributes = {
+ id: "PlayaHater",
+ name: "PlayaHater"
+ };
+ swfobject.embedSWF("progressive.swf", "flashContent", "480", "390", swfVersionStr, xiSwfUrlStr, flashvars, params, attributes);
+ function Focal(){
+ document.Main.focus();
+ }
+ </script>
+ <style media="screen" type="text/css">
+ body {
+ background-color:#1D8AC4;
+ font-family:"Helvetica,Arial,FreeSans";
+ text-align:center;
+ }
+
+ #wrapper {
+ background-color:#1D8AC4;
+ width:480px;
+ margin:50px auto;
+ padding:20px 20px 20px 20px;
+ min-height:390px;
+ border:2px solid #fff;
+ outline:1px solid #0D0E29;
+ text-align:left;
+ }
+
+ h1, h2 {
+ letter-spacing:-1px;
+ color:#0D0E29;
+ font-weight:normal;
+ margin-bottom:-10px;
+ }
+
+ h1 {
+ font-size:22px;
+ }
+
+ h2 {
+ font-size:18px;
+ }
+
+ .less {
+ color:#0D0E29;
+ font-size:12px;
+ }
+
+ a {
+ color:#0D0E29;
+ }
+ </style>
+</head>
+<body onLoad="Focal()">
+ <h3>PlayaHater :: Progressive Example</h3>
+ <div id="wrapper">
+ <div id="flashContent">
+ <a href="http://www.adobe.com/go/getflashplayer">
+ <img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif"
+ alt="Get Adobe Flash player"/>
+ </a>
+ </div>
+ </div>
+</body>
+</html>
Binary file not shown.
Oops, something went wrong.

0 comments on commit fe7d510

Please sign in to comment.