Namespaces

Variants
Actions

Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.

Archived:How to create a playlist for the music player using Symbian C++

From Wiki
Jump to: navigation, search

Archived.pngArchived: This article is archived because it is not considered relevant for third-party developers creating commercial solutions today. If you think this article is still relevant, let us know by adding the template {{ReviewForRemovalFromArchive|user=~~~~|write your reason here}}.

Article Metadata
Tested with
Devices(s): Nokia E71, N95, N96
Compatibility
Platform(s): S60 3rd Edition FP1, S60 3rd Edition FP2
S60 3rd Edition FP2
S60 3rd Edition FP1
Article
Keywords: Playlist, Music player, M3U
Created: User:Kbwiki (08 Sep 2009)
Last edited: hamishwillee (14 Jun 2012)

Contents

Overview

This article provides the way to create a playlist for the standard S60 music player.

Description

The standard S60 mMusic player supports playlists in the M3U format (Moving Picture Experts Group Audio Layer 3 Uniform Resource Locator). So, to create playlist programmatically, we need to write an M3U file with the file names of each track in the playlist. File paths can be either absolute or relative to the M3U file.

Solution

The sample M3U file:

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

Create a file with the extension .m3u and write the song names and paths using RFile::Write(). We need to write into the m3u file in UTF8 format (use 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();

Note

The music player needs to be refreshed in order to show the playlist in the music player's playlist library.

Related article

M3U wiki page[1]

This page was last modified on 14 June 2012, at 11:13.
84 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×