You Are Here:

Community: Wiki

This page was last modified on 22 October 2009, at 16:02.

如何为音乐播放器生成一个播放列表

From Forum Nokia Wiki

TSS001461

设备, 软件 版本: S60 3rd Edition FP1, S60 3rd Edition FP2


详细描述

S60标准的音乐播放器支持M3U格式的播放列表(Moving Picture Experts Group Audio Layer 3 Uniform Resource Locator)

这样我们可以通过程序来生成列表。我们需要将每个track的文件名写入到播放列表中(M3U文件),文件路径可以是相对路径

解决方案

M3U文件示例:

#EXTM3U
Audio1.mp3
Audio2.mp3
Audio3.mp3
Audio4.mp3

生成一个.m3u后缀的文件,并将歌曲名和路径使用RFile::Write()写入。我们需要采用UTF8格式

(CnvUtfConverter::ConvertFromUnicodeToUtf8)

//Creating a pre-defined playlist
RFile file;
TInt nRetVal;
TInt err;
RFs fs;
TBuf<500> string;
//Header
string.Copy(_L("#EXTM3U\n"));
//Songs relative paths
string.Append(_L("song1.mp3\n"));
string.Append(_L("song2.mp3\n"));
string.Append(_L("song3.mp3"));
User::LeaveIfError(fs.Connect());
CleanupClosePushL(fs);
_LIT(KLogFile,"c:\\data\\MyPlayList.m3u");
err = file.Create(fs, KLogFile, EFileWrite);
if( err == KErrAlreadyExists)
file.Open(fs, KLogFile, EFileWrite);
TPtrC8 representation((TUint8*)(&string)->Ptr(), (&string)->Size());
TInt pos;
nRetVal = file.Size(pos);
TBuf8<500> stringutf;
CnvUtfConverter::ConvertFromUnicodeToUtf8(stringutf, string);
nRetVal = file.Write(stringutf);
nRetVal = file.Flush();
file.Close();
CleanupStack::PopAndDestroy();

注意

音乐播放器需要刷新一下,才能显示

Related Wiki Articles

No related wiki articles found

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia 
RDF Facets: qdcZidentifierQSxhttpE3aE2fE2fwikiE2eforumE2enokiaE2ecomE2findeE78E2ephpE2fFileE3aMicrokernelE5fArchitectureE2eGIFX qdcZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qdcZtypeQUqfntypeZCommunityContentQ qdcZtypeQUqfntypeZE52esourceQ qdcZtypeQUqfntypeZWebpageQ qdcZtypeQUqfntypeZWikiContentQ qdcZtypeQUqmarsZManagedE52esourceQ qdcZtypeQUqwebZInformationE52esourceQ qdcZtypeQUqwebZPageQ qdcZtypeQUqwebZE52esourceQ qdcZtypeQUqrdfsZE52esourceQ qfnZtypeQUqfntypeZCommunityContentQ qfnZtypeQUqfntypeZE52esourceQ qfnZtypeQUqfntypeZWebpageQ qfnZtypeQUqfntypeZWikiContentQ qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX qrdfZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qrdfZtypeQUqfntypeZCommunityContentQ qrdfZtypeQUqfntypeZE52esourceQ qrdfZtypeQUqfntypeZWebpageQ qrdfZtypeQUqfntypeZWikiContentQ qrdfZtypeQUqmarsZManagedE52esourceQ qrdfZtypeQUqwebZInformationE52esourceQ qrdfZtypeQUqwebZPageQ qrdfZtypeQUqwebZE52esourceQ qrdfZtypeQUqrdfsZE52esourceQ