Question

I am using this MPMoviePlayerViewController to play .mp3 file from server but not working properly. Here is the code i am using.

NSString *path = @"http://myurl/music.mp3";
MPMoviePlayerViewController *mpviewController = [[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL URLWithString:path]];
mpviewController.moviePlayer.movieSourceType = MPMovieSourceTypeStreaming;  
[self presentModalViewController:mpviewController animated:YES];
[[mpviewController moviePlayer] play];

Audio play for 3 or 5 seconds only then it stops automatically. Cant figure out whats the problem. Your suggestions would be great help.

Thank you.

Was it helpful?

Solution

Solved it by this code :) May it helps someone.

NSString *path = @"http://myurl/mymusic.mp3";
mv = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL URLWithString:path]];
mv.movieSourceType = MPMovieSourceTypeUnknown;
[self.view addSubview:mv.view];
[mv play];

OTHER TIPS

I am using this GIT for audio streaming from my server. it is simple to use repo.

At the time I have imported to my project it didn't have any background playing. I have added that with some simple iOS code.

Maybe you should retain your mpviewController, I make the same misstake.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top