Greetings, I'm currently trying to get videos as Mobiclip formats to display correctly on the Wii's Flash emulator here. I have recoded and builded my own Wii API library for ActionScript. The original libraries go to Nintendo. Anyways, I have my own ActionScript class called, "StoryMode". This class is supposed to attach the video wrapper, gets it's video instance, which the linked video's name is called:
video1
calls the WiiVideoPlayback class:
and is supposed to load a video here:
In fact, it does load the file on the Wii. But the problem is that it only plays the audio part and not the video display. I don't know what I did wrong here and I don't really know what type of codec my Mobiclip has. I've used the Mobiclip conversion tool from converting the other video format to the *.mo* format for the Wii.
Here's my two classes, StoryMode and WiiVideoPlayback:
StoryMode:
WiiVideoPlayback:
video1
calls the WiiVideoPlayback class:
Code:
this._videoInstance = Video(this._videoWrapper.getInstanceByName("video1"));
this._wiiVideoPlayback = new platform.nintendo.wii.media.WiiVideoPlayback(this._videoInstance);
Code:
this._wiiVideoPlayback.load(StoryMode.TRUSTED + StoryMode.STORY + ".mo");
Here's my two classes, StoryMode and WiiVideoPlayback:
StoryMode:
Code:
class StoryMode extends sugar.core.UIMovieClip
{
var container;
var _source;
var _queuedSeekPos;
var systemVideoPlayer;
var _videoWrapper;
var _videoInstance;
var _wiiVideoPlayback;
var _timeline;
var _isVideoMasked;
static var instance;
static var TRUSTED = "file://videos/";
static var STORY = "story";
var _maskTargetDepot = {};
var _isVideoLoaded = false;
function StoryMode()
{
super.init();
super.updateDisplay();
this.buildVideoPlayer();
this.autoPlay = true;
}
static function getInstance()
{
if (StoryMode.instance == null || StoryMode.instance == undefined)
{
StoryMode.instance = new StoryMode();
}
return StoryMode.instance;
}
function get timeline()
{
return this._timeline;
}
function buildVideoPlayer()
{
super.updateDisplay();
this._videoWrapper = sugar.core.UIMovieClip(this.attachMovie("VideoWrapper", "_videoWrapper", this.getNextHighestDepth()));
this._videoInstance = Video(this._videoWrapper.getInstanceByName("video1"));
this._wiiVideoPlayback = new platform.nintendo.wii.media.WiiVideoPlayback(this._videoInstance);
this._wiiVideoPlayback.videoCodec = 1;
this._wiiVideoPlayback.load(StoryMode.TRUSTED + StoryMode.STORY + ".mo");
this._wiiVideoPlayback.show();
this.autoPlay = true;
this.maximize();
this._videoWrapper._visible = true;
}
function drawMask()
{
this._videoWrapper.clear();
this._videoWrapper.beginFill(16711680, 0);
sugar.utils.GeomUtil.drawRect(this._videoWrapper, 0, 0, this._videoWrapper.width, this._videoWrapper.height);
this._videoWrapper.endFill();
}
function set autoPlay(value)
{
this._wiiVideoPlayback.autoplay = value;
}
function get autoPlay()
{
return this._wiiVideoPlayback.autoplay;
}
function maximize()
{
this._videoWrapper.setActualSize(sugar.core.WiiSugarApplication.stageWidth, sugar.core.WiiSugarApplication.stageHeight);
this._videoWrapper.x = 0;
this._videoWrapper.y = 0;
}
function destroy()
{
if (this._wiiVideoPlayback != null)
{
this._wiiVideoPlayback.destroy();
this._wiiVideoPlayback = null;
}
if (this._videoWrapper != null)
{
this._videoWrapper.removeMovieClip();
this._videoWrapper = null;
}
}
}
Code:
class platform.nintendo.wii.media.WiiVideoPlayback extends platform.nintendo.wii.core.WiiEventDispatcher
{
var video;
var _eKeyIndex;
var _videoHURL;
var _videoURL;
var dispatchEvent;
var _eventInterval;
static var CODEC_AUTO_DETECT = -1;
static var CODEC_H264 = 0;
static var CODEC_MOBI = 1;
static var _overlayEnabled = false;
static var _overlayKeyColor = 0;
static var _overlayAlpha = 100;
static var _playbackThreshold = 24;
var autoplay = true;
var dispatchContinuousEvents = true;
var eventFrequency = 500;
var _originalDimValue = platform.nintendo.wii.Wii.dimmingEnabled;
var _originalHBMValue = platform.nintendo.wii.Wii.homeButtonEnabled;
var _isIntervalRunning = false;
var _state = platform.nintendo.wii.media.WiiVideoState.STOPPED;
var _cType = platform.nintendo.wii.media.WiiVideoPlayback.CODEC_AUTO_DETECT;
var _isPlaying = false;
var _isSeeking = false;
function WiiVideoPlayback(pVideo)
{
super();
if (!pVideo)
{
throw new platform.nintendo.wii.core.WiiError(platform.nintendo.wii.core.WiiError.GENERAL_ERROR, "An error has occurred because the WiiVideoPlayback's video instance is required on construction.");
}
this.video = pVideo;
this.video.onStatus == mx.utils.Delegate.create(this, this.videoOnStatus);
this.video.play();
}
static function get overlayEnabled()
{
return platform.nintendo.wii.media.WiiVideoPlayback._overlayEnabled;
}
static function set overlayEnabled(pValue)
{
platform.nintendo.wii.media.WiiVideoPlayback._overlayEnabled = pValue;
_global.my.extensions.WiiSystem.videoRenderMode(platform.nintendo.wii.media.WiiVideoPlayback._overlayEnabled,platform.nintendo.wii.media.WiiVideoPlayback._overlayKeyColor,platform.nintendo.wii.media.WiiVideoPlayback._overlayAlpha);
}
static function get overlayKeyColor()
{
return platform.nintendo.wii.media.WiiVideoPlayback._overlayKeyColor;
}
static function set overlayKeyColor(pValue)
{
platform.nintendo.wii.media.WiiVideoPlayback._overlayKeyColor = pValue;
_global.my.extensions.WiiSystem.videoRenderMode(platform.nintendo.wii.media.WiiVideoPlayback._overlayEnabled,platform.nintendo.wii.media.WiiVideoPlayback._overlayKeyColor,platform.nintendo.wii.media.WiiVideoPlayback._overlayAlpha);
}
static function get overlayAlpha()
{
return platform.nintendo.wii.media.WiiVideoPlayback._overlayAlpha;
}
static function set overlayAlpha(pValue)
{
platform.nintendo.wii.media.WiiVideoPlayback._overlayAlpha = pValue;
_global.my.extensions.WiiSystem.videoRenderMode(platform.nintendo.wii.media.WiiVideoPlayback._overlayEnabled,platform.nintendo.wii.media.WiiVideoPlayback._overlayKeyColor,platform.nintendo.wii.media.WiiVideoPlayback._overlayAlpha);
}
function get state()
{
return this._state;
}
function get bytesLoaded()
{
return int(this.video.bytesLoaded());
}
function get bytesTotal()
{
return int(this.video.bytesTotal());
}
function get currentFrame()
{
return int(this.video.getCurrentFrame());
}
function get elapsedTime()
{
return int(this.video.time());
}
function get totalTime()
{
return int(this.video.totalTime());
}
function get width()
{
return int(this.video.getWidth());
}
function get height()
{
return int(this.video.getHeight());
}
function get isPlaying()
{
return this._isPlaying;
}
function get playbackThreshold()
{
return platform.nintendo.wii.media.WiiVideoPlayback._playbackThreshold;
}
function set playbackThreshold(pValue)
{
if (pValue > 0 && pValue <= 32)
{
platform.nintendo.wii.media.WiiVideoPlayback._playbackThreshold = pValue;
}
this.video.setPlaybackThreshold(platform.nintendo.wii.media.WiiVideoPlayback._playbackThreshold);
}
function get deviceVideoInstance()
{
return this.video;
}
function get encryptionKeyIndex()
{
return this._eKeyIndex;
}
function set encryptionKeyIndex(pKeyIndex)
{
this._eKeyIndex = pKeyIndex;
}
function get videoHeaderURL()
{
return this._videoHURL;
}
function set videoHeaderURL(pHeaderURL)
{
this._videoHURL = pHeaderURL;
}
function get videoCodec()
{
return this._cType;
}
function set videoCodec(pVideoCodec)
{
this._cType = pVideoCodec;
}
function load(pURL)
{
this._videoURL = pURL;
this._isPlaying = this.autoplay;
this._state = platform.nintendo.wii.media.WiiVideoState.LOADING;
this.video.setVideoType(this._cType);
if (!isNaN(this._eKeyIndex))
{
this.video.setEncryptionKey(this._eKeyIndex);
}
if (this._videoHURL)
{
this.video.setHeaderURL(this._videoHURL);
}
this.video.play(this._videoURL);
}
function play()
{
if (this._state == platform.nintendo.wii.media.WiiVideoState.PLAYING || this._isPlaying == true)
{
return undefined;
}
if (this._state == platform.nintendo.wii.media.WiiVideoState.STOPPED)
{
this.load(this._videoURL);
return undefined;
}
this._isPlaying = true;
this._state = platform.nintendo.wii.media.WiiVideoState.PLAYING;
this.video.resume();
}
function pause()
{
if (this._state == platform.nintendo.wii.media.WiiVideoState.PAUSED || this._isPlaying == false)
{
return undefined;
}
this._isPlaying = false;
this._state = platform.nintendo.wii.media.WiiVideoState.PAUSED;
this.video.pause();
}
function stop()
{
if (this._state == platform.nintendo.wii.media.WiiVideoState.STOPPED)
{
return undefined;
}
this._isPlaying = false;
this._state = platform.nintendo.wii.media.WiiVideoState.STOPPED;
this.stopEventInterval();
this.video.stop();
}
function show()
{
this.video.showVideo();
}
function hide()
{
this.video.hideVideo();
}
function captureFrame(pWidth, pHeight)
{
if (pWidth == undefined)
{
pWidth = int(this.video.getWidth());
}
if (pHeight == undefined)
{
pHeight = int(this.video.getHeight());
}
return flash.display.BitmapData(_global.my.extensions.WiiSystem.getVideoFrame(pWidth, pHeight));
}
function reset()
{
this.seek(0);
}
function seek(pTime)
{
this.video.seek(pTime);
}
function destroy()
{
stop();
this.video.close();
this.video = null;
this.autoplay = null;
}
function onError(pErrorCode)
{
platform.nintendo.wii.Wii.dimmingEnabled = this._originalDimValue;
platform.nintendo.wii.Wii.homeButtonEnabled = this._originalHBMValue;
this.dispatchEvent(new platform.nintendo.wii.media.WiiVideoErrorEvent(pErrorCode, this));
}
function onBuffered()
{
this.dispatchEvent(new platform.nintendo.wii.media.WiiVideoEvent(platform.nintendo.wii.media.WiiVideoEvent.BUFFERED, this));
}
function onBuffering()
{
this.dispatchEvent(new platform.nintendo.wii.media.WiiVideoEvent(platform.nintendo.wii.media.WiiVideoEvent.BUFFERING, this));
}
function onRemoteConnectionRetry()
{
this.dispatchEvent(new platform.nintendo.wii.media.WiiVideoEvent(platform.nintendo.wii.media.WiiVideoEvent.REMOTE_CONNECTION_RETRY, this));
}
function onCompleted()
{
this.dispatchEvent(new platform.nintendo.wii.media.WiiVideoEvent(platform.nintendo.wii.media.WiiVideoEvent.COMPLETED, this));
}
function onLoaded()
{
this.dispatchEvent(new platform.nintendo.wii.media.WiiVideoEvent(platform.nintendo.wii.media.WiiVideoEvent.LOADED, this));
}
function onLoading()
{
this.dispatchEvent(new platform.nintendo.wii.media.WiiVideoEvent(platform.nintendo.wii.media.WiiVideoEvent.LOADING, this));
}
function onPaused()
{
this.dispatchEvent(new platform.nintendo.wii.media.WiiVideoEvent(platform.nintendo.wii.media.WiiVideoEvent.PAUSED, this));
}
function onPlaying()
{
this.dispatchEvent(new platform.nintendo.wii.media.WiiVideoEvent(platform.nintendo.wii.media.WiiVideoEvent.PLAYING, this));
}
function onResume()
{
this.dispatchEvent(new platform.nintendo.wii.media.WiiVideoEvent(platform.nintendo.wii.media.WiiVideoEvent.PLAYING, this));
}
function onStopped()
{
this.dispatchEvent(new platform.nintendo.wii.media.WiiVideoEvent(platform.nintendo.wii.media.WiiVideoEvent.STOPPED, this));
}
function startEventInterval()
{
if (this.dispatchContinuousEvents == false || this._isIntervalRunning == true)
{
return undefined;
}
this._eventInterval = setInterval(this, "eventIntervalOnInterval", this.eventFrequency);
this.eventIntervalOnInterval();
this._isIntervalRunning = true;
}
function stopEventInterval()
{
if (this.dispatchContinuousEvents == false || this._isIntervalRunning == false)
{
return undefined;
}
clearInterval(this._eventInterval);
this._isIntervalRunning = false;
}
function setDimming()
{
if (this._state == platform.nintendo.wii.media.WiiVideoState.RESUME || this._state == platform.nintendo.wii.media.WiiVideoState.PLAYING || this._state == platform.nintendo.wii.media.WiiVideoState.BUFFERED)
{
platform.nintendo.wii.Wii.dimmingEnabled = false;
}
else
{
platform.nintendo.wii.Wii.dimmingEnabled = this._originalDimValue;
}
}
function setHBM()
{
if (this._state == platform.nintendo.wii.media.WiiVideoState.LOADING || this._state == platform.nintendo.wii.media.WiiVideoState.BUFFERED)
{
platform.nintendo.wii.Wii.homeButtonEnabled = false;
}
else
{
platform.nintendo.wii.Wii.homeButtonEnabled = this._originalHBMValue;
}
}
function eventIntervalOnInterval()
{
switch (this._state)
{
case platform.nintendo.wii.media.WiiVideoState.LOADING :
this.onLoading();
return undefined;
case platform.nintendo.wii.media.WiiVideoState.BUFFERING :
this.onBuffering();
return undefined;
case platform.nintendo.wii.media.WiiVideoState.RESUME :
this._state = platform.nintendo.wii.media.WiiVideoState.PLAYING;
this._isPlaying = true;
break;
case platform.nintendo.wii.media.WiiVideoState.PLAYING :
break;
default :
this.stopEventInterval();
}
this.onPlaying();
return undefined;
}
function videoOnStatus(pEvent)
{
if (pEvent.level == platform.nintendo.wii.core.WiiEvent.LEVEL_ERROR)
{
this.stopEventInterval();
this.onError(pEvent.code);
return undefined;
}
if (pEvent.code == platform.nintendo.wii.media.WiiVideoEvent.REMOTE_CONNECTION_RETRY)
{
this.onRemoteConnectionRetry();
return undefined;
}
this._state = pEvent.code;
this.setDimming();
this.setHBM();
switch (this._state)
{
case platform.nintendo.wii.media.WiiVideoEvent.LOADING :
this.startEventInterval();
this.onLoading();
return undefined;
case platform.nintendo.wii.media.WiiVideoEvent.LOADED :
this.stopEventInterval();
if (this.autoplay == false)
{
this.pause();
}
this.onLoaded();
return undefined;
case platform.nintendo.wii.media.WiiVideoEvent.BUFFERING :
this.startEventInterval();
this.onBuffering();
return undefined;
case platform.nintendo.wii.media.WiiVideoEvent.BUFFERED :
this.stopEventInterval();
this.onBuffered();
return undefined;
case platform.nintendo.wii.media.WiiVideoEvent.PAUSED :
this.stopEventInterval();
this.onPaused();
return undefined;
case platform.nintendo.wii.media.WiiVideoEvent.RESUME :
this.startEventInterval();
this.onResume();
return undefined;
case platform.nintendo.wii.media.WiiVideoEvent.PLAYING :
this.startEventInterval();
this.onPlaying();
return undefined;
case platform.nintendo.wii.media.WiiVideoEvent.COMPLETED :
this.onCompleted();
return undefined;
case platform.nintendo.wii.media.WiiVideoEvent.STOPPED :
this.onStopped();
return undefined;
default :
}
}
}