なぜか、Yahoo!ビデオキャストに「この動画はガイドライン違反により削除されました。」とされてしまった地下鉄走行動画。

Ref. ALPSLAB video (名古屋市営地下鉄 名城線 茶屋ヶ坂~砂田橋)

Yahoo!ビデオキャストに聞いてみたら「お問い合わせいただきました削除基準や、削除理由につきましては個別の回答を行うことはできかねます」とのこと。ちょいムカ(-_-+) まぁ答えてくれるとは思ってなかったけど。

とりあえず、せっかくなので動画を3Dキューブにしてみた。

クリックで再生&停止。

ソースコード(VideoCube.as)

Flex SDK + Papervision3D でコンパイル。


package {
 
  import flash.display.*;
  import flash.events.*;
  import flash.geom.*;
  import flash.media.*;
  import flash.net.*;
  import flash.text.*;
 
  import org.papervision3d.scenes.*;
  import org.papervision3d.objects.*;
  import org.papervision3d.cameras.*;
  import org.papervision3d.materials.*;
 
  [SWF(width="400", height="400", backgroundColor="#000000", frameRate="30")]
 
  // 
  public class VideoCube extends Sprite {
 
    private var container : Sprite;
    private var scene     : Scene3D;
    private var camera    : Camera3D;
    private var rootNode  : DisplayObject3D;
 
    private var obj:Array = new Array();
 
    // 3Dオブジェクト踊らせ用パラメータ
    private var valx    : Number = 0;
    private var valy    : Number = 0;
 
    // Video
    private var netconnection : NetConnection;
    private var netstream     : NetStream;
    private var video         : Video;
 
    public function VideoCube():void {
 
      // リサイズに対応(swfをブラウザで直接ひらいているときとか)
      stage.addEventListener(Event.RESIZE, onStageResize);
 
      // 定期的にイベント発生
      addEventListener(Event.ENTER_FRAME, myLoopEvent);
 
      stage.addEventListener(MouseEvent.CLICK, myClick);
 
      // 表示用の Sprite オブジェクトを生成
      container = new Sprite();
      container.x = 400 / 2; // at center : swf width  = 400
      container.y = 400 / 2; // at center : swf height = 400
      addChild(container);
 
      // シーンオブジェクトを作る
      scene = new Scene3D(container);
 
      // カメラオブジェクトを作る
      camera = new Camera3D();
      camera.z = -300;
      camera.focus = 500;
      camera.zoom = 1;
 
      // ルートノードを作る
      rootNode = new DisplayObject3D();
      scene.addChild(rootNode);
 
      // 動画読み込み
      netconnection = new NetConnection();
      netconnection.addEventListener(NetStatusEvent.NET_STATUS, myNetStatus);
      netconnection.connect(null);
      netstream = new NetStream(netconnection);
      netstream.addEventListener(NetStatusEvent.NET_STATUS, myNetStatus);
      video = new Video();
      video.attachNetStream(netstream);
    }
 
    private function createVideoCube():DisplayObject3D {
 
      var material:VideoStreamMaterial = new VideoStreamMaterial(video, netstream);
      material.doubleSided = true;
 
      var planeSize:int = 300;
      var segment:int = 2;
 
      // using this
      var cube:Cube = new Cube(
        material, planeSize, planeSize, planeSize, segment, segment, segment);
      cube.x =  0;
      cube.y =  0;
      cube.z =  0;
      return cube;
    }
 
    private var initVideoCube:Boolean = false;
    private var flushVideoCube:Boolean = true;
 
    private function myClick(event:Event):void {
      if(!initVideoCube){
        // 最初の再生
        initVideoCube = true;
        var vc:DisplayObject3D = createVideoCube();
        rootNode.addChild(vc);
        obj.push(vc);
        flushVideoCube = false;
        netstream.play("VideoCube.flv");
      }else if(flushVideoCube){ // 2周目の動きがあやしい……
        // リプレイ
        flushVideoCube = false;
        netstream.seek(0);
      }else{
        // ポーズ&レジューム
        netstream.togglePause();
      }
    }
 
    private function myNetStatus(event:NetStatusEvent):void {
      if(event.info.code == "NetStream.Buffer.Flush"){
        flushVideoCube = true;
      }
    }
 
    private function myLoopEvent(event:Event):void {
 
      valx += container.mouseX / 100;
      valy += container.mouseY / 100;
 
      for(var i:int; i<obj.length; i++){
        obj[i].rotationY = valx;
        obj[i].rotationX = valy;
      }
 
      scene.renderCamera(camera);
    }
 
    private function onStageResize(event:Event):void {
      container.x = stage.stageWidth  / 2;
      container.y = stage.stageHeight / 2;
    }
    
  }
}

# これを使うとショボいジェットコースター動画でも、再生しながらくるくる回すとけっこういい絶叫マシンになるかも(^_^;

一応、YouTube にもアップロードしておいた

Ref. YouTube - 名古屋市営地下鉄 名城線 茶屋ヶ坂~砂田橋

過去の関連エントリ

ルートビデオ: 名古屋市営地下鉄 名城線 茶屋ヶ坂~砂田橋

ルートビデオ再び: 名古屋市営地下鉄 名城線 茶屋ヶ坂~砂田橋

tags: zlashdot Flash Flash Flex Papervision3D

Posted by NI-Lab. (@nilab)