avplayerlayer

Sync video in AVPlayerLayer and AVPlayerViewController

天大地大妈咪最大 提交于 2019-12-23 19:21:03
问题 I'm working with AVPlayer to show the playing video using a URL in it. There are 2 parts to it: 1. Firstly, I've embedded the AVPlayer to a view's sublayer using AVPlayerLayer , i.e. var player: AVPlayer? func configure() { let urlString = "https://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4" if let url = URL(string: urlString) { self.player = AVPlayer(url: url) let playerLayer = AVPlayerLayer(player: self.player) playerLayer.frame = self.view.bounds self.view.layer.addSublayer(playerLayer)

Saving video with overlay of GIF image

走远了吗. 提交于 2019-12-22 09:37:10
问题 I am working on an application in which I record a video. When recording finished I put a GIF image on it with use of Library. My code for playing video and putting gif image as an overlay self.avPlayer = [AVPlayer playerWithURL:self.urlstring]; self.avPlayer.actionAtItemEnd = AVPlayerActionAtItemEndNone; AVPlayerLayer *videoLayer = [AVPlayerLayer playerLayerWithPlayer:self.avPlayer]; videoLayer.frame = self.preview_view.bounds; videoLayer.videoGravity = AVLayerVideoGravityResizeAspectFill;

Resume AVPlayer video playback after app become active

浪尽此生 提交于 2019-12-20 10:27:06
问题 I write custom player from AVPlayer for video playback. According to Apple docs set the video layer: self.player = [IPLPlayer new]; self.player.playerLayer = (AVPlayerLayer *)self.playerView.layer; Where self.playerView is usual class from those docs: @implementation PlayerView + (Class) layerClass { return [AVPlayerLayer class]; } - (AVPlayer *)player { return [(AVPlayerLayer *)[self layer] player]; } - (void)setPlayer:(AVPlayer *) player { [(AVPlayerLayer *) [self layer] setPlayer:player];

Multiple videos with AVPlayer

假如想象 提交于 2019-12-18 09:56:06
问题 I am developing an iOS app for iPad that needs to play videos in some part of the screen. I have several video files that needs to be played after each other in an order that is not given at compile time. It must looks as if it is just one video playing. It is fine that when going from one video to the next that is some delay where the last or first frame of the two videos are shown, but there should be no flickering or white screens with no content. The videos does not contain audio. It is

AVPlayerLayer Position in UIView Layer

感情迁移 提交于 2019-12-12 13:10:03
问题 I am writing an application using Swift to view surveillance cameras via HLS. I have the basic device list working and I am able to segue to the Live view and display the stream however, I need to move the AVPlayerLayer and I am having trouble figuring this out. Here is my current code: let player = AVPlayer(URL: url!) let playerLayer = AVPlayerLayer(player: player) let view = UIView(frame: CGRectMake(0, 0, screenSize.width, screenSize.height)) self.view.layer.borderWidth = 1 self.view.layer

Using Swift with AVPlayer, how do you add and remove a video via code?

不羁岁月 提交于 2019-12-12 12:50:23
问题 I'm new to Swift and am trying to add a video to the view and then remove it when my "stopScreenSaver" notification is dispatched. All seems to work well except for when I go to remove the video layer (playerLayer.removeFromSuperlayer()). Any guidance would be appreciated. I feel like I'm missing some basic concept here for adding and removing the layer! import UIKit import AVFoundation import QuartzCore import CoreMedia class ViewController: UIViewController { let contentURL = NSBundle

AVPlayerLayer as SCNMaterial not rendered, audio playing fine

╄→гoц情女王★ 提交于 2019-12-12 10:43:30
问题 i'm trying to use a AVPlayerLayer as a SCNMaterial to be assigned to a SCNSphere. Based on: https://developer.apple.com/library/mac/samplecode/SceneKit_Slides_WWDC2013/Listings/Scene_Kit_Session_WWDC_2013_Sources_Slides_ASCSlideMaterialLayer_m.html I create a player, create a player layer and have tried with and without a backgroundLayer to assign as material for my SCNSphere Issue is, I get the same result reported here: SCNMaterialProperty not rendering layer Audio plays, video not rendered

AVPlayer does not show video

非 Y 不嫁゛ 提交于 2019-12-12 01:47:39
问题 I am trying to play a movie at the beginning of my game. I am using AVPlayer to do this. My problem is, when I register a KVO to check the status of my AVPlayer, my game proceeds as usual without waiting for the video to load and finish. As a result, I can only hear the audio from my .mov file and can't see any video (since my game has already started). I would like the video to load and finish before proceeding with the game. Here's the code: @interface RMVideoView : NSView { NSURL*

Add Trick Play feature with AVPlayerViewController in Swift

北城以北 提交于 2019-12-11 10:38:47
问题 I implemented a video player function with AVPlayer in Swift 3. Currently, I can play the video well. I would like to add the feature of " Trick Play " with the speed of 2x,3x,4x . However, I didn't find anything googling. Can anyone help me please? 回答1: Try playerViewController.player!.rate = 2 // 3, 4 etc 来源: https://stackoverflow.com/questions/42973856/add-trick-play-feature-with-avplayerviewcontroller-in-swift

NSKeyValueObservation: Cannot remove an observer for the key path from object because it is not registered as an observer

*爱你&永不变心* 提交于 2019-12-08 14:54:22
问题 I get random crashes (which I can't reproduce on devices I own) in my app with exception: Cannot remove an observer Foundation.NSKeyValueObservation 0xaddress for the key path "readyForDisplay" from AVPlayerLayer 0xaddress because it is not registered as an observer. This happens when I deallocate a UIView which contains AVPlayerLayer. My init: private var playerLayer : AVPlayerLayer { return self.layer as! AVPlayerLayer } init(withURL url : URL) { ... self.asset = AVURLAsset(url: url) self