avplayer

How to Encrypt mp3 Files in iOS

拟墨画扇 提交于 2019-12-22 00:59:31
问题 I have an app that downloads MP3 files from our web server and momentarily stores them in an NSData object. This object is then written to a .mp3 file stored to the /Library/Cache folder in the app's sandbox. When it is time to play the file, I load it into an AVPlayerItem like so: NSString *filePath = [[NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) objectAtIndex:0] stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.mp3", trackID]]; NSURL *fileURL =

How to start next a Song or recognized that a song is finished while playing with AVPlayer?

三世轮回 提交于 2019-12-21 22:22:24
问题 How can I start next song immediately with AVPlayer? I have collections of song selected from iPod Library in MPMediaItemCollection . Now how can i use AVPlayer for lists of songs to be played one by one?? 回答1: For answer to your first question, You can use Notification for the same as [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(songFinished:) name:AVPlayerItemDidPlayToEndTimeNotification object:[yourAVPlayer currentItem]]; -(void)songFinished:(NSNotification *

Using Haneke to cache then play MP4 files with AVPlayer

不羁的心 提交于 2019-12-21 20:56:01
问题 I'm looking for some help solving what seems like a simple problem, but I just can't seem to figure it out. I'm using Haneke from Cocoapods to cache MP4 files from URL (on my server) and then play the cached version using AVPlayer. I'm setting up an AVPreviewLayer inside a UICOllectionViewCell and running this code. The issue is that the player won't play the video initially, but it will play it again in the future (after i scroll back to that cell in the uicollectionview) let getUrl = NSURL

Stream Audio with AVPlayer

匆匆过客 提交于 2019-12-21 20:19:37
问题 I'm trying to play audio from a URL using AVPlayer when a row is selected in a table view but it doesn't play. What am I doing wrong? Here is the code: - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { NSString *streamingString = [NSString stringWithFormat:@"%@.json?client_id=fc886d005e29ba78f046e5474e3fdefb", [streamURLArray objectAtIndex:indexPath.row]]; NSURL *streamingURL = [NSURL URLWithString:streamingString]; NSLog(@"%@", streamingURL);

Detecting AVPlayer video start stop events

余生长醉 提交于 2019-12-21 20:13:02
问题 Here is nice simple avplayer piece of code playing a small collection of videos in a queue. My question. I actually want to pause between videos on my queue. Is it possible? I did note that rate fires twice; status fires just once as does notification. import UIKit import AVKit import AVFoundation class ViewController: UIViewController { @IBOutlet weak var VideoView: UIView! var player:AVQueuePlayer = AVQueuePlayer() @IBAction func NextSlide(sender: AnyObject) { player.play() } override func

AVPlayer not finishing when streaming via AirPlay

▼魔方 西西 提交于 2019-12-21 20:00:18
问题 I am observing the following Notification to know when my HLS stream in AVPlayer has been played until the end: [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didPlayToEnd:) name:AVPlayerItemDidPlayToEndTimeNotification object:_player.currentItem]; This works fine when playing inside the app but when I stream via AirPlay, the notification is not sent. On my Apple TV it looks like the video has played up until shortly before the end of the video and then paused. So

defining view frame size for AV Player ViewController in ios

[亡魂溺海] 提交于 2019-12-21 19:52:18
问题 How does one play a video as a background in iOS? I followed this question How to play a local video with Swift?, but AV Player ViewController is a controller and doesn't let me decide where and how big the view containing video is. It always takes some predefined values. 回答1: I've got this working for a project that I've done but not with an AVPlayerViewController - just a plain AVPlayer that I add to a view's layer. I have a collection view but you can just insert the video on a layer

How to add external WebVTT subtitles into HTTP Live Stream on iOS client

大城市里の小女人 提交于 2019-12-21 17:25:17
问题 We have videos encoded via bitmovin.com and provided as HTTP Live Streams (Fairplay HLS), but subtitles although in WebVTT format are exposed separately as direct URLs for the whole file, not individual segments and are not part of the HLS m3u8 playlist. I am looking for the way how an external .vtt file downloaded separately can still be included in the HLS stream and be available as a subtitle in AVPlayer. I know Apple's recommendation is to include segmented VTT subtitles into the HLS

How to get thumbnail image of video from ALAsset in iOS?

烈酒焚心 提交于 2019-12-21 17:13:58
问题 I want to get thumbnail images of every frame from video and then save this images in Mutable Array of images. I want to use this images to play as a animation. NSURL* assetURL = [self.asset valueForProperty:ALAssetPropertyAssetURL]; NSDictionary* assetOptions = nil; AVAsset* myAsset = [[AVURLAsset alloc] initWithURL:assetURL options:assetOptions]; self.imageGenerator = [AVAssetImageGenerator assetImageGeneratorWithAsset:myAsset]; int duration = CMTimeGetSeconds([myAsset duration]); for(int i

Progressive Video Download on iOS

你。 提交于 2019-12-21 12:41:01
问题 I am trying to implement Progressive Downloading of a video in my iOS application that can be played through AVPlayer. I have already implemented a downloader module that can download the files to the iPad. However, I have discovered I cannot play a file that is still being written to So, as far as I can tell, my only solution would be through downloading a list of file 'chunks' and then keep playing through every file as they are ready (ie: downloaded), probably using HLS Searching I have