【问题标题】:How can I make a dynamic video player in Actionscript 3.0 in Flash如何在 Flash 中使用 Actionscript 3.0 制作动态视频播放器
【发布时间】:2017-04-05 16:33:16
【问题描述】:

需要 Actionscript 3 中的视频播放器代码。可以从我手机存储位置的任何文件夹中播放 mp4 格式的视频?

【问题讨论】:

  • 我认为您之所以被否决是因为您的编程/技术问题质量。尝试显示您尝试过的代码,以便我们帮助您修复它。短句适用于通灵者和/或谷歌。考虑一下:“需要...” = 不允许免费赠品请求,“有可能..?” = 查看 AS3 手册。无论如何我试图在下面提供帮助,让我知道它是否正常工作......

标签: actionscript-3 flash video media-player video-gallery


【解决方案1】:

由于它适用于移动设备(使用 AIR),请尝试使用 File 类。它允许您浏览文件。
您可以使用FileFilter锁定文件浏览以仅列出特定格式

在此处阅读 Adob​​e 指南:Working with File objects in AIR

以下是您可以尝试的示例代码。目前未经测试(但从另一个Answer修改)。

//someGraphic is your own UI element (clicked/tapped) for user to begin file browse
someGraphic.addEventListener(MouseEvent.CLICK, browseVideo);

function browseVideo(evt:MouseEvent = null):void 
{
    var vidFiles : FileFilter = new FileFilter("Choose Video", " *.mp4 ; *.flv");

    var file:File = new File();
    file.addEventListener(Event.SELECT, onFileSelected); 
    file.browse([vidFiles]);
}

function onFileSelected(evt:Event):void 
{
    //auto-extract path to give to NS video player
    playVideo(evt.currentTarget.nativePath);
}

function playVideo(video_path:String):void
{
    // using a Video + NetStream object
    var nc:NetConnection = new NetConnection();
    nc.connect(null);
    var ns:NetStream = new NetStream(nc);
    ns.client = this;
    var video:Video = new Video();
    video.attachNetStream(ns);
    addChild(video);

    ns.play(video_path); //is using auto-extracted path
}

【讨论】:

  • 感谢您的帮助 ,,, 以 mp4 格式正确运行..!! ,, 您的代码需要选择一个视频到任何位置,, 但我需要从定义的 Video_folder 播放所有视频任何格式,,,, 不需要重命名这样的 video1.mp4 或 video2.flv,,, 请帮助. .谢谢@VC.One
猜你喜欢
  • 1970-01-01
  • 2021-01-01
  • 1970-01-01
  • 2023-03-25
  • 2011-06-24
  • 2021-09-17
  • 1970-01-01
  • 2011-05-31
  • 1970-01-01
相关资源
最近更新 更多