Adobe AIR的:如何播放本地的MP3文件?

编程入门 行业动态 更新时间:2024-10-25 12:19:30
本文介绍了Adobe AIR的:如何播放本地的MP3文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我测试的Adobe AIR使用Flex,我想通过一个打开文件对话框中发挥的MP3,我这样做:

I'm testing Adobe AIR with flex, and I wanted to play a mp3 via an open file dialog, I did that :

import flash.filesystem.*; import flash.events.Event; import flash.media.*; import mx.core.SoundAsset; public var loadedFile:File; public var channel:SoundChannel; public var song:SoundAsset; private function loadFile():void { loadedFile = new File(); loadedFile.browseForOpen("Open multimedia File"); loadedFile.addEventListener(Event.SELECT, fileSelected); } private function fileSelected(event:Event):void { song = new SoundAsset() song.load(URLRequest(loadedFile.url)); channel = song.play(); }

但是,当我试图打开一个文件,打开文件对话框关闭后,我得到这个错误:

But when I try to open a file, after the Open file dialog close, I get this error :

TypeError: Error #1034: Type Coercion failed: cannot convert "file:///C:/Users/Kedare/Music/05-Scene%20V%20~%20Prelude.mp3" to flash.URLRequest.

我找不到任何有关这对谷歌或其他文件,都让我觉得是有关的文档使用URL,而不是本地文件播放声音:(

I can't find anything related to that on Google or another documentation, all the docs I find is related to play a sound using URL and not Local files :(

什么可问题你知道吗?我该怎么办?

Any idea of what can be the problem ? What can I do ?

感谢您!

推荐答案

修改

song.load(URLRequest(loadedFile.url));

song.load(new URLRequest(loadedFile.url));

更多推荐

Adobe AIR的:如何播放本地的MP3文件?

本文发布于:2023-11-23 15:42:18,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1621996.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:文件   Adobe   AIR

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!