collectionview - Play audio when uicollectionviewcell is clicked in iOS -


i want play mp3 file file when user select collection view custom cell. not playing . here code have written purpose -(void)collectionview:(uicollectionview *)collectionview didselectitematindexpath:(nsindexpath *)indexpath {

    nslog(@"cell selected ");     avaudioplayer * audioplayer;     nsstring *path = [[nsbundle mainbundle] pathforresource:@"bismillah" oftype:@"mp3"];     nsurl *audiourl=[nsurl fileurlwithpath:path];     audioplayer=[[avaudioplayer alloc] initwithcontentsofurl:audiourl error:nil];     //audioplayer.delegate=self;     [audioplayer play];    // cell.backgroundcolor = [uicolor bluecolor]; 

}

once try this, , once check present in bundle resources or not.

nsstring *audio=[[nsbundle mainbundle]pathforresource:@"ranz des vaches" oftype:@"mp3"]; nsurl *url=[[nsurl alloc]initfileurlwithpath:audio]; avplayer = [[avaudioplayer alloc]initwithcontentsofurl:url error:nil]; avplayer.delegate = self; [avplayer preparetoplay]; [avplayer play]; 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -