07-04-2009 02:39 PM
Hi there,
What's the best way to create a custom overlay and display the media controls in the overlay? Basically, we want to display the overlay with media controls whenever someone rolls over the video. The media controls would have the play/pause, playhead, menu buttons and controls.
I would greatly appreciate some advice and help.
Thanks,
S
Solved! Go to Solution.
07-06-2009 09:27 AM
I believe the best way to build this is to use the videoDisplay component for video playback and then build the controls in ActionScript and load them in using a swf loader. We have built these types of controls in Professional Services and that is the approach we took. Essentially, the swf component is a sprite on the player that draws all of the controls it needs. To be honest this is not a trival task since there are a lot of events you need to listen for in order create the controls from scratch and know when to hide/show them. That being said all of the events you need are exposed through our player APIs.
Another option you could explore is to try to put the custom media controls over the player. Then using our APIs you would show/hide it depending on whether or not the user has moused over the player. I have not tried this and don't think this is the best option but could be a much easier option. Hope this is helpful, if you any specific questions feel free to ask.
07-06-2009 01:14 PM
Thanks for the response. We are looking into how we can get the overlay working.
One related question - How do we detect a rollover on the videoDisplay when inside of a flash file loaded using SWFLoader? We are unable to trigger the proper events when a user rolls over and off the video.
Thanks.
07-06-2009 01:28 PM
You should be able to add the event listeners to the player module. You can see my example code below.
mPlayer.getModule("videoPlayer").addEventListener(
mPlayer.getModule("videoPlayer").addEventListener(
mPlayer.getModule("videoPlayer").addEventListener(
Note that this was before the Player .swc which is why the code is not strongly typed.
Thanks,
Jesse
07-06-2009 01:54 PM
Note that although this might work right now, there is no guarantee it will continue to do so since the VideoPlayerModule itself is not guaranteed, through our supported documentation, to be a Sprite (and won't be, if you use the SWC).
A better option would be to use a SWFLoader, as Jesse suggested, to overlay the video screen and put the logic in there to handle rollovers.
07-06-2009 03:20 PM
I've tried using the SWFloader and it seems like only the initialize function ever seems to get called. The rollovers don't seem to get invoked. We are using the suggested approach of loading the overlay onto the videoscreen and using the latest SWC file.
How do we determine if the event listeners are registering? - as they don't seem to be doing so.
07-06-2009 05:27 PM
It's very strange but I'm still not able to receive any mouse events. Even when we draw a Shape on the Sprite and try to listen for ROLL_OUT,ROLL_OVER,MOUSE_MOVE... nothing comes through.
Any ideas of what's eating the mouse events?
Thanks.
07-07-2009 04:54 PM
We've done a couple of player components that create custom overlays over a VideoDisplay. Here's how:
In the BEML, we place both the SWFLoader and VideoDisplay in a Canvas so that the SWFLoader sits directly above the VideoDisplay:
<Canvas>
<VideoDisplay id="videoPlayer" showBack="true" includeFullscreenControls="true"/>
<SWFLoader source="[PATH TO SWF]" depth="2"/>
</Canvas>
Then, in ActionScript, we create a Sprite overlay, and figure out the dimensions of the overlay using the videoPlayerModule.getWidth() and .getHeight() methods:
var _width:Number = videoPlayerModule.getWidth();
var _height:Number = videoPlayerModule.getHeight();
Then we draw the overlay Sprite as a transparent rectangle over the entire area:
this.graphics.beginFill(0x000000, 0.0);
this.graphics.drawRect(0, 0, _width, _height);
this.graphics.endFill();
Now you can add event listeners to your overlay Sprite, as well as add children to it, such as custom player controls.
overlay.addEventListener(MouseEvent.CLICK, handleClick);
//etc.
The trick then is that this overlay will cover the default Brightcove overlay that appears either when you pause or open a menu, which is a problem. So, you have do a couple of things:
1. Remove the overlay any time the player is paused, a menu is open, or the player is in full-screen mode, and add it again whenever it returns to a normal playing state. These are the listeners to use:
videoPlayerModule.addEventListener(MediaEvent.BEGI
N, handleMediaPlay);
videoPlayerModule.addEventListener(MediaEvent.PLAY, handleMediaPlay);
videoPlayerModule.addEventListener(MediaEvent.STOP, handleMediaStop);
menuModule.addEventListener(MenuEvent.MENU_PAGE_OPEN, handleMenuPageOpen);
menuModule.addEventListener(MenuEvent.MENU_PAGE_CLOSE, handleMenuPageClose);
experienceModule.addEventListener(ExperienceEvent.ENTER_FULLSCREEN, handleEnterFullScreen);
experienceModule.addEventListener(ExperienceEvent.EXIT_FULLSCREEN, handleExitFullScreen);
Each handler function needs to either add or remove the overlay, depending on the state of the player, which requires a bit of logic that you'll have to figure out.
2. Make sure that you also listen for clicks on the overlay to toggle playback on the player, presuming you want to preserve the default Brightcove player interface.
private function handleClick(event:MouseEvent):void {
videoPlayerModule.pause(videoPlayerModule.isPlayin
g());
// Anything else you want to happen...
}
After that, it's really up you what you do with it! As was mentioned earlier, creating your own media controls from scratch can be tedious because of all the events involved, but it's certainly possible. Or you could use the rollover event to make a BEML MediaControls element appear.
07-09-2009 04:50 PM
This is great - thanks for the detailed help.
We now have a problem that we are unable to interact with the media controls as the overlay is on top of it. Is there any for the media controls to be ontop of the overlay? We have tried the depth parameter for media controls and the overlay seems to always be on top.
Any ideas?
Thanks.
07-09-2009 05:02 PM
Hmm, so this doesn't work?
<Canvas> <VideoDisplay id="videoPlayer" showBack="true" includeFullscreenControls="true"/> <SWFLoader source="[PATH TO SWF]"/> <MediaControls ... /> </Canvas>
Even once you're able to get the MediaControls to layer over the overlay correctly, you'll potentially run into a problem where the overlay will think the user has rolled out of it as soon as they roll onto the MediaControls. If that's the case, I'm not exactly sure what an elegant solution might be.
Brightcove Inc., a leading global provider of cloud content services, provides a family of products used to publish and distribute the world's professional digital media. The company's products include Brightcove Video Cloud, the market-leading online video platform, and Brightcove App Cloud, the pioneering content app platform. Together, more than 4,200 customers in 50 countries rely on Brightcove's cloud content services to build and operate exceptional media experiences across PCs, smartphones, tablets and connected TVs.
Brightcove Inc.
© 2012 Brightcove Inc.
