Namespaces
Variants
Actions

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

Jump to: navigation, search
Archived.png
Archived: 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

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 14:13.
244 page views in the last 30 days.
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved