iOS Question MediaPLayer initWithContentsOfURL

narek adonts

Well-Known Member
Licensed User
Longtime User
I am loading an audio with NSURL from ipod-library.

I am trying this sub

B4X:
-(AVAudioPlayer*)MPlayer: (NSString*)url
{

NSURL*nURL=[NSURL URLWithString:url];
//NSError *err;
AVAudioPlayer *avAudioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:nURL error:nil] ;
//if( err!=nil )
//{
//  NSLog(@"Error");
//}
//avAudioPlayer.numberOfLoops = -1; //infinite
NSLog(url);
// Play that t


        

[avAudioPlayer prepareToPlay] ;
//[avAudioPlayer play];
//[avAudioPlayer setVolume:0.5];
B4IMediaPlayer*bMP;
bMP.object=avAudioPlayer;
return avAudioPlayer;
}


to set my MediaPlayer with the one that i created but it doesnt play.

I saw on internet that I need to add @property

@property (nonatomic,strong) AVAudioPlayer *avAudioPlayer;


but I dont know how to add a property as it doesnt compile when I add it.
 
Upvote 0
Top