ActionScript 3 Full Browser Background Video

An Full Browser Background Video Demonstration

Supports either progressive or streaming video and audio (AAC) files (streaming tested using Red 5 and FMS). The demo consists of 3 classes, the main NpVideoProvider Class handles acquiring video, a NetConnect Class handles all netConnection duties, and an event class handles all the necessary events. Originally I wrote a class to handle testing BandWidth on streaming servers, but I didn’t think people would want that. If I’m wrong, I can add that functionality back in?

Class allows for loading in seperate files. So it would be pretty simple to turn this into a video slideshow. Class also, dispatches progress events along with events for each relevant netStatus event.

Class Features.

    External Video files.
    Either .flv, or .mp4 (h264), f4v, m4a (AAC), m4v, files.
    Get / Set video looping.
    Dispatches Progress events.
    Get / Set a load point at which point video plays.
    Get / Set video source files.
    Play, Stop, Pause Methods.
    Get / Set Seek Points.
    Get / Set Sound volume.
    Get / Set Sound Pan.
    Get / Set Video Smoothing.
    Get Video MetaData.
    Get Video CuePoints.
    Get Video XMP Data.
    Get Video Image Data.
    Get Video Text Data.
    Definable Min scale size at which point the videos are clipped.
    Supports FullScreen Events.

The demo contains two examples, one similar to what is online and one much more basic version. When I have time I’ll finish off a 3rd demo for using the NpVideoProvider Class as the base for a FLV player.

Updates11 Oct 2008: Renamed a property. Updated help files, updated demo files to more clearly show how to avoid stretching your video files.

08 December 2008: Added in support for f4v files, by adding in callback handlers for XMP, text and Image Data. The demos have been updated to demonstrate pulling in cover art from both a video and AAC audio source using the NpVideoProvider Class. The class is at Revision 1.1 now.

In this demo, I’m also using a tiled Background class, as a pattern overlay. This decreases performance notably. There is an option to turn this off in the demo.

View Example
Here is an example; http://www.noponies.com/dev/as3_fullscreen_bg_vid/

Source Files
Donate if you want these source files

Dependencies
None.

81 Neighs about “ActionScript 3 Full Browser Background Video”



Zara Neighed:

nice dali….i saw an example of this the other day on a site and the first guy i thought of was you…how big are those vid files that you are using just out of curiosity? great work….

Dale Neighed:

Zara,

They are both about 1meg in size, H264 encoded mp4’s. Cheers.

Slivka Neighed:

Really nice stuff, as always! I?Ǭ¥ll donate to get the code when it?Ǭ¥s finished.

Barrett Neighed:

Hey Dale, this really looks awesome. I have been wondering how to pull this off for a long time. I would like to donate, when do you think it may be ready?

Dale Neighed:

Barrett,

In a few days it should all be done. I’ve extended the class to also work as a basis a generic .flv/.mov player. Once that is all error tested etc, I’ll upload it.

Zara Neighed:

a generic player with controls etc??……awsome dale…surley a bunch of people will be waiting in anticipation to donate….thx for your hard work…

Ant Neighed:

hey dale, lovely site with lovely examples – this being one – so nice code!

ive no problem donating if im going to need and use this code – hopefully one day soon ;) – but hows the donation ware thing going to work cos im not familiar with the process ;)

Dale Neighed:

Ant,

When its ready, and you donate, you will get access to a secure part of the site, and the files.

oliver_l1 Neighed:

Great Work! I’ll donate too when its ready.

Lock Neighed:

Be quick, i need it :) . Nice work. Waittinngg..

sanbra Neighed:

Hi, I wish to get the file of this implementation, but it’s ready yet or not, I will donate that’s sure.

Congratulations great work !!!.

shaked Neighed:

hye, excuse me to ask, but i would likre to know if the file is downloadable and if it does work with AS2
Thank you very much
Great work!

Dale Neighed:

The core classes are complete but not the demo implementation, which needs a little more work. Will be ready when its ready, which should be in a few days or so.

Luke Neighed:

Dear Noponies,
Wow! The script is amazing. I’m a young graphic designer gone flash developer, but I’m still struggling with as3. I know it is donation ware, but where can I find source code for making video fullscreen like you did?!

Dale Neighed:

Luke,

I just wrote it from scratch.

Pierre Neighed:

great!
I would be glad to pitch in for this too.
nice work.
pierre

marie Neighed:

Hello,
Just to be sure that I well understand :)
If I done some money, you will send me the script?
Thanks

Dale Neighed:

Marie,

