avplayer

Mojave/macOS 10.14.0: [AVPlayerItem duration] is always indefinite

我的梦境 提交于 2021-01-28 02:26:06
问题 I'm trying to read the duration of a locally stored audio file using the following code: #import <Foundation/Foundation.h> #import <CoreMedia/CoreMedia.h> #import <AVFoundation/AVFoundation.h> AVPlayer *player = [AVPlayer playerWithURL: urlForLocalAudioFile]; // busy wait - I know, not elegant, please ignore int timeout = 0; while (([player status] == AVPlayerStatusUnknown || [[player currentItem] status] == AVPlayerItemStatusUnknown) && timeout < 100) { [NSThread sleepForTimeInterval: 0.1];

Getting SwiftUI wrapper of AVPlayer to pause when view disappears

我是研究僧i 提交于 2021-01-28 00:45:09
问题 TL;DR Can't seem to use binding to tell wrapped AVPlayer to stop — why not? The "one weird trick" from Vlad works for me, without state & binding, but why? See Also My question is something like this one but that poster wanted to wrap an AVPlayerViewController and I want to control playback programmatically. This guy also wondered when updateUIView() was called. What happens (Console logs shown below.) With code as shown here, The user taps "Go to Movie" MovieView appears and the vid plays

Swift -AVPlayer' KVO in cell's parent vc causing Xcode to freeze

冷暖自知 提交于 2021-01-27 22:43:56
问题 I have a cell that takes up the entire screen so there is only 1 visible cell at a time. Inside the cell I have an AVPlayer. Inside the cell's parent vc I have a KVO observer that listens to the "timeControlStatus" . When the player stops playing I call a function stopVideo() inside the cell to stop the player and either show a replay button or a play button etc. 3 problems: 1- When the video stops/reaches end if I don't use DispatchQueue inside the KVO the app crashes when the cell's

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:

Swift -AVPlayer' KVO in cell's parent vc causing Xcode to freeze

折月煮酒 提交于 2021-01-27 20:51:02
问题 I have a cell that takes up the entire screen so there is only 1 visible cell at a time. Inside the cell I have an AVPlayer. Inside the cell's parent vc I have a KVO observer that listens to the "timeControlStatus" . When the player stops playing I call a function stopVideo() inside the cell to stop the player and either show a replay button or a play button etc. 3 problems: 1- When the video stops/reaches end if I don't use DispatchQueue inside the KVO the app crashes when the cell's

Cache HLS video while playing with AVAssetDownloadTask

拈花ヽ惹草 提交于 2021-01-27 14:23:09
问题 I am trying cache an HLS stream while I am playing it. I was following the Apple documentation on this (the section Playing Offline Assets): https://developer.apple.com/library/archive/documentation/AudioVideo/Conceptual/MediaPlaybackGuide/Contents/Resources/en.lproj/HTTPLiveStreaming/HTTPLiveStreaming.html#//apple_ref/doc/uid/TP40016757-CH11-SW1 I've implemented the following method - which should make my HLS streams download while playing: func downloadAndPlayAsset(_ asset: AVURLAsset) { //

rtsp:// liveStream with AVPlayer

两盒软妹~` 提交于 2021-01-27 10:33:05
问题 I want to play liveStream on iPhoneDevice with AVPlayer. Also i want to get CVPixelBufferRef from this stream for next usage. I use Apple guide for creating player. Currently with locally stored videoFiles this player works just fine, also when i try to play this AppleSampleStremURL - http://devimages.apple.com/iphone/samples/bipbop/bipbopall.m3u8 - its work sine too. Problems appear when i want to play stream with rtsp:// like this one: rtsp://192.192.168.1:8227/TTLS/Streaming/channels/2

rtsp:// liveStream with AVPlayer

与世无争的帅哥 提交于 2021-01-27 10:31:13
问题 I want to play liveStream on iPhoneDevice with AVPlayer. Also i want to get CVPixelBufferRef from this stream for next usage. I use Apple guide for creating player. Currently with locally stored videoFiles this player works just fine, also when i try to play this AppleSampleStremURL - http://devimages.apple.com/iphone/samples/bipbop/bipbopall.m3u8 - its work sine too. Problems appear when i want to play stream with rtsp:// like this one: rtsp://192.192.168.1:8227/TTLS/Streaming/channels/2

Too many AVPlayers causes Terminated due to memory issue

穿精又带淫゛_ 提交于 2021-01-01 10:00:05
问题 I have a vc that has an AVPlayer inside of it. From that vc I can push on a different vc with another player inside of it and I can keep pushing on more vcs with a player inside them also. After about the 14th vc getting pushed on the app crashes with Terminated due to memory issue . When I look at the memory graph (9th icon in left pane) it's at about 70mb so there isn't an obscene jump in memory. All of my video files are saved to and retrieved from disk and whenever I pop a vc I have a

Too many AVPlayers causes Terminated due to memory issue

孤街醉人 提交于 2021-01-01 09:58:28
问题 I have a vc that has an AVPlayer inside of it. From that vc I can push on a different vc with another player inside of it and I can keep pushing on more vcs with a player inside them also. After about the 14th vc getting pushed on the app crashes with Terminated due to memory issue . When I look at the memory graph (9th icon in left pane) it's at about 70mb so there isn't an obscene jump in memory. All of my video files are saved to and retrieved from disk and whenever I pop a vc I have a