[Sample] Playing with music file[1]

[入库:2005年8月18日] [更新:2007年3月25日]

本文简介:选择自 denal 的 blog

getting into my music

if you decide to have your own interface for playing music, one of the fundamental decisions is how to manage your library of mp3/wma files. do you use the existing library of another program (such as microsoft?windows media?player), or do you write your own? this is not a particularly easy decision, and i am still not completely sure which is the best choice, but i had to make a decision or i would never be able to move on in my development. i decided that using a database to create my own library/catalog of music files would be the most flexible option, although this path would likely require more work at the beginning. i set up a new database in msde on my development machine, and created the following schema (actually it is a fair bit more complicated, but these are the key tables):

click here for larger image.

figure 1. a simple database schema for holding my music library

of course, after building my own system, along came what is arguably a much better one in the form of windows xp media center edition, which created a bit of a conflict in my mind. why continue building my own if i could go get a better one that is completely done for me? the confusion only lasted a few moments though; i am a programmer, so i often build things when it would be much more logical to buy them.

reading the tags

although i didn't have any formal requirements or architectural documentation (maybe it's just me, but having to produce all the same documentation as a work project would take some of the fun out of it), i knew that moving to the next stage would require code that could read all of the attributes from an audio file梐rtist, song, and album names, for example.

i originally assumed my collection would be in mp3 files, which store attributes using various flavors of a system called "id3," so using the resources available at www.id3.org, i started creating a microsoft windows .net framework-based library that could handle the more common versions of id3 tags. in parallel, i began ripping my cd collection onto my hard drive (for my own personal use, of course). for this, i used windows media player, and i spent some time investigating the various options available in terms of wma (windows media audio) versus mp3 and different encoding rates.

note   choosing a format and encoding quality requires some research, especially before you rip several hundred cds to your hard drive. (that is not a task i would like to redo.) i won't spent a lot of time explaining why i chose wma. i am not really an objective reviewer of audio file formats anyway, but it appears to produce higher quality at lower file sizes, which seems like a good thing to me. starting with version 9 of windows media player, a variable bit rate (vbr) encoding format is available, which might turn out to be the best choice, but i didn't have access to that format when i was ripping my collection to disk.

i ended up choosing wma at around 160 kilobits per second (kbps). now i needed to make sure my attribute reading code could handle both wma and mp3 files. well, to make a long story somewhat shorter, i decided that since windows media player could handle both file formats, i should take a look at the windows media sdk. sure enough, the sdk even provided a sample to do exactly what i wanted. instead of doing all my work for me and writing the sample as a com component, however, it was a regular old console application.

本文关键:window media 9
  相关方案
Google
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top