When its all done, I’ll let you know.

I’m currently adding in support for streams…taking longer than I thought,

» Vídeo background with AS3 | DES 84 - Blog of DES84 Website Neighed:

[...] http://www.blog.noponies.com/archives/85 Escrito por: Pablo Davi e Gravado em: ActionScript 3, Novidades, [...]

michael Neighed:

Dale,

this looks great. I am trying to make a super simplified version for a looped bg video in as3. Are there any resources you found especially useful??

thanks,
michael

Dale Neighed:

Michael,

I just sifted through the Adobe docs, and some articles on DevNet. The most complicated element was getting stream server support.

Kris Neighed:

Can you easily remove the bottom controls and just ave the video run in a loop?

Dale Neighed:

Kris,

Yes, in the files you download, there is a simple version, that does just that.

Kris Neighed:

Awesome, donation coming your way soon.

jm Neighed:

There’s something wrong with the demo.
The videos aren’t playing and the menu at the bottom won’t expand.

Dale Neighed:

jm,

I just tested it, worked fine.

What browser etc are you using?

Didi Neighed:

Hi… I?Ǭ¥ve donated and downloaded this files but i?Ǭ¥m having a problem… Firefox and Ie when showing the page are using about 80% of the computers resources. Do you know what?Ǭ¥s going on?

Yhanks for all and keep up the good work!

Dale Neighed:

Didi,

Its a processor intensive operation running fullscreen video. On my machine it uses about 70% of the cpu. Turning off the overlay, (if you have it on) will lower that CPU useage.

Didi Neighed:

hi…

Another question… I published everything remotely on my server and the video don?Ǭ¥t load! Locally is 100%. Do you know what am i missing?

Thanks

Dale Neighed:

Didi,

Not sure, maybe the swfObject embedding script, or the path to your flv could be wrong etc.

Ilanb Neighed:

Hi Dale,

I use rtmp videos with FMS3 and mp4 with your exemple.

Work like a charm ! but :

How to use scrubber with your exemple and how to add more 2 videos ?
Can you add xml list or somthing like this ?
Last request :-) , It’s possible to add graphic buffer ?

Thanks

Greats works and thanks for sharing

Donate OK :-)

Matt Neighed:

I’m working on a project that has the mouse movement back and forth controlling the video playback. Is there any way to make the video scrub smoother? Here is the code I have so far:

private function mouseMoveHandler(event:MouseEvent):void
{
//trace((event.stageX)/stage.width);
vid.seekAsPercent((event.stageX)/stage.width);
}

Thanks for your help!

Dale Neighed:

Matt,

I usually use a timer when making controllers for this class. I’ve not actually tried with a mouseMove. Have you tried adding in the event.updateAfterEvent() method to your function?

Jaremore7 Neighed:

Hello Dale,

I’ve just downloaded the files of this video player, and when I’m trying to play FLV’s is not working properly. I’m just changing the loadFile root, for the appropiate one.

Apart from that, I wanted to know if there is a way where I can randomize the play order of the videos, or loop one after the other (instead of just looping the same video). Or XML support instead of direct inputing.

Jaremore7 Neighed:

(if you can just link this comment to the previous)
I also wonder why when I’m trying to play the basic fullscreen, the video doesnt play fullscreen. If could make it work full screen with other videos in a randomize order (without controls or anything) i would be great.

Regards

Hipnotik Neighed:

I found you through Google search using Chrome browser. Works lovely in Chrome, by the way! :-) I will be donating next week. This is what I’ve been hunting for the past few days.

Now, I have a few questions:

1. Can I place my content over the video (CSS), while the video runs in the back
ground? How?

2. Can I set the code to play once and not loop? How?

Thanks!

Hipnotik

Dale Neighed:

Hipnotik,

Yes, you can do all of those things. The class has a setting, for looping. If you don’t want it to loop, you turn it off.

Dale Neighed:

Jaramore7,

It sounds like your FLV has damaged meta data.

Try moving the original FLVS the file comes with to your new directory and seeing if they still play.

You just have to make a XML links to your video class yourself, and pass each file you want to play to the video class from that. This class is supposed to just play video. Not load in or handle XML etc.

Matt Neighed:

Hey Dale, thanks for the suggestion. I actually found out the problem was that the flv I was loading in had keyframes every 24 frames vs every frame. Now the video is working perfectly scrubbing back and forth with the mouse move. I was wondering, how do you access the cue points in the flv with this, I didn’t understand the documentation. I’m going to have different text appear at every cue point in the video, with a link.

Thanks for any help!

