У вас есть хороший пример фонового приложения GPS, которое воспроизводит звуки даже в фоновом режиме:
http://www.informit.com/articles/article.aspx?p=1646438& seqNum = 5
В этом примере используется AudioToolbox.
Я сам провел тест, и он работает: создайте простой проект, который отслеживает сообщение GPS (UIBackgroundModes
location
), и каждую полученную позицию x, воспроизводите звук, используя
AudioServicesPlaySystemSound(soundId);
Тогда, если вы добавите audio
как часть вашего UIBackgroundModes
, и звуки будут воспроизводиться, даже если приложение больше не находится на переднем плане.
Я сделал такой тест, и он работает нормально!
(мне не удалось заставить его работать с AVPlayer, поэтому я отказался от AudioToolbox)
I'm always setting CurrentThread.Current(Ui)Culture to the correct value in our (ASP.NET) applications. This is usually done at the begin of each request, based on the user's preferences or a default value stored in a config file (if the user has not defined a preference).
After setting these properties of the current thread, you can stop thinking about it - numbers, dates, etc. will be correctly formatted/parsed, even when no IFormatProvider is provided to these methods. Otherwise, you have to ensure that the correct IFormatProvider is passed everywhere.
I the case of a library, I think it should just rely on the application for these things and should not have to worry about these things.
Как вы говорите, в закрытой среде вы можете вызывать методы без предоставленного IFormatProvider.
По мере написания вы можете предоставить объект CultureInfo следующим образом:
Console.WriteLine(String.Format(CultureInfo.CurrentCulture, "{0}", DateTime.Now));
Console.WriteLine(String.Format(new CultureInfo("en-US"), "{0}", DateTime.Now));
Это будет для меня отображать дату двумя разными способами, поскольку моя CurrentCulture на шведском языке:
28 мая 2009 г., 13:12:43
28.05.2009 13:12:43
CultureInfo.CurrentCulture обрабатывает форматирование дат и т. д. и обеспечивается настройками на вашем текущем компьютере.
CurrentCulture.CurrentUiCulture имеет отношение к локализации, то есть к переводу. Это означает то, что отображается в меню и т. Д. В окнах.
Я предполагаю, что поведение методов по умолчанию - использовать CurrentCulture, если ничего не указано.
I set the current culture to US english because in my country few 'intelligent' persons decided that decimal separator is comma. Sometimes decimal number is with ',' and sometimes with '.'. Not all computers have regional settings configured correctly and you shouldn't rely on that.
To set that application-wide settings:
Application.CurrentCulture = new CultureInfo("en-US");
Application.CurrentCulture.NumberFormat.NumberDecimalSeparator = ".";