Click here to Skip to main content
15,896,915 members
Articles / Desktop Programming / Windows Forms

BSEtunes

Rate me:
Please Sign up or sign in to vote.
4.67/5 (11 votes)
24 Apr 2010CPOL4 min read 64.8K   4.3K   58  
BSEtunes is a MySQL based, full manageable, networkable single or multiuser jukebox application
using System;
using System.IO;
using BSE.Platten.BO;
using System.Globalization;
using BSE.Platten.Audio.Properties;

namespace BSE.Platten.Audio
{
	/// <summary>
	/// Zusammenfassung f�r CMediaMetaData.
	/// </summary>
	public class CWMFMediaData : AudioData
	{
		#region FieldsPrivate
		#endregion
		
		#region MethodsPublic

		public CWMFMediaData()
		{
			//
			// TODO: F�gen Sie hier die Konstruktorlogik hinzu
			//
		}

		public override AudioMetaData GetMediaMetaData(string fileInfoFullName)
		{
            FileInfo fileInfo = new FileInfo(fileInfoFullName);
			AudioMetaData audioMetaData = null;
            if (fileInfo.Exists == true)
			{
                if ((string.Compare(fileInfo.Extension.ToLower(),AudioformatExtensions.Mp3) == 0) ||
                    (string.Compare(fileInfo.Extension.ToLower(),AudioformatExtensions.Wma) == 0))
				{
                    using (WMFSDK.CMetaDataEditor metaDataEditor = new WMFSDK.CMetaDataEditor())
                    {
                        audioMetaData = metaDataEditor.GetMediaMetaData(fileInfo.FullName);
                    }
				}
			}
			return audioMetaData;
		}

		public override void SetAttributeAuthor(string fileInfoFullName,string pwszAttribValue)
		{
			SetAttribute(fileInfoFullName,WMFSDK.WM.g_wszWMAuthor,(ushort)WMFSDK.WMT_ATTR_DATATYPE.WMT_TYPE_STRING,pwszAttribValue);
		}

		public override void SetAttributeAlbumTitle(string fileInfoFullName,string pwszAttribValue)
		{
			SetAttribute(fileInfoFullName,WMFSDK.WM.g_wszWMAlbumTitle,(ushort)WMFSDK.WMT_ATTR_DATATYPE.WMT_TYPE_STRING,pwszAttribValue);
		}

		public override void SetAttributeGenre(string fileInfoFullName,string pwszAttribValue)
		{
			SetAttribute(fileInfoFullName,WMFSDK.WM.g_wszWMGenre,(ushort)WMFSDK.WMT_ATTR_DATATYPE.WMT_TYPE_STRING,pwszAttribValue);
		}

		public override void SetAttributeYear(string fileInfoFullName,string pwszAttribValue)
		{
			SetAttribute(fileInfoFullName,WMFSDK.WM.g_wszWMYear,(ushort)WMFSDK.WMT_ATTR_DATATYPE.WMT_TYPE_STRING,pwszAttribValue);
		}

		public override void SetAttributeTrackNumber(string fileInfoFullName,string pwszAttribValue)
		{
			SetAttribute(fileInfoFullName,WMFSDK.WM.g_wszWMTrackNumber,(ushort)WMFSDK.WMT_ATTR_DATATYPE.WMT_TYPE_STRING,pwszAttribValue);
		}

		public override void SetAttributeTitle(string fileInfoFullName,string pwszAttribValue)
		{
			SetAttribute(fileInfoFullName,WMFSDK.WM.g_wszWMTitle,(ushort)WMFSDK.WMT_ATTR_DATATYPE.WMT_TYPE_STRING,pwszAttribValue);
		}

		public override void SetAttribute(string fileInfoFullName, string pwszAttribName, 
			ushort wAttribType, string pwszAttribValue)
		{
			FileInfo fileInfo = new FileInfo(fileInfoFullName);
			if (fileInfo.Exists == true)
			{
                if ((string.Compare(fileInfo.Extension.ToLower(),AudioformatExtensions.Mp3) == 0) ||
                    (string.Compare(fileInfo.Extension.ToLower(),AudioformatExtensions.Wma) == 0))
				{
					using (WMFSDK.CMetaDataEditor metaDataEditor = new BSE.Platten.Audio.WMFSDK.CMetaDataEditor())
					{
						metaDataEditor.SetAttribute(fileInfoFullName,pwszAttribName,wAttribType,pwszAttribValue);
					}
				}
			}
			else
			{
				string strFileNotFoundException = String.Format(
                    CultureInfo.CurrentUICulture,
                    Resources.IDS_FileNotFoundException,fileInfoFullName);
				throw new FileNotFoundException(strFileNotFoundException);
			}
		}

		#endregion
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Switzerland Switzerland
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions