it's my first question here. I searched all the way, tried a lot but couldn't get what I want to do. Here's the problem: I have an app that uses SoundPool to play sounds, just that. But there's a lot to load (>50) and it takes time to load one by one. take a look;
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_fragment_hue, container, false); DBSupport.setContext(getActivity()); lista = DBSupport.getListaHue();
<!-- page content -->
<StackPanel Grid.Row="1" VerticalAlignment="Top" Orientation="Horizontal"
Padding="12,8,0,0">
<ListView ItemsSource="{x:Bind Items}" />
</StackPanel>
And I want to make a thread or an Async to load it while I scroll through the ListView
Any advice?
PS: I'm a newbie, so sorry if the code is confuse.
Thanks!!
答案 0 :(得分:0)
您需要做的是在onCreate()中启动您希望能够在活动中播放的所有声音。在对任何声音调用load()之前,您还应该设置一个带有setOnLoadCompleteListener()的侦听器,以便在所有声音都已加载时计算出来。只有在声音完成后才能尝试播放它们。
如果您需要在用户与UI交互之前完全加载声音,您可能需要提供某种等待指示器,直到所有声音都完成。完成后,显示您的UI。然后在需要时只需play声音即可开始播放。