Skip to content

Commit

Permalink
iOS: Peak file now generating in background when a song starts playing.
Browse files Browse the repository at this point in the history
PeakFile.cs has been renamed to PeakFileGenerator.cs and is no longer dependent on System.Reactive.
Added Normalizer class to MPfm.Core.

Related to issue #323 and issue #405.
  • Loading branch information
ycastonguay committed Mar 12, 2013
1 parent 5d1e117 commit 75edef4
Show file tree
Hide file tree
Showing 7 changed files with 778 additions and 861 deletions.
1 change: 1 addition & 0 deletions MPfm/MPfm.Core/MPfm.Core.iOS.csproj
Expand Up @@ -157,5 +157,6 @@
<Compile Include="OS.cs" />
<Compile Include="CacheStore.cs" />
<Compile Include="ByteArrayQueue.cs" />
<Compile Include="Normalizer.cs" />
</ItemGroup>
</Project>
61 changes: 61 additions & 0 deletions MPfm/MPfm.Core/Normalizer.cs
@@ -0,0 +1,61 @@
// Copyright © 2011-2013 Yanick Castonguay
//
// This file is part of MPfm.
//
// MPfm is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// MPfm is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with MPfm. If not, see <http://www.gnu.org/licenses/>.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Globalization;

namespace MPfm.Core
{
/// <summary>
/// Normalizing class for strings and other objects.
/// </summary>
public static class Normalizer
{
/// <summary>
/// Normalizes a string for URL.
/// Taken from http://stackoverflow.com/questions/249087/how-do-i-remove-diacritics-accents-from-a-string-in-net
/// </summary>
public static string NormalizeStringForUrl(string name)
{
String normalizedString = name.Normalize(NormalizationForm.FormD);
StringBuilder stringBuilder = new StringBuilder();

foreach (char c in normalizedString)
{
switch (CharUnicodeInfo.GetUnicodeCategory(c))
{
case UnicodeCategory.LowercaseLetter:
case UnicodeCategory.UppercaseLetter:
case UnicodeCategory.DecimalDigitNumber:
stringBuilder.Append(c);
break;
case UnicodeCategory.SpaceSeparator:
case UnicodeCategory.ConnectorPunctuation:
case UnicodeCategory.DashPunctuation:
stringBuilder.Append('_');
break;
}
}
string result = stringBuilder.ToString();
return String.Join("_", result.Split(new char[] { '_' }
, StringSplitOptions.RemoveEmptyEntries)); // remove duplicate underscores
}
}
}
3 changes: 2 additions & 1 deletion MPfm/MPfm.Sound/MPfm.Sound.iOS.csproj
Expand Up @@ -161,6 +161,7 @@
<ItemGroup>
<Folder Include="Lib\iOS\" />
<Folder Include="Lib\Android\" />
<Folder Include="PeakFiles\" />
</ItemGroup>
<ItemGroup>
<Compile Include="AudioFiles\AudioFile.cs" />
Expand Down Expand Up @@ -208,7 +209,6 @@
<Compile Include="Playlists\PlaylistItem.cs" />
<Compile Include="Playlists\PlaylistTools.cs" />
<Compile Include="Playlists\PlaylistFileFormat.cs" />
<Compile Include="PeakFile.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Tags\APETag.cs" />
<Compile Include="Tags\SV7Metadata.cs" />
Expand All @@ -218,5 +218,6 @@
<Compile Include="Tags\SV8Tag.cs" />
<Compile Include="Tags\SV8Metadata.cs" />
<Compile Include="XingInfoHeaderReader.cs" />
<Compile Include="PeakFiles\PeakFileGenerator.cs" />
</ItemGroup>
</Project>

0 comments on commit 75edef4

Please sign in to comment.