One of the main changes was my desire to "kill" the AudioCache API due to the vast confusion that it caused with users (despite our best efforts documenting everything).
We still have the AudioCache class but its APIs are exclusively dedicated to transforming asset files into local files, cache them, and provide the path. It however doesn't normally need be used by end users because the AudioPlayer itself is now capable of playing audio from any Source.
What is a Source? It's a sealed class that can be one of:
UrlSource: get the audio from a remote URL from the Internet
DeviceFileSource: access a file in the user's device, probably selected by a file picker
AssetSource: play an asset bundled with your app, normally within the assets directory
BytesSource (only some platforms): pass in the bytes of your audio directly (read it from anywhere).
If you use AssetSource, the AudioPlayer will use its instance of AudioCache (which defaults to the global cache if unchanged) automatically. This unifies all playing APIs under AudioPlayer and entirely removes the AudioCache detail for most users.
其中一个主要的变化是我想 "杀死 "AudioCache API,因为它给用户带来了巨大的混乱(尽管我们尽了最大努力记录了一切)。
我们仍然有AudioCache类,但它的API专门用于将资产文件转化为本地文件,缓存它们,并提供路径。然而,它通常不需要被终端用户使用,因为AudioPlayer本身现在能够播放来自任何Source的音频。
什么是Source?它是一个密封的类,可以是以下之一。
UrlSource:从互联网上的一个远程URL获取音频
设备文件源(DeviceFileSource):访问用户设备中的一个文件,可能是由一个文件选择器选择的。
AssetSource:播放与你的应用程序捆绑的资产,通常在assets目录中
BytesSource(只有一些平台):直接传入你的音频字节(从任何地方读取)。
如果你使用AssetSource,AudioPlayer将自动使用它的AudioCache实例(如果没有改变,默认为全局缓存)。这就把所有的播放API统一到AudioPlayer下,对大多数用户来说,完全删除了AudioCache的细节。