0

I want to play video (.mp4 format) in background continuously(on loop). I tried using the MediaPlayer,AVFoundation but i didn't get the desired result.

I used another method after converting mp4 to gif, .gif worked for me but the quality was low. So please help me find the best method to solve my problem.

Umar Farooque
  • 2,049
  • 21
  • 32
niravdesai21
  • 4,818
  • 3
  • 22
  • 33

2 Answers2

0

You can create AVPlayer object in AppDelegate. Then register its "MovieFinished" observer. In that notification, you can restart the video playing.

Hope this helps.

Bharat Nakum
  • 647
  • 6
  • 18
0

For what purpose is this? If you're trying to have a video background for a login screen or something of that sort, its better to stick with lower res GIFs. It will save you memory, infact you can get really high quality GIFs from .mp4 files using photoshop but the resolution and frames will eat up iPhone's memory.

Rakshith G B
  • 816
  • 2
  • 8
  • 24
  • Yes this is behind the login screen, thank you i know your point seems valuable but the problem is project needs a video background, so i need solution for that. – niravdesai21 Aug 08 '15 at 11:30
  • You can try to use a very high resolution GIF with very less number of frames, this way you will have a high quality video with poor frame rate. You can see here how to do it in photoshop: https://www.youtube.com/watch?v=v79czy49kTQ Using a GIF is anyday a better option over a video file. – Rakshith G B Aug 08 '15 at 11:37
  • If you're still keen on using video, check this tread: http://stackoverflow.com/a/5365362/5043609 It has your solution. – Rakshith G B Aug 08 '15 at 11:40
  • Worked perfect but there is a problem i need full screen view and i am getting this currently : http://i62.tinypic.com/bj8t9e.png – niravdesai21 Aug 08 '15 at 11:50
  • You will have to crop your video before you import it photoshop, crop it to the iPhone's resolution. – Rakshith G B Aug 08 '15 at 11:55
  • can you give me some idea how that is done. as this is the video i am using:http://www.shutterstock.com/video/clip-3199027-stock-footage-deer-running-in-glenn-afrric-scotland-slow-motion-p-conformed-to-p.html?src=search/xlK0i9Mx4v4qYxLzSQ4uGA:1:6/3p – niravdesai21 Aug 08 '15 at 12:01
  • You can do it in Final Cut Pro or any other similar video editing tool. – Rakshith G B Aug 08 '15 at 14:24