Folge dem Video um zu sehen, wie unsere Website als Web-App auf dem Startbildschirm installiert werden kann.
Anmerkung: Diese Funktion ist in einigen Browsern möglicherweise nicht verfügbar.
// Imports
import flash.media.*;
import caurina.transitions.*;
import caurina.transitions.properties.FilterShortcuts;
.
.
.
// Klassenvariablen
private var st:SoundTransform = null; // Soundsteuerung wie Lautstärke
var videoMC:MovieClip = new MovieClip(); // MovieClip für das Video
private var video:Video = null; // Das Video Objekt
private var nc:NetConnection = new NetConnection();
private var ns:NetStream = null;
private var bFullscreen:Boolean = false;
.
.
.
// Im Konstruktor
video = new Video(vWidth, vHeight);
videoMC.addChild(video);
videoMC.addEventListener(MouseEvent.CLICK, onVideoClick);
this.addChild(videoMC);
// Funktion zum abspielen eines Flash-Videos:
private function playVideo(url:String):void {
nc.connect(null);
ns = new NetStream(nc);
st = new SoundTransform(volume/100);
ns.soundTransform = st;
ns.addEventListener(NetStatusEvent.NET_STATUS, onStatusEvent);
video.attachNetStream(ns);
ns.client = this;
ns.play(url);
}
// Handler, der auf das Ende des Videos reagiert
public function onStatusEvent(stats:NetStatusEvent):void {
if( stats.info.code == "NetStream.Play.Stop" ) {
// Video ist zu Ende
}
}
// Lautstärke verändern
public override function updateVolume(volume:Number):void {
st = new SoundTransform(volume);
ns.soundTransform = st;
}
// Bei einem Click auf das Video Fullscreen oder halt net
public function onVideoClick(e:Event):void {
if ( bIsFullscreen == false ) {
Tweener.addTween(videoMC, {x:fsX,y:fsY, width:fsWidth, height:fsHeight, time:1, transition:"easeInOutSine"});
}
else {
Tweener.addTween(videoMC, {x:normX,y:normY + 190 - video.height/2, width:normWidth, height:normHeight, time:1, transition:"easeInOutSine"});
}
bIsFullscreen = !bIsFullscreen;
}
// Handler, der aufgerufen wird, wenn das Video geladen wurde
// Hier kannst du das Seitenverhältnis des Videos erfragen und entsprechend deine Fullscreenwerte setzen
public function onMetaData(meta:Object):void {
var bGotDims = true;
var ratio:Number = 0;
if( !meta.width || !meta.height ) {
bGotDims = false;
}
else {
ratio = meta.width/meta.height;
}
if( ratio == 0 ) {
video.width = vWidth;
video.height= vHeight;
}
else if ( ratio > videoRatio ) {
// Breite zaehlt
video.width = vWidth;
video.height= vWidth/ratio;
} else {
// Höhe zählt
video.height = vHeight;
video.width = vHeight*ratio;
}
if( ratio == 0 ) {
fsWidth = 1024;
fsHeight = 626;
}
else if ( ratio > fsRatio ) {
// Breite zaehlt
fsWidth = 1024;
fsHeight = 1024/ratio;
} else {
// Höhe zählt
fsHeight = 626;
fsWidth = 626*ratio;
}
normWidth = video.width;
normHeight= video.height;
fsX = 512 - fsWidth / 2;
fsY = 313 - fsHeight / 2;
videoMC.x = normX;
videoMC.y = (normY + 190) - video.height/2;
}
UPS...
In dem Forum gehts ja gar net um Programmierung ...
Egal, vielleicht kann ja jemand anders was damit anfangen ;-)
Pit