English 中文(简体)
Unable to access file in ResourcesSounds folder
原标题:
  • 时间:2023-06-17 02:16:38
  •  标签:
  • maui

I m using .net Maui and attempting to create audioManager players for a couple of sound files located in the ResourcesSounds folder in the project.

The code is this:

var playerStartSound = audioManager.CreatePlayer(await FileSystem.OpenAppPackageFileAsync("record-start.mp3"));

When it runs, I get an error:

System.IO.FileNotFoundException:  Could not find file  /private/var/containers/Bundle/Application/3C75FEDB-E70F-43F9-8F37-9AC51D76BB62/MyApp.app/record-start.mp3 . 

I m not sure if the ResourcesSounds should be added to the above path or if the OpenAppPackageFileAsync will search the subfolder s or not?

What am I doing wrong here? How can I access the files located in the MyAppResourcesSounds folder?

问题回答

Look at the path in the error message:

../MyApp.app/record-start.mp3

Q: Based on that error message, what folder is it looking in, for that file?
A: Directly in folder Resources.

Fix:
Give the correct path to your file:

    ..FileSystem.OpenAppPackageFileAsync("Sounds/record-start.mp3"));




相关问题
Unable to access file in ResourcesSounds folder

I m using .net Maui and attempting to create audioManager players for a couple of sound files located in the ResourcesSounds folder in the project. The code is this: var playerStartSound = ...

.NET MAUI native audio player

I am interested is there a way to play mp3 files from the phone internal memory using the built in native audio player. I am asking this, because I want to implement an equalizer too, so I am guessing ...

Integrating Push Notifications in MAUI .NET 7 Applications

I m developing a cross-platform application using MAUI .NET 7 and I would like to add push notification functionality to my application. I m considering using Firebase Cloud Messaging or Azure ...

Databinding doesnt work in my xaml.cs file

I am trying to load some data from my Model to the xaml.cs file. But it doesn t work. In my Mainpage.xaml i have a binding property inside a label. In the code behind file a BindingContext to my ...

Do some tasks after OnAppearing() in MAUI

I have a maui community toolkit expander control in my page. On Tapping the header the content is shown/hidden .I got a Maui map in the expander s content. It display properly if the expander is in ...

NET MAUI是否有可调整的分辨率特征?

页: 1 NET MAUI用于一个即将到来的项目,但我发现一件失踪的事情是,我需要的是分裂的特征。 我发现,散射器在移动上可能不会产生作用,但Im主要针对Windows......。

How to optimize detail page reset button in C# MAUI?

I ve implemented a Reset button on a Detail page in C# MAUI and it works, but I can t figure out why I need to be so explicit in the way I capture the initial data to perform the reset, when requested....

热门标签