本文介绍了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文件?
发布评论