void removeItemAt(int idx) { if((idx < 0) || (idx >= dequeueSize())) return; item* pItem = getItemAt(idx); item* pBefore = NULL; if(pItem != first) pBefore = getPrevItem(pItem); item* pAfter = NULL; if(pItem != last) pAfter = getNextItem(pItem); if((pBefore != NULL) || (pAfter != NULL)){ pBefore->next = pAfter; pAfter->prev = pBefore; }else if(pBefore == NULL){ first = getNextItem(first); first->prev = NULL; }else if(pAfter == NULL){ last = getPrevItem(last); last->next = NULL; } free(pItem); pItem = NULL; };
item* getItemAt(int idx) { int size = dequeueSize(); if((idx >= size) || (idx < 0)) return NULL; item* pItem = NULL; if(idx+1 <= size/2){ pItem = first; int cnt = 0; for(cnt = 0; (cnt != idx) && (cnt < size); ++cnt) pItem = getNextItem(pItem); }else{ pItem = last; int cnt = size-1; for(cnt = size-1; (cnt != idx) && (cnt >= 0); --cnt){ pItem = getPrevItem(pItem); } } return pItem; };
fsl_player_ret_val playlist_previous(fsl_player_handle handle, options* opt) { fsl_player* pplayer = NULL; pplayer = (fsl_player*)handle; fsl_player_drm_format drm_format; PlayItem * current = opt->current; PlayItem * next = getPrevItem(current); if(next) { opt->current = next; printf("%s\n", opt->current->name); pplayer->klass->stop(pplayer); pplayer->klass->set_media_location(pplayer, opt->current->name, &drm_format); pplayer->klass->play(pplayer); } switch( opt->repeat ) { case FSL_PLAYER_REPEAT_NONE: { if( next ) { opt->current = next; printf("%s\n", opt->current->name); pplayer->klass->stop(pplayer); pplayer->klass->set_media_location(pplayer, opt->current->name, &drm_format); pplayer->klass->play(pplayer); } else { //gcore_register_callback(gcore, NULL, NULL,0); // if not repeated mode or no next item, exit. //printf("%s(): No more multimedia files, exit.\n", __FUNCTION__); //player_exit(pplayer); } break; } case FSL_PLAYER_REPEAT_PLAYLIST: { if( next ) { opt->current = next; printf("%s\n", opt->current->name); pplayer->klass->stop(pplayer); pplayer->klass->set_media_location(pplayer, opt->current->name, &drm_format); pplayer->klass->play(pplayer); } else { next = getLastItem(opt->pl); opt->current = next; pplayer->klass->stop(pplayer); pplayer->klass->set_media_location(pplayer, opt->current->name, &drm_format); pplayer->klass->play(pplayer); } break; } case FSL_PLAYER_REPEAT_CURRENT: { pplayer->klass->stop(pplayer); //pplayer->klass->set_media_location(pplayer, opt->current->name, &drm_format); pplayer->klass->play(pplayer); break; } default: { break; } } return FSL_PLAYER_SUCCESS; }