iOS - Video Streaming, Prevent Video from being downloaded or saved locally - ios

Is there any way to play Video Streaming via URL in iOS native App which can not be downloaded or saved locally. I want to let the user watch video but he should not be able to download or save video locally (via 3rd party downloader apps).
Is above case can be possible in MPMoviePlayerController, MPMoviePlayerViewController or WebViewController?
Any suggestion will be appreciated.

It is possible via MPMoviePlayerViewController.
NSURL *url = [NSURL URLWithString:yourLink];
MPMoviePlayerViewController *moviePlayer = [[MPMoviePlayerViewController alloc] initWithContentURL:url];
[self presentMoviePlayerViewControllerAnimated:moviePlayer];

Related

AVPlayer video preview issue iOS 14.0.1

I am trying to play local and remote videos using AVPlayer and AVPlayerViewController but I am facing an issue. The player is playing the audio for video but not showing the preview.
It is working fine on all the iOS versions less than iOS 14.0.1.
Please help me on this issue
Here is the sample code
movieUrl = [NSURL fileURLWithPath:filePath];
AVPlayer *player = [AVPlayer playerWithURL:movieUrl];
theMoviPlayer = [[AVPlayerViewController alloc] init];
theMoviPlayer.player = player;
[self addSubview:theMoviPlayer.view];
theMoviPlayer.view.frame = self.bounds;
[theMoviPlayer.player play];
Look at this image for better understanding
I have found the actual reason of this issue. It seems that for certain non-standard encoding or fps, AVPlayer is not able to play video. I have exported the same video in correct encoding using some tool i.e, QuickTimePayer, and the video is playable now.
This issue is only producing on iOS 14.0.1, may be it is a bug/feature in AVPlayer in this update.
Conclusion:
Always check your video encoding if your video is not playing or you are just hearing only audio without any video frames.

How to play youtube video using MPMoviePlayerController?

I want to play video of youtube url.
I'm using below code but it is not working.
-(void)playVideoFromURL
{
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:#"%s","https://www.youtube.com/embed/96ReVjMAXEE?autoplay=1&vq=small"]];
self.videoController = [[MPMoviePlayerController alloc] initWithContentURL:url];
[self.videoController setControlStyle:MPMovieControlStyleNone];
self.videoController.repeatMode=MPMovieRepeatModeOne;
self.videoController.fullscreen=YES;
self.videoController.scalingMode=MPMovieScalingModeFill;
self.videoController.view.frame=CGRectMake(0,0,self.videoplayview.frame.size.width, self.videoplayview.frame.size.height);
[self.videoplayview addSubview:self.videoController.view];
[self.videoController play];
}
You cannot play a YouTube vidoe URL in MPMoviePlayerController. For this you have to use
youtube-iso-player-helper - But you cannot play private video URL in youtube-iso-player-helper
XCDYoutubeKit - It is against YouTube Terms and Service.
Unfortunately, there's no way to directly play a youtube video with MPMoviePlayerController because youtube does not expose direct links to the video files.
The only way to have a youtube video play inside your own app is to create a UIWebView with the embed tag from Youtube for the movie you want to play as the UIWebView's content. UIWebView will detect that the embedded object is a Youtube link, and the web view's content will be the youtube preview for the video. When your user clicks the preview, the video will be shown in an MPMoviePlayerController.

MKV player in my iOS app

How can I play mkv video into my iOS App?
Can I use MPMoviePlayerController and add to it mkv codecs?
I try to load an mkv from an URL into my MPMoviePlayerController
NSURL *videoStreamURL = [NSURL URLWithString:#"mkvURL"];
mediaPlayer = [[MPMoviePlayerController alloc] initWithContentURL:videoStreamURL];
But a black screen, with nothing in it to play, appears.
The simple answer is no.
You can use FFMPEG to accomplish this using https://github.com/iMoreApps/ffmpeg-avplayer-for-ios

buffer video before playing it on iphone

I'm doing some testing which during I would like to:
- Take a video that is in the app folder
- load that video to memory (buffer it)
- play the bufferd frames from the memory
All made on iPhone
Actually,
I would like to play a video from memory.
(I also want to load the video to memory by frames).
I hope it clear enough.
How can I accomplish this?
Tnx
EDIT:
Maybe I can point my question a little more..
I have a server that streams video via UDP (let's say that for the simuloation I'm using VLC to stream via UDP).
What do I have to do and implement in order to get the UDP stream from VLC and display it on the screen of my I device (of course i'm talking about writing code and not using VLC streamer :-) ).
Hope that's better and that I'll get some answers now.
Tnx
A video has to be buffered only if you receive the video from a server over internet via packets/Streams.
Else you can just play the video using below code:-
NSURL *url = [NSURL URLWithString:[[NSBundle mainBundle] pathForResource:#"yourVideo" ofType:#"yourVideoType" inDirectory:#""]];
MPMoviePlayerController *player = [[MPMoviePlayerController alloc] initWithContentURL:url];
[[player view] setFrame:[self.view bounds]];
[self.view addSubview:[player view]];
[player play];
[player release];
You can implement the notification MPMoviePlayerLoadStateDidChangeNotification, if you are playing the videos after fetching over some data service.(GPRS,2G, Internet.)

MPMoviePlayerController is not responding to device volume controls

I'm working on a game that during the title sequence plays a video in the background using MPMoviePlayerController. I overlay my game controls over this (just a few textured UIButtons).
The video itself has no audio, but I'm playing sounds when I press buttons via OpenAL.
The Audio Session is set to "Ambient" and whenever the MPMoviePlayerController is not around it responds correctly to device's mute button and volume. But as soon as the video starts playing it blares out the sounds with no regard to the mute or volume settings.
Can anyone help me? Is the MPMoviePlayerController interfering with the AudioSession state?
Is there a way to stop this from happening. My movie has no sound in it so it shouldn't need to do that.
The MPMoviePlayerController uses the AVAudioPlayer shared instance. So you can literally set the volume of the MPMoviePlayerController and it will turn down your background music. However, a better way is to tell MPMoviePlayerController to not use the shared instance.
NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:#"intro" ofType:#"m4v"]];
self.player = [[MPMoviePlayerController alloc] initWithContentURL:url];
self.player.movieSourceType = MPMovieSourceTypeFile;
**[self.player setUseApplicationAudioSession:FALSE];**

Resources