code_junkie

Play video from local file using Adobe AIR

Nov 13th, 2011
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. private function playVideo():void {
  2. var nc:NetConnection = new NetConnection();
  3. nc.connect(null);
  4.  
  5. var ns:NetStream = new NetStream(nc);
  6.  
  7. # onMetaData listener is required otherwise you get a ReferenceError
  8. var client:Object = new Object();
  9. client.onMetaData = function(metadata:Object):void {
  10. trace(metadata.duration);
  11. }
  12. ns.client = client;
  13.  
  14. var v:Video = new Video();
  15. v.attachNetStream(ns);
  16. stage.addChild(v);
  17.  
  18. var f:File = new File("/tmp/test.flv");
  19. ns.play(f.url);
  20. }
  21.  
  22. <?xml version="1.0" encoding="utf-8"?>
  23. <mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
  24. <mx:VideoDisplay source="D:DataProjectsFlex 3AirLocalVideobin-debugNightSky.flv" />
  25. </mx:WindowedApplication>
  26.  
  27. <?xml version="1.0" encoding="utf-8"?>
  28. <mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
  29. <mx:VideoDisplay source="file://D:/Data/Projects/Flex 3/AirLocalVideo/bin-debug/NightSky.flv" />
  30. </mx:WindowedApplication>
Add Comment
Please, Sign In to add comment