Lali Neighed:

I’m doing a school project that about carbon footprint and I’ll like to have a fullscreen video background for the project. and your example is along the lines of what I’m trying to achieve. How do I get a hold of the class to try it out?

Will Neighed:

Hi Dale.

First of thank you for the great work.

I am having a problem with my video not getting resized proportionally. I think it maybe is not picking up the dimensions of my flv.

The video playback is fine – only problem is the scaling.

Any suggestions?

Thanks,
Will

Dale Neighed:

Will,

The problem will be related to how you pass the video you are loading in to the NpFSObjectResize class.

THe first thing you need to do, is make sure you can set your videos dimensions correctly before you pass it to the NpFSObjectResize class. Simply set the width and height of your instance of the NpVideoProvider class to match your video. If you don’t know those dimensions, listen for the metaData event, and then set your videos dimensions. The reason for needing to do this, is that by default, Flash will size all new video instances at 320*240. Which is probably not the size or aspect ratio of your video.

The second issue. There was a bug in the NpFSObjectResize class, which I have since corrected that made it behave bad with video. You can simply download the NpFSObjectResize class again, and replace your copy with a newer version.

Hope that helps.

Will Neighed:

Hi Dale.

I am not quite sure where I need to set the width and height.

Can you tell me exactly where i should be doing this?

Thank you.

Dale Neighed:

Before you apply the instance of the NpVideoProvider to the NpFSObjectResize class.

What demo file are you using?

Will Neighed:

I am sorry, but I am not so much of a code-wizard. Yet. :)

I am using the Actionscript 3 Full Browser Background Video demo, basic version with just the video looping.

Dale Neighed:

Will,

Send me an email from the address you used to get the file and I’ll send you some sample code.

Will Neighed:

Dale,

I’ve sent you an email.

Jerry Neighed:

Great stuff!

Is it possible to seemless loop a progressive loaded h264-encoded mp4 (with correct moov atom at the beginning)? I can’t figure out, how to do it without a hickup. (Sorry for my bad english, I am german).

Thank you and best wishes!

_Jerry

Lali Neighed:

Thanks for this great class. Is there a way to fade in a video? if so how do i go about doing that. Thanks

Lali Neighed:

I’m trying to use the onCuePoint function in the video class and I can’t seem to get it to work, can you post an example of it on here

George Neighed:

Hi Dale.

Nice file!

I have one simple question. You mention in the BasicFullScreen class that if my video is not 4-3 aspect ration i need to change it in the NpFSObjectResize class, but I cannot find the variables in the file, that i have to change. Can you tell me exactly how to set my aspect ratio to 16:9 ? Thanks alot! George.

Dale Neighed:

George,

You need to set your flv’s dimensions before you pass it to the NpFSObjectResize class. Exactly how it occurs in the demo file.

George Neighed:

I have already done so, but it does not scale proportionally to the 16:9, instead it scales to 4:3.

And you write in the comments that I must change my aspect ratio in the NpFSObjectResize

George Neighed:

I got it, it was because my video didn’t align to center. Thx

phil Neighed:

Hi,
thanks for writing this class, it saved me a bunch of time.I’m attempting to use these classes on a new site that i am building. There are four main sections and each section had its own background video. The video gets loaded up when you open a section. The issue I’m having is that when you first load up, the video starts, but if you quickly try to open a new section before the video completes, the next video trys to load up and the whole browser completes. I only use one video object and loadFile to load the video. Any tips on debugging this? Seems like I’m overloading the buffer or something?

Anders Neighed:

Hello,

Lovely script. But there seems to be a problem with Firefox 3.0.4 on mac (havent tested it on Windows yet…) The video does not play, if you resize the browser window some weird pattern that flickers…

Also the video control menu i behaving strangely…

If this could be solved I will definately donate to get your script.

Cheers!

Dale Neighed:

Anders,

I tested it off my machine here (mac) using Firefox 3.04 and it worked fine. Let me know if it is behaving the same under windows and if so, I’ll have a bug to hunt down.

Sebas Neighed:

Nice work! I have only one question… What’s the best encoding format and setting for a full screen video ? Because if it’s too big the flash is getting lag…

Thanks!

Dale Neighed:

Sebas,

I generally use H264, but a flv will use less CPU, but look worse.

Morten Neighed:

hey
Nice script
I just have a small problem with it..
I’ve done some modifications to your script, so that it now loads a playlist xml-file to load the videos. This works perfect, but when i turn off the looping of the video, and try to make it go on to the next video-file automatically, it throws me an error about something with a parameter onLastSecond not existing in NpVideoProvider. It seem to have something to do with the NpVideoProviderEvent.END… but i can’t figure out what..
Do you have an idea on how to make it automatically go to the next video after the first one has ended??

