/// <summary> /// Build a url to the otamata sound player. /// </summary> /// <param name="soundId">The sound id</param> /// <param name="version">What version of player</param> /// <param name="displayType">What display type of player</param> /// <returns>The player url</returns> public static string SoundPlayerUrl(string soundId, SoundPlayerVersion version, PlayerDisplayType displayType) { if (version == SoundPlayerVersion.Version1) { /* * /player/([sound number digit as letter][random letter])*[player version as letter (a=0, b=2, etc.)][random letter][display type as letter] * * Example * * player version = 1 * dispay type = 0 * sound number = 23 * * /player/b6cPbWa */ string encryptedSoundId = string.Empty; int lowerCaseaInAscii = 97; int upperCaseAInAscii = 65; int soundIdLen = soundId.Length; Random rand1 = new Random(); for (int i = 0; i < soundIdLen; i++) { int digit = soundId[i] - '0'; // [soundId characterAtIndex:i] - '0'; // encryptedSoundId = [NSString stringWithFormat:@"%@%c%c", encryptedSoundId, lowerCaseaInAscii + digit, random() % 26 + upperCaseAInAscii]; encryptedSoundId = string.Format("{0}{1}{2}", encryptedSoundId, (char)(lowerCaseaInAscii + digit), (char)(rand1.Next(26) + upperCaseAInAscii)); } // encryptedSoundId = [NSString stringWithFormat:@"%@%c%c%c", encryptedSoundId, lowerCaseaInAscii + version, random() % 26 + upperCaseAInAscii, lowerCaseaInAscii + displayType]; encryptedSoundId = string.Format("{0}{1}{2}{3}", encryptedSoundId, (char)(lowerCaseaInAscii + version), (char)(rand1.Next(26) + upperCaseAInAscii), (char)(lowerCaseaInAscii + displayType)); // return [NSString stringWithFormat:@"http://%@/player/%@", [self remoteHost], encryptedSoundId]; return(string.Format("{0}/player/{1}", Config.ServerName, encryptedSoundId)); } else { throw new NotImplementedException(string.Format("Invalid sound player version: {0}", version)); } }
/// <summary> /// Build a url to the otamata sound player. /// </summary> /// <param name="soundId">The sound id</param> /// <param name="version">What version of player</param> /// <param name="displayType">What display type of player</param> /// <returns>The player url</returns> public static string SoundPlayerUrl(int soundId, SoundPlayerVersion version, PlayerDisplayType displayType) { return(SoundPlayerUrl(soundId.ToString(), version, displayType)); }