Order Now AdSolution Sign Up | Login » Bits on the Run Sign Up | Login »

Forums

/

Display stack

7 replies [Last post]

In 4.0 "developers could use view.skin to refer to the player's display stack" but that is no longer supported in 5.

Forgive me but what is the suggested method going forward? Does anyone have an example where they have had to remove this method in order to make it compatible with 5.0?

@Kristian -

JW5 prevents plugins from directly manipulating the display stack, since in JW4, this caused instability when using more than one plugin.

What sort of thing are you trying to do? As it is now, the plugin already has its own space in the display stack.

One of our developers created a plugin for 4.4 that would display the current time over the time slider while scrubbing the video. He has since left and I'm looking into modifying it to work in 5.1.

I am just digging into 5.1 and have zero experience with developing plugins but I believe that this is why it is not compatible.

@Kristian -

Yes, this is most likely the reason your plugin isn't working in v5. We are planning to implement the time scrubber tooltip feature for version 5.2, so you might be able to simply wait for the feature to be added. Otherwise, you'll need to do some plugin coding.

Thanks for the quick response and it's good to know you guys are planning to support this feature.

In the meantime I'll see what I can do!

I guess this didn't make it into 5.2

@Kristian -

No, unfortunately this was pushed to into 5.3. Here's the ticket for it if you'd like to keep track of its progress:

http://developer.longtailvideo.com/trac/ticket/884

I like the way you guys plan to approach it. As I said before, a developer who has since left wrote a plugin that allowed me to do exactly what I needed. Unfortunately it uses methods that are no longer supported in 5.0+.

package com.xxx.time{

/* The events package contains references to the Player */
import com.jeroenwijering.events.*;
import com.jeroenwijering.utils.*;

import flash.events.*;
import flash.display.*;
import flash.net.*;
import flash.text.TextField;
import flash.text.TextFormat;
import flash.text.AntiAliasType;
import flash.geom.Point;

public class Time extends MovieClip implements PluginInterface {
/** Reference to the View of the player. **/
private var _view:AbstractView;
/** Reference to the graphics. **/
private var _clip:MovieClip;
private var _config:Object;
private var _tf:TextField;
private var _dur:Number=0;
private var _scrubberX:Number=-1;

/** Constructor; nothing going on. **/
public function Time() {
_clip=this;
_clip.visible=false;
_clip.textEmbed.visible=false;
_clip.mouseChildren=false;
_clip.popup.x=-1*Math.round(_clip.popup.width/2)+1;

var fmt:TextFormat=new TextFormat  ;
fmt.font="Arial";
fmt.size=10;
fmt.color=0xffffff;

this._tf=new TextField  ;
this._tf.antiAliasType=AntiAliasType.ADVANCED;
this._tf.defaultTextFormat=fmt;
this._tf.embedFonts=true;
this._tf.x=2;
this._tf.y=1;
this._tf.selectable=false;
_clip.popup.addChild(this._tf);
}

/**
* initializePlugin() is called by the JW Player when the plugin is
* loaded into the player.
*/
public function initializePlugin($vie:AbstractView):void {
_view=$vie;
var skin:MovieClip=_view.skin;
skin.setChildIndex(this,skin.numChildren-1);
_config=_view.getPluginConfig(this);
_view.addModelListener(ModelEvent.TIME,timeHandler);
var controlbar:MovieClip=_view.getPlugin('controlbar').clip;
controlbar.timeSlider.addEventListener(MouseEvent.MOUSE_DOWN,_handleMouseDown,false,0,true);
controlbar.timeSlider.addEventListener(MouseEvent.MOUSE_UP,_handleMouseUp,false,0,true);
}

/** Process time updates given by the model. **/
private function timeHandler(evt:ModelEvent=null):void {
var dur:Number=0;
if (evt) {
dur=evt.data.duration;
}

if (dur>0) {
_dur=dur;
}
}

private function _handleMouseDown($evt:MouseEvent):void {
stage.addEventListener(MouseEvent.MOUSE_UP,_handleMouseUp,false,0,true);

if (_dur>0) {
var controlbar:MovieClip=_view.getPlugin('controlbar').clip;
_scrubberX=controlbar.timeSlider.icon.x;
stage.addEventListener(Event.ENTER_FRAME,_handleEnterFrame,false,0,true);
stage.addEventListener(MouseEvent.MOUSE_MOVE,_handleMouseMove,false,0,true);
}
}

private function _handleEnterFrame($evt:Event):void {
var controlbar:MovieClip=_view.getPlugin('controlbar').clip;
if (controlbar.timeSlider.icon.x!=_scrubberX) {
_scrubberX=controlbar.timeSlider.icon.x;
_view.skin.removeChild(_clip);
_view.skin.addChild(_clip);
_handleMouseMove();
stage.removeEventListener(Event.ENTER_FRAME,_handleEnterFrame);
}

}

private function _handleMouseMove($evt:MouseEvent=null):void {
_clip.visible=true;
var controlbar:MovieClip=_view.getPlugin('controlbar').clip;
var estimatedSecs:Number=this._dur*controlbar.timeSlider.icon.x/controlbar.timeSlider.rail.width-controlbar.timeSlider.icon.width;
this._tf.text=Strings.digits(estimatedSecs);
_clip.x=controlbar.timeSlider.localToGlobal(new Point(controlbar.timeSlider.icon.x,controlbar.timeSlider.icon.y)).x+controlbar.timeSlider.icon.width/2;
_clip.y=controlbar.y+controlbar.timeSlider.mark.y-4;
}

private function _handleMouseUp($evt:MouseEvent):void {
_clip.visible=false;
stage.removeEventListener(MouseEvent.MOUSE_MOVE,_handleMouseMove);
stage.removeEventListener(MouseEvent.MOUSE_UP,_handleMouseUp);
stage.removeEventListener(Event.ENTER_FRAME,_handleEnterFrame);
}

/** Handle a resize. **/
private function _resizeHandler($evt:ControllerEvent):void {

}
}

}