Rich notification play video clip - swift

I'm trying to get rich notification and play video on the notification.
I success to show an image and not found swift sample code.
What need to be done to add video clip / mp4 notification support?
which function need to add to the NotificationService class ?
Thanks Yakir

There is no need to add extra code and no need to use AV player also. we can achieve that by initialising UNNotificationAttachment with url which we get after URLSession.shared.downloadTask
URLSession.shared.downloadTask(with: attachmentURL) { url, _ , _ in
let attachment = try UNNotificationAttachment(identifier: "identifier", url: url, options: nil)
content.attachments.append(attachment)
}
While updating the content in NotificationServiceExtension. Notification will load the video if it is video url.
Note: - please make sure video should be small size or as suggested by Apple.

Related

AVPlayer doesn't play video [duplicate]

This question already has answers here:
How to embed a Youtube video into my app?
(7 answers)
Closed 7 years ago.
Okay so I'm looking to play film trailers in my app. The user will press a button, and then it plays the video. I have added the import AVKit and import AVFoundation lines to my file. This is the code I have so far for making the video play:
#IBAction func playTrailerPressed(sender: AnyObject) {
let videoURL = NSURL(string: "https://youtu.be/d88APYIGkjk")
let player = AVPlayer(URL: videoURL!)
let playerViewController = AVPlayerViewController()
playerViewController.player = player
self.presentViewController(playerViewController, animated: true) {
playerViewController.player!.play()
}
}
This seems to launch an AVPlayerViewController, but doesn't play the video from YouTube. Instead, I get the below:
I have tried both the sharing and embedding link from YouTube, but neither work. If I use a link which has the video file name at the end, it plays it fine, for example: "https://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4"- So I know the code works.
Does anyone know if this is possible to use this way with a YouTube video? (I have also tried trailers from IMDb and Apple, but it's the same).
Thanks for your help!
AVPlayer only plays movie files, and YouTube videos aren't directly exposed as movie files at their URL. It looks like the preferred way to handle YouTube videos is to embed a web view into your app. See this page for information from Google on how to do that.

NSURL not locating my video in my project

In my project, I have a video playing silently as a background video as an introduction. However, when I add the video to my project using NSURL I get this error (see screenshot). I have also provided the code below too. Any ideas?
let videoURL: NSURL = NSBundle.mainBundle().URLForResource("Background_2", withExtension: "mp4")!
I had this problem myself. I would suggest using a video encoder (Adobe Media Encoder CC is good). In the media encoder change, the video codec to H.264 and make sure it has a file extension of QuickTime .mov this will ensure Xcode and your application can read your video correctly.
In addition, when you have successfully changed the codec, make sure you add the video to your Bundle Resources!
Good luck!

RevMobAds - Test video ads not loading?

Ive opted towards RevMob since the iAd network isn't accepting new apps and I'm trying to put a video ad after a round of my game is played like this:
func gameOver() {
RevMobAds.session().fullscreen().loadVideo()
RevMobAds.session().fullscreen().showVideo()
let transition = SKTransition.fadeWithDuration(0.5)
let gameScene = GameOver(size: self.size)
self.view!.presentScene(gameScene, transition: transition)
}
My fullscreen and banner ads are working perfectly, but when I end the game to load the video, I get this in the console with no ad being shown:
[RevMob] Ad received: (200) - 56ba71998e700003764c65b9
Is anyone else having this problem? If so, have you fixed it?
We have changed our documentation, please checkout the updated one here.
What I believe is happening is that you are not saving the fullscreen object. You should create a fullscreen object and save it into a variable:
video = RevMobAds.session().fullscreen()
Then you can load a video ad into the fullscreen object: video!.loadVideo()
And then showVideo on the fullscreen object: video!.showVideo()
Note that loadVideo() is an asynchronous call, so you should either call the methods with completion handlers or extend our delegate classes.
Best regards,

uiimagepickercontroller video duration - photo library

Am developing a app which will upload video to the server which is picked form local iphone photo library.
here i want to restrict the user not to upload more than 3min of video..Question is how to get the duration of the video which is picked from local photo library using uiimagepickercontroller.
will it contain any property for that..?
Thanks
I am not sure but did u try imagePickerController.videoMaximumDuration = urDuration;
You can get the size of your videofile.If you want to put check according to the size that is possible or you can get the duration by using mpmovieplayer class but for that you have to get the full video file .I dont think so you want to do this so its gud if you can put a check according to the size.

Iphone http streaming video problem

When our application play new url of http streaming video , mpmovieplayer show previous image of video during loading new video from new url .
In detail , it show last part of previous video then show first part of previous that video again ( all captured image ) then it plays new url http streaming .
We need your advice how to solve this . Thanks in advance .
This is a known bug in the MPMoviePlayerController. You can work around it by adding the following to your MPMoviePlayerPlaybackDidFinishNotification callback:
[myMoviePlayerController stop];
[myMoviePlayerController setInitialPlaybackTime: -1.0];