iOS
AVPlayer और AVPlayerViewController
खोज…
टिप्पणियों
आयात AVKit, AVFoundation आयात करें।
AVPlayerViewController का उपयोग कर मीडिया चला रहा है
उद्देश्य सी
NSURL *url = [[NSURL alloc] initWithString:@"YOUR URL"]; // url can be remote or local
AVPlayer *player = [AVPlayer playerWithURL:url];
// create a player view controller
AVPlayerViewController *controller = [[AVPlayerViewController alloc] init];
[self presentViewController:controller animated:YES completion:nil];
controller.player = player;
[player play];
तीव्र
let player = AVPlayer(URL: url) // url can be remote or local
let playerViewController = AVPlayerViewController()
// creating a player view controller
playerViewController.player = player
self.presentViewController(playerViewController, animated: true) {
playerViewController.player!.play()
}
AVPlayer और AVPlayerLayer का उपयोग करके मीडिया चला रहा है
उद्देश्य सी
NSURL *url = [NSURL URLWithString:@"YOUR URL"];
AVPlayer *player = [AVPlayer playerWithURL:videoURL];
AVPlayerLayer *playerLayer = [AVPlayerLayer playerLayerWithPlayer:player];
playerLayer.frame = self.view.bounds;
[self.view.layer addSublayer:playerLayer];
[player play];
तीव्र
let url = NSURL(string: "YOUR URL")
let player = AVPlayer(URL: videoURL!)
let playerLayer = AVPlayerLayer(player: player)
playerLayer.frame = self.view.bounds
self.view.layer.addSublayer(playerLayer)
player.play()
AVPlayer उदाहरण
AVPlayer * avPlayer = [AVPlayer playerWithURL: [NSURL URLWithString: @ "आपका URL"]];
AVPlayerViewController *avPlayerCtrl = [[AVPlayerViewController alloc] init];
avPlayerCtrl.view.frame = self.view.frame;
avPlayerCtrl.player = avPlayer;
avPlayerCtrl.delegate = self;
[avPlayer play];
[self presentViewController:avPlayerCtrl animated:YES completion:nil
Modified text is an extract of the original Stack Overflow Documentation
के तहत लाइसेंस प्राप्त है CC BY-SA 3.0
से संबद्ध नहीं है Stack Overflow