I would really appreciate any kind of help…
cheers

Dale Neighed:

I’ve not come across that param, I’ll look into it.

Justin Neighed:

Awesome work, this is a killer script. I was stoked to donate.

In the basic file there is an image with a cyclops dude in the top right… Anyone know how to get rid of that?

Cheers,
J

Justin Neighed:

my bad.

it was just this code, pulling a frame. very cool [again]. Commented out addChild,

//listener for pulling cover art from video stream, if it has any..
private function handleVideoImageData(event:NpVideoProviderEvent):void {
var loader:Loader = new Loader();
loader.loadBytes(event.object);
//addChild(loader);
}

Will Neighed:

Hi Dale.

Can you tell me how to make this into a video slideshow?

You say in the description, that it is quite easy.

Thank you.

Dale Neighed:

@Will

Create an array that holds the urls of the videos you want to play in your slideshow, then for each new slide, load one of the video URLS in your array.

Will Neighed:

I know that would take me a lot of time to make it work.

How much would it cost me, for you to do it? Thanks

Dale Neighed:

@Will,

Email me with exactly what you want, and how you want it to work etc, and I’ll let you know.

Phil Neighed:

Hi,

Im using hi quality video for my background. It all works fine but the performance is fairly low. I get a framerate of around 15-20fps. I have been looking into flash’s publish setting for hardware acceleration. I have enabled it but it does not seem to make a difference. From what I have read I think hardware acceleration for h264 video is only available when in fullscreen take-over mode. Has anyone else been able to get hardware acceleration to work for this sort of video scaling?

Dale Neighed:

Yeah, it will only work for fullscreen take over mode.

I’m working on some other approaches to speed it up, but that will take a while to get released.

20 fps is low, it should be able to handle 30 fps fairly well. What hardware are you playing it back on?

daniel Neighed:

Hi,
I’m looking for a script like yours, i have found most of my answers reading the comments.

But i couldnt find if there is built in controls when using the external api to play and pause the movie from html.

Cheers

Kvist Neighed:

I can donate extra for a simple function to control the playback of the video with simple functions such as play pause triggered by javascript functions.

I think it would be useful to many people if its not already included.

daniel Neighed:

Was my question deleted?
Im really intrrested in buy this script, but i need to now this before i purchase.
Is it possible to pause the videostream from a HTML link using javascript?
I ill use Lightwindow to display quicktime videos over. So i need to now if its possible to send a variable in and pause the stream while lightwindow is open over.

Dale Neighed:

@ Daniel,

No, there is no API currently to call the classes methods from HTML. Maybe something I could add at some stage.

Justin Neighed:

Hey Dale,

Great script, I have been working with it for a while now. I am at a loss to get the BasicFullScreen.swf to work in Mac Firefox 3.0.8 it just shows up blank.

What are the required vars to put into the BasicFullScreen.swf embed script? I think it must be missing something on the embed code. I tried to use the embed code from the provided index.html file [for the FullVid.swf file].

That embed works in the above FF, but it shows up black when I try to call the Basic file. It works correctly in other browsers, just not FF.

I also have the developer flash player [no errors tho].

Any assistance would be great, I just need a solid example of the embed script for the BasicFullScreen.swf file[:

Thanks again, great work!
Cheers from vancouver, frost.

Josefina Neighed:

this is so impressive, yours might be my favorite site online, your sense of form/function is exquisite; and yet, i dont understand a thing of your full browser video class, i guess i thought i could figure it out with how little i know. but it’s encouraging, to keep learning.

Dale Neighed:

@Justin,

Firefox has some issues with SWFObject sometimes. Try using the built into Flash embedding routines that Flash makes for you when you publish your file.

Flash - Full Browser. | NoisyDesign.com Neighed:

[...] -http://www.blog.noponies.com/archives/85 – noponies full browser movie background. [...]

James Neighed:

Is it possible for the video to play straight away. In the demo the movie is paused and you have t click the play button. Thanks.

Dale Neighed:

Read the documentation, thats what its for.

The property you want is playAtStart = true;

cris Neighed:

hi, i’m sort of new to as3. So when I open the sample file and then I preview it, I get a white blank screen. What do I need to do to preview the fullscreen background video? Nothing shows. Thanks

Dale Neighed:

Works fine for me me, all the provided .flas display their content correctly.

Leave a neigh?