diff --git a/src/as/com/threerings/flash/media/FlvVideoPlayer.as b/src/as/com/threerings/flash/media/FlvVideoPlayer.as
index 04ce72e6..56523c5e 100644
--- a/src/as/com/threerings/flash/media/FlvVideoPlayer.as
+++ b/src/as/com/threerings/flash/media/FlvVideoPlayer.as
@@ -151,9 +151,16 @@ public class FlvVideoPlayer extends EventDispatcher
}
}
+ // from VideoPlayer
+ public function getMetadata () :Object
+ {
+ return _metadata;
+ }
+
// from VideoPlayer
public function unload () :void
{
+ _metadata = null;
_sizeChecker.reset();
_positionChecker.reset();
_vid.attachNetStream(null);
@@ -266,17 +273,15 @@ public class FlvVideoPlayer extends EventDispatcher
*/
protected function handleMetaData (info :Object) :void
{
-// log.debug("Got video metadata:");
-// for (var n :String in info) {
-// log.debug(" " + n + ": " + info[n]);
-// }
-
if ("duration" in info) {
_duration = Number(info.duration);
if (!isNaN(_duration)) {
dispatchEvent(new ValueEvent(MediaPlayerCodes.DURATION, _duration));
}
}
+
+ _metadata = info;
+ dispatchEvent(new ValueEvent(MediaPlayerCodes.METADATA, info));
}
protected function updateState (newState :int) :void
@@ -316,6 +321,8 @@ public class FlvVideoPlayer extends EventDispatcher
protected var _volume :Number = 1;
+ protected var _metadata :Object;
+
/** Checks the video every 100ms to see if the dimensions are now know.
* Yes, this is how to do it. We could trigger on ENTER_FRAME, but then
* we may not know the dimensions unless we're added on the display list,
diff --git a/src/as/com/threerings/flash/media/MediaPlayer.as b/src/as/com/threerings/flash/media/MediaPlayer.as
index 1781475e..7f0668f0 100644
--- a/src/as/com/threerings/flash/media/MediaPlayer.as
+++ b/src/as/com/threerings/flash/media/MediaPlayer.as
@@ -32,6 +32,14 @@ import com.threerings.util.ValueEvent;
*/
[Event(name="position", type="com.threerings.util.ValueEvent")]
+/**
+ * Dispatched when media metadata is available, if ever.
+ * value: metadata object. @see getMetadata() for more info.
+ *
+ * @eventType com.threerings.flash.media.MediaPlayerCodes.METADATA
+ */
+[Event(name="metadata", type="com.threerings.util.ValueEvent")]
+
/**
* Dispatched when there's a problem.
* value: a String error code/message.
@@ -85,6 +93,12 @@ public interface MediaPlayer extends IEventDispatcher
*/
function getVolume () :Number;
+ /**
+ * Get metadata, or null if none or not yet available. The exact format of this data
+ * object varies by MediaPlayer implementation, see the documentation for each.
+ */
+ function getMetadata () :Object;
+
/**
* Unload the media.
*/
diff --git a/src/as/com/threerings/flash/media/MediaPlayerCodes.as b/src/as/com/threerings/flash/media/MediaPlayerCodes.as
index 84533dec..1945c810 100644
--- a/src/as/com/threerings/flash/media/MediaPlayerCodes.as
+++ b/src/as/com/threerings/flash/media/MediaPlayerCodes.as
@@ -11,6 +11,8 @@ public class MediaPlayerCodes
public static const POSITION :String = "position";
+ public static const METADATA :String = "metadata";
+
/** Only applicable for VideoPlayer. */
public static const SIZE :String = "size";
diff --git a/src/as/com/threerings/flash/media/Mp3AudioPlayer.as b/src/as/com/threerings/flash/media/Mp3AudioPlayer.as
index 2c743402..bf92ca1f 100644
--- a/src/as/com/threerings/flash/media/Mp3AudioPlayer.as
+++ b/src/as/com/threerings/flash/media/Mp3AudioPlayer.as
@@ -117,6 +117,12 @@ public class Mp3AudioPlayer extends EventDispatcher
return _volume;
}
+ // from AudioPlayer
+ public function getMetadata () :Object
+ {
+ return (_sound == null) ? null : _sound.id3;
+ }
+
// from AudioPlayer
public function unload () :void
{
@@ -132,6 +138,9 @@ public class Mp3AudioPlayer extends EventDispatcher
_lastPosition = NaN;
}
+ /**
+ * Play without updating the current state.
+ */
protected function play0 () :void
{
pause0();
@@ -143,6 +152,9 @@ public class Mp3AudioPlayer extends EventDispatcher
}
}
+ /**
+ * Pause without saving the position or updating the state.
+ */
protected function pause0 () :void
{
if (_chan != null) {
@@ -177,7 +189,7 @@ public class Mp3AudioPlayer extends EventDispatcher
protected function handleId3 (event :Event) :void
{
- trace("Got ID3");
+ dispatchEvent(new ValueEvent(MediaPlayerCodes.METADATA, _sound.id3));
}
/**