Please do not post the same thing multiple times. The board software automatically flags certain posts as needing moderator attention. This happens the most often for new users. I'm pretty sure this is made clear at the time you attempt to post. Posting the same thing over and over again just makes that many more posts the moderators have to weed through later. This makes us sad. Don't make us sad. If your post/thread doesn't appear, just wait a while. Don't post it again. If it hasn't shown up by the next day, then you can try again. I normally go through posts in the mornings, and try to check a few times throughout the day, but I'm not here 24/7. There will typically be a significant delay before posts are approved. Just be patient.
Hello everyone. I have recently made an app, but whenever I play more than one video using the Mediaplayer framework, it crashes on the device, it is fine in the simulator, but when I test it on a provisioned device, it crashes. I received no help in multiple online forums, so I am willing to pay for help. If you are interested, or have any questions, feel free to contact me at alanr917@hotmail.com, please only contact if you believe you can help. I would like this done before Thursday, 9/20/12. And please have a reasonable price, Thank you for your time.
try using the memory leak tool you are probably not releasing properly something.
usually when something works on the simulator and crashes on the device is a memory leak or a not initialized boolean/var
for example if you are using a boolean to know if the instance of the object you are using is dynamically allocated and you can access it and at the beginning you didn't initialize it correctly it would work on the simulator and crash on the device because they are initialized differently by the 2 compilers and in one case it can access the memory and on the other case it cannot.
I don't know exactly what you are trying to do.. but note that in your code when you say
you are not releasing the allocated memory you just point your biaPlayer16 pointer to nothing the memory is still dynamically allocated. you should release it. I think something like:
biaPlayer16.player.currentItem.release; or
[biaPlayer16 release];
and then you point your biaPlayer16 to nill. that way you don't create loose pointers or memory junk.
you don't expect an iphone to be able to hold 16 or more videos in its memory and just view them randomly do you? I did a project the other day using multiple videos blended together.. and I wrote the program in c++ for a pc. it barely could handle 20 videos allocated into the memory the same time..
If you are loading 20 videos in memory (depending on size) that could cause your device to run out of memory. Have you implemeted applicationDidReceiveMemoryWarning:
the profile memory leak tool can help you find in which part of the code the leak occurs. note that sometimes if you are leaking an insane amount it doesn't show anything. for now just try uncomment the:
biaPlayer16 = nil;
note that when you hide the video: [biaPlayer16.view removeFromSuperview]; and then you say = nill in a sense you are 'removing' it as it plays.
try stop the video, unload it and then pass the nill to the pointer.
Should i profile the app when it is on the simulator and doesnt crash, or when it is on the device? I tried it on the device and it didnt show any leaks
It's best to profile on the device when possible. If you don't see any leaks but still are getting memory warnings, it's probably a leak in C code somewhere. I think the leaks tool can only detect leaks of Objective-C objects, but will not find leaks in stuff like Core Foundation code or other C based frameworks.
True but not 100% accurate, I write a lot of my code in C and objC++ and the tool rarely misses a leak, it's not very specific as it is with the objective c code but it tells you when something goes wrong.. but I don't think Alan writes anything in C for this project anyways.
unfortunately without seeing the full code I can't really tell you anything more.
my guess is that you assign a pointer to nill while it plays a file (before finishing). or when you are switching between objects you are trying to access things that are not allocated properly and that is why it crashes,
it's a mystery though why it doesn't crash on the simulator, my guess is that the videoplayer object does things differently on the actual device.
I downloaded the project *(i have a very slow Internet connection)
my man Alan, are you making an 130mb iphone app? what kind of monster computer do you have anyways? i-mac T-1000? I have snow leopard on my lap-top, I had to tweak the project to make it compile..
So first of all as I've noticed this is not a universal app. it is an iphone app. right?
Yet your videos are all HD. and uncompressed. Iphone resolution is 480x320x@2retina. your videos are 1080p ::humongous videos.
you should compress all your videos to the right format and resolution. I don't own an iphone 4s but I am quite sure it cannot handle 1080p videos.
furthermore, most of your videos are just one image and audio.
you should recreate that video. load. the image and audio separately. don't use a video object unless it is ABSOLUTELY NECESSARY to show a video.
forget this project. start from scratch.
convert all the videos that doesn't show moving image to picture with mp3
in my opinion.. you should actually even upload your remaining actual videos on the Internet and stream them through your app.
I ll try have a look at the actual code sometime tomorrow.
Since you register as an observer to the notification center, you have to unregister as well. If not the notification center will try to send a message to the object that was already destroyed and crash your app. I didn't see you unregistering in your code.
as far as the done button - from the docs:
"The Done button pauses playback and causes the movie player to exit fullscreen mode. To detect this scenario, register for other notifications such as MPMoviePlayerDidExitFullscreenNotification."
I didn't see a method that listens to this notification.
Under ARC you don't need to set your ivars to nil. I see you do this in moviePlayBackDidFinish
technically it should be 640x1136 because of the retina, but that wouldn't help you a lot, I do mine 640x360.. but an additional problem in you case is that the pictures in them are in very weird sizes.. squares.. that would made them look horrid. That is why I suggested converting everything into mp3s. and playing the audio while keeping a good picture quality that would've helped dramatically. The other problem is ....if you are going to make this a universal app!! you are going to more or less need the quality you have now..
this app is only going to be deployed on 14 iPods, not on the app store, if i converted them to mp3, would I still be able to use the media player framework?
Well if it's only for 14 ipods then it's ok and your video resolution should be: 640x960; - (the resolution of old ipods) the format can be either mp4 or mov it really doesn't matter one bit.
My main concern was the downloading thing from the app store! (if the devices can handle the videos)
The media player can play mp3s, but you really shouldn't use it because it's going to open a black screen anyways. unless you program it to do otherwise.
..it's not that difficult to replace the players with something like the AVAudioPlayer.
That would make your app way more responsive and fast...
okay, I plan to do that in the future, but will this work if I use the mediaplayer framework: I added a moviePlayerWillExitFullScreen, and something to call it:
// // TurnerViewController.m // LYWAM Tour // // Created by Alan Raff on 9/13/12. // //
Replies
usually when something works on the simulator and crashes on the device is a memory leak or a not initialized boolean/var
for example if you are using a boolean to know if the instance of the object you are using is dynamically allocated and you can access it and at the beginning you didn't initialize it correctly it would work on the simulator and crash on the device because they are initialized differently by the 2 compilers and in one case it can access the memory and on the other case it cannot.
I don't know exactly what you are trying to do..
but note that in your code when you say
-(void) moviePlayBackDidFinish:(NSNotification *)aNotification{
[biaPlayer16.view removeFromSuperview];
biaPlayer16 = nil;
}
you are not releasing the allocated memory you just point your biaPlayer16 pointer to nothing the memory is still dynamically allocated. you should release it. I think something like:
biaPlayer16.player.currentItem.release;
or
[biaPlayer16 release];
and then you point your biaPlayer16 to nill. that way you don't create loose pointers or memory junk.
you don't expect an iphone to be able to hold 16 or more videos in its memory and just view them randomly do you? I did a project the other day using multiple videos blended together.. and I wrote the program in c++ for a pc. it barely could handle 20 videos allocated into the memory the same time..
- Spam
- Abuse
- Troll
0 · Off Topic Insightful Disagree Dislike Like Awesome- Spam
- Abuse
- Troll
0 · Off Topic Insightful Disagree Dislike Like AwesomeapplicationDidReceiveMemoryWarning:- Spam
- Abuse
- Troll
0 · Off Topic Insightful Disagree Dislike Like Awesome- Spam
- Abuse
- Troll
0 · Off Topic Insightful Disagree Dislike Like Awesome- Spam
- Abuse
- Troll
0 · Off Topic Insightful Disagree Dislike Like Awesome- Spam
- Abuse
- Troll
0 · Off Topic Insightful Disagree Dislike Like Awesomefor now just try uncomment the:
biaPlayer16 = nil;
note that when you hide the video: [biaPlayer16.view removeFromSuperview]; and then you say = nill in a sense you are 'removing' it as it plays.
try stop the video, unload it and then pass the nill to the pointer.
- Spam
- Abuse
- Troll
0 · Off Topic Insightful Disagree Dislike Like Awesome- Spam
- Abuse
- Troll
0 · Off Topic Insightful Disagree Dislike Like Awesome- Spam
- Abuse
- Troll
0 · Off Topic Insightful Disagree Dislike Like Awesomeunfortunately without seeing the full code I can't really tell you anything more.
my guess is that you assign a pointer to nill while it plays a file (before finishing).
or when you are switching between objects you are trying to access things that are not allocated properly and that is why it crashes,
it's a mystery though why it doesn't crash on the simulator, my guess is that the videoplayer object does things differently on the actual device.
either that or is a blunt memory leak.
- Spam
- Abuse
- Troll
0 · Off Topic Insightful Disagree Dislike Like Awesome- Spam
- Abuse
- Troll
0 · Off Topic Insightful Disagree Dislike Like Awesome- Spam
- Abuse
- Troll
0 · Off Topic Insightful Disagree Dislike Like Awesome- Spam
- Abuse
- Troll
0 · Off Topic Insightful Disagree Dislike Like Awesome- Spam
- Abuse
- Troll
0 · Off Topic Insightful Disagree Dislike Like Awesome- Spam
- Abuse
- Troll
0 · Off Topic Insightful Disagree Dislike Like Awesomemy man Alan, are you making an 130mb iphone app?
what kind of monster computer do you have anyways? i-mac T-1000?
I have snow leopard on my lap-top, I had to tweak the project to make it compile..
So first of all as I've noticed this is not a universal app. it is an iphone app. right?
Yet your videos are all HD. and uncompressed. Iphone resolution is 480x320x@2retina. your videos are 1080p
::humongous videos.
you should compress all your videos to the right format and resolution. I don't own an iphone 4s but I am quite sure it cannot handle 1080p videos.
furthermore, most of your videos are just one image and audio.
you should recreate that video. load. the image and audio separately. don't use a video object unless it is ABSOLUTELY NECESSARY to show a video.
forget this project.
start from scratch.
convert all the videos that doesn't show moving image to picture with mp3
in my opinion.. you should actually even upload your remaining actual videos on the Internet and stream them through your app.
I ll try have a look at the actual code sometime tomorrow.
- Spam
- Abuse
- Troll
0 · Off Topic Insightful Disagree Dislike Like Awesomeas far as the done button - from the docs:
"The Done button pauses playback and causes the movie player to exit fullscreen mode. To detect this scenario, register for other notifications such as MPMoviePlayerDidExitFullscreenNotification."
I didn't see a method that listens to this notification.
Under ARC you don't need to set your ivars to nil. I see you do this in moviePlayBackDidFinish
- Spam
- Abuse
- Troll
1 · Off Topic Insightful Disagree Dislike 1Like Awesome- Spam
- Abuse
- Troll
0 · Off Topic Insightful Disagree Dislike Like Awesome- Spam
- Abuse
- Troll
0 · Off Topic Insightful Disagree Dislike Like Awesome- Spam
- Abuse
- Troll
0 · Off Topic Insightful Disagree Dislike Like AwesomeThe other problem is ....if you are going to make this a universal app!! you are going to more or less need the quality you have now..
:| ...tough choice.
let me know how it goes
- Spam
- Abuse
- Troll
0 · Off Topic Insightful Disagree Dislike Like Awesome- Spam
- Abuse
- Troll
0 · Off Topic Insightful Disagree Dislike Like AwesomeWell if it's only for 14 ipods then it's ok and your video resolution should be:
640x960; - (the resolution of old ipods) the format can be either mp4 or mov it really doesn't matter one bit.
My main concern was the downloading thing from the app store!
(if the devices can handle the videos)
The media player can play mp3s, but you really shouldn't use it because it's going to open a black screen anyways. unless you program it to do otherwise.
..it's not that difficult to replace the players with something like the AVAudioPlayer.
That would make your app way more responsive and fast...
- Spam
- Abuse
- Troll
0 · Off Topic Insightful Disagree Dislike Like Awesome- Spam
- Abuse
- Troll
0 · Off Topic Insightful Disagree Dislike Like Awesome- Spam
- Abuse
- Troll
0 · Off Topic Insightful Disagree Dislike Like Awesome