avkit

Subtitles won't display if closed caption is off in system settings

一世执手 提交于 2021-02-20 00:41:29
问题 I am trying to get subtitles to display regardless of what the device has set under the accessibilities. Currently, if the device is set to English with closed captioning enabled in settings, English subtitles will play, and if the device is set to Spanish, Spanish subtitles will play. I would like subtitles to play regardless of whether or not closed captioning is on. I attempted to add this code from apple's documentation, but it did not help. It seems to be reading the options fine,

How to resume audio playing of other apps after dismissing AVPlayerViewController?

放肆的年华 提交于 2021-02-18 18:09:13
问题 I use AVPlayerViewController to play short videos in my app. If there is an app playing audio in background before user plays a video in my app, I want the background audio playing of the other app to resume after my video player is dismissed. I currently use AVAudioSession.setActive(false, with: .notifyOthersOnDeactivation) to do that. Even though Apple's Music app and Podcasts app do resume playing after I call AVAudioSession.setActive(false, with: .notifyOthersOnDeactivation) —won't resume

How to resume audio playing of other apps after dismissing AVPlayerViewController?

馋奶兔 提交于 2021-02-18 18:06:08
问题 I use AVPlayerViewController to play short videos in my app. If there is an app playing audio in background before user plays a video in my app, I want the background audio playing of the other app to resume after my video player is dismissed. I currently use AVAudioSession.setActive(false, with: .notifyOthersOnDeactivation) to do that. Even though Apple's Music app and Podcasts app do resume playing after I call AVAudioSession.setActive(false, with: .notifyOthersOnDeactivation) —won't resume

Can't able to get Video Tracks from AVURLAsset for HLS videos(.m3u8 format) for AVPlayer?

a 夏天 提交于 2021-02-18 17:40:08
问题 I am developing a custom video player to stream HLS videos from server. I can successfully play HLS videos using AVPlayerItem and AVPlayer. After that I want to add subtitle track and audio tracks for my video player. So I used AVMutableComposition to do so. So now the issue is when I am creating AVURLAsset for HLS Videos, I can't able to get video tracks from AVURLAsset. It is giving me always 0 tracks. I tried "loadValuesAsynchronously" of AVURLAsset and I tried adding KVO for "tracks" of

Rotate video 90 degrees in AVPlayerViewController - possible?

落爺英雄遲暮 提交于 2021-01-27 20:58:24
问题 I cannot figure out how to rotate the video 90 degrees in AVPlayerViewController , anyone have any ideas as to how to do this? I'm unsure how to access the AVPlayerLayer as you normally would. 回答1: Try with this code, using AffineTransform we rotate the view but we need also adjust the frame EDITED UIView.animate(withDuration: 0.5) { self.avPlayerViewController?.view.transform = CGAffineTransform(rotationAngle: CGFloat((90 * Double.pi)/180)) self.avPlayerViewController?.view.frame = CGRect(x:

Close AVPlayer when movie is complete

一曲冷凌霜 提交于 2020-05-25 17:23:15
问题 I am making a simple iPad app to play a movie when a button is pressed. The movie plays and when the movie is finished I want to close AVPlayerView so it goes back to the main screen. Currently when the video finishes it stays on the last frame. My ViewController.Swift at the moment. import UIKit import AVKit import AVFoundation class ViewController: UIViewController { //MARK : Properties override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view,

Exporting a mirrored video with AVMutableComposition causes resizing issues

心已入冬 提交于 2020-01-04 06:14:56
问题 Everything works as expected if I turn off the mirroring on the front camera. However, if I turn it on, my final exported video has crucial resizing problems: This is how I currently manage the mirroring for my videos: if currentDevice == frontCamera { if let connection = output.connections.first { if connection.isVideoMirroringSupported { connection.automaticallyAdjustsVideoMirroring = false connection.isVideoMirrored = true //if true, this bug occurs. } } }else { //disabling photo mirroring

AVPlayerViewController doesn't play local videos

家住魔仙堡 提交于 2019-12-31 05:18:47
问题 I have added a DemoVideo.mp4 in my project and added it to copy resource file. But when i run the app it doesn't play my video. Here is my method. private func setUpAndPlayVideo() { guard let videoPath = Bundle.main.path(forResource: "DemoVideo.mp4", ofType: nil) else { return } let videoURL = NSURL(string: videoPath) let player = AVPlayer(url: videoURL! as URL) playerViewController = AVPlayerViewController() playerViewController.player = player playerViewController.view.frame = self

How can I get Camera Calibration Data on iOS? aka AVCameraCalibrationData

a 夏天 提交于 2019-12-31 04:20:25
问题 As I understand it, AVCameraCalibrationData is only available over AVCaptureDepthDataOutput. Is that correct? AVCaptureDepthDataOutput on the other hand is only accessible with iPhone X front cam or iPhone Plus back cam, or am I mistaken? What I am trying to do is to get the FOV of an AVCaptureVideoDataOutput SampleBuffer. Especially, it should match the selected preset (full HD, Photo etc.). 回答1: You can get AVCameraCalibrationData only from depth data output or photo output. However, if all

Playing a live TuneIn Radio URL iOS Swift

喜欢而已 提交于 2019-12-24 08:07:23
问题 I am working on an app which is intended to play life radio by using TuneIn URLs. In TuneIn, there is an http get request in the API which provides a JSON with all the URL and its bitrates. So http://opml.radiotime.com/Tune.ashx?id=s150147&formats=aac,mp3&render=json will return { "head": { "status": "200"}, "body": [ { "element" : "audio", "url": "http://player.absoluteradio.co.uk/tunein.php?i=a664.aac", "reliability": 95, "bitrate": 64, "media_type": "aac", "position": 0, "player_width":