0

i want to developing Audio player using AVAudioplyaer framework.I have some MP3 URLS. I want to using Local DataBase (SQLITE3). The total MP3 urls are put in SQLITE3.And i want to get the urls from sqlite3. This is my App Requirement. I am having idea using json framework how to get the audio urls. But i have no idea using Local Database how to get the urls.Please give me any idea how to put the MP3 URLS in SQLITE3 and also how to get the urls from sqlite3. I am new to the Programming. Thanks in advance.

user2930730
  • 359
  • 2
  • 4
  • 14

2 Answers2

0

two ways to store

  1. store the URLS in a string then retrieve it... or

  2. store your audio in sqlite using BLOB...

Rugmangathan
  • 3,186
  • 6
  • 33
  • 44
0

use SQLite Database Browser software for creating the sqlite database and add urls to your table and then use that file in your application or alternatively you can create database using code and then read data. the FMDB library is very good option for that. For creating the database using code you can use this link creating sqlite database and for selecting urls using select query you can use

-(NSArray *)getAudioUrls {

    sqlite3 *database;
    sqlite3_open([[DBAccess getDBPath] UTF8String], &database);
    NSMutableArray *result = [[NSMutableArray alloc]init] ;

    NSString *sql = @"SELECT url FROM AudioUrl"; //AudiUrl is sqlite table name

    sqlite3_stmt *statement;

    int sqlResult = sqlite3_prepare_v2(database, [sql UTF8String], -1, &statement, NULL);

    if(sqlResult == SQLITE_OK)
    {
        while(sqlite3_step(statement) == SQLITE_ROW)
        {
            AudioFile *audio = [[Celebrity alloc]init]; // Create audiofile class
            [audio setAudioUrl:[NSString stringWithUTF8String:(char *) sqlite3_column_text(statement, 0)]];

            [result audio];

        }
    } else
    {
        result = nil;
        printf( "could not prepare statemnt: %s\n", sqlite3_errmsg(database) );
    }

    sqlite3_reset(statement);
    sqlite3_finalize(statement);

    sqlite3_close(database);

    return result;

}

#pragma mark Class functions

+ (NSString *) getDBPath {
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory , NSUserDomainMask, YES);
    NSString *documentsDir = [paths objectAtIndex:0];
    return [documentsDir stringByAppendingPathComponent:@"Audio.sqlite"];
}
Community
  • 1
  • 1
Suhit Patil
  • 11,748
  • 3
  • 50
  • 60
  • Hi suhit Thanks for your reply.But i cant understand what is SQLITE database browser.how to use it for creating the sqlite and add urls to my table? – user2930730 Nov 13 '13 at 12:11
  • it's a software, you can use it for creating sqlite database rather than creating using code. http://sourceforge.net/projects/sqlitebrowser/ – Suhit Patil Nov 13 '13 at 12:29