Avplayer wont playing video from url
AVPlayer not playing video when I'm trying to play it from url. But when I try download and play video its playing.What I'm doing wrong ?
self.avAsset = AVAsset(URL: NSURL(string: contentURLString)!)
let item = AVPlayerItem(asset: avAsset)
avPlayer = AVPlayer(playerItem: item)
playerLayer = AVPlayerLayer(player: avPlayer)
playerLayer.frame = self.view.frame
playerLayer.videoGravity = AVLayerVideoGravityResizeAspectFill
cell.videoView.layer.addSublayer(playerLayer)
self.avPlayer.seekToTime(kCMTimeZero)
avPlayer.play()
ios swift video avplayer
|
show 1 more comment
AVPlayer not playing video when I'm trying to play it from url. But when I try download and play video its playing.What I'm doing wrong ?
self.avAsset = AVAsset(URL: NSURL(string: contentURLString)!)
let item = AVPlayerItem(asset: avAsset)
avPlayer = AVPlayer(playerItem: item)
playerLayer = AVPlayerLayer(player: avPlayer)
playerLayer.frame = self.view.frame
playerLayer.videoGravity = AVLayerVideoGravityResizeAspectFill
cell.videoView.layer.addSublayer(playerLayer)
self.avPlayer.seekToTime(kCMTimeZero)
avPlayer.play()
ios swift video avplayer
1
AVPlayer not playing video
Just not playing? Or is there an error message? What are the symptoms?
– ayaio
Jun 2 '16 at 14:01
just not playing video.
– Murat Kaya
Jun 2 '16 at 14:07
is there a black blank screen??
– Harris
Jun 2 '16 at 14:16
2
While playing remote files, you are supposed to make use of KVO to get notified for changes in player status. You should then be able to tell whether the playback has failed or not.
– Xcoder
Jun 2 '16 at 14:31
See this question for more on what Xcoder is talking about stackoverflow.com/questions/5401437/…
– naomimichiko
Jun 2 '16 at 17:13
|
show 1 more comment
AVPlayer not playing video when I'm trying to play it from url. But when I try download and play video its playing.What I'm doing wrong ?
self.avAsset = AVAsset(URL: NSURL(string: contentURLString)!)
let item = AVPlayerItem(asset: avAsset)
avPlayer = AVPlayer(playerItem: item)
playerLayer = AVPlayerLayer(player: avPlayer)
playerLayer.frame = self.view.frame
playerLayer.videoGravity = AVLayerVideoGravityResizeAspectFill
cell.videoView.layer.addSublayer(playerLayer)
self.avPlayer.seekToTime(kCMTimeZero)
avPlayer.play()
ios swift video avplayer
AVPlayer not playing video when I'm trying to play it from url. But when I try download and play video its playing.What I'm doing wrong ?
self.avAsset = AVAsset(URL: NSURL(string: contentURLString)!)
let item = AVPlayerItem(asset: avAsset)
avPlayer = AVPlayer(playerItem: item)
playerLayer = AVPlayerLayer(player: avPlayer)
playerLayer.frame = self.view.frame
playerLayer.videoGravity = AVLayerVideoGravityResizeAspectFill
cell.videoView.layer.addSublayer(playerLayer)
self.avPlayer.seekToTime(kCMTimeZero)
avPlayer.play()
ios swift video avplayer
ios swift video avplayer
asked Jun 2 '16 at 13:59
Murat KayaMurat Kaya
4571541
4571541
1
AVPlayer not playing video
Just not playing? Or is there an error message? What are the symptoms?
– ayaio
Jun 2 '16 at 14:01
just not playing video.
– Murat Kaya
Jun 2 '16 at 14:07
is there a black blank screen??
– Harris
Jun 2 '16 at 14:16
2
While playing remote files, you are supposed to make use of KVO to get notified for changes in player status. You should then be able to tell whether the playback has failed or not.
– Xcoder
Jun 2 '16 at 14:31
See this question for more on what Xcoder is talking about stackoverflow.com/questions/5401437/…
– naomimichiko
Jun 2 '16 at 17:13
|
show 1 more comment
1
AVPlayer not playing video
Just not playing? Or is there an error message? What are the symptoms?
– ayaio
Jun 2 '16 at 14:01
just not playing video.
– Murat Kaya
Jun 2 '16 at 14:07
is there a black blank screen??
– Harris
Jun 2 '16 at 14:16
2
While playing remote files, you are supposed to make use of KVO to get notified for changes in player status. You should then be able to tell whether the playback has failed or not.
– Xcoder
Jun 2 '16 at 14:31
See this question for more on what Xcoder is talking about stackoverflow.com/questions/5401437/…
– naomimichiko
Jun 2 '16 at 17:13
1
1
AVPlayer not playing video
Just not playing? Or is there an error message? What are the symptoms?– ayaio
Jun 2 '16 at 14:01
AVPlayer not playing video
Just not playing? Or is there an error message? What are the symptoms?– ayaio
Jun 2 '16 at 14:01
just not playing video.
– Murat Kaya
Jun 2 '16 at 14:07
just not playing video.
– Murat Kaya
Jun 2 '16 at 14:07
is there a black blank screen??
– Harris
Jun 2 '16 at 14:16
is there a black blank screen??
– Harris
Jun 2 '16 at 14:16
2
2
While playing remote files, you are supposed to make use of KVO to get notified for changes in player status. You should then be able to tell whether the playback has failed or not.
– Xcoder
Jun 2 '16 at 14:31
While playing remote files, you are supposed to make use of KVO to get notified for changes in player status. You should then be able to tell whether the playback has failed or not.
– Xcoder
Jun 2 '16 at 14:31
See this question for more on what Xcoder is talking about stackoverflow.com/questions/5401437/…
– naomimichiko
Jun 2 '16 at 17:13
See this question for more on what Xcoder is talking about stackoverflow.com/questions/5401437/…
– naomimichiko
Jun 2 '16 at 17:13
|
show 1 more comment
4 Answers
4
active
oldest
votes
Swift 3.0 Translation of Objective-C Answer
let videoURL: URL = URL(string: contentURLString)!
let playerViewController = AVPlayerViewController()
self.playerController = playerViewController
self.playerController.player = AVPlayer(url: videoURL)
self.present(self.playerController, animated: true) {
self.playerController.player?.play()
}
add a comment |
For using AVPlayer with remote file, create a sample project and add the following lines in the viewDidLoad() of the ViewController.
NSURL *videoURL = [NSURL URLWithString:contentURLString];
//Use AVPlayerViewController to use default Apple Controls
AVPlayerViewController *playerViewController = [AVPlayerViewController new];
self.playerController = playerViewController;
self.playerController.player = [AVPlayer playerWithURL:videoURL];
[self presentViewController:self.playerController animated:YES completion:^{
//Start Playback
[self.playerController.player play];
}];
The question is tagged "swift", not "objective-c". Please replace your Objective-C example with a Swift example.
– ayaio
Jan 25 '17 at 9:43
add a comment |
AVplayer won't play remote url video unless server support Http Range: parameter. Otherwise show blank black screen
add a comment |
I had the same symptoms, I tried playing a sample video from URL.
However I got an empty Player view, but the video was not playing.
There was no error message when testing on a device, but when testing on simulator I got the following message:
The resource could not be loaded because the App Transport Security policy requires the use of a secure connection.
So the problem was basically the HTTP-Protocol.
Solution A: Use a video source with https.
Solution B: Change the App Transport Security policies in your info-file (as described in this topic)
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f37594060%2favplayer-wont-playing-video-from-url%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
4 Answers
4
active
oldest
votes
4 Answers
4
active
oldest
votes
active
oldest
votes
active
oldest
votes
Swift 3.0 Translation of Objective-C Answer
let videoURL: URL = URL(string: contentURLString)!
let playerViewController = AVPlayerViewController()
self.playerController = playerViewController
self.playerController.player = AVPlayer(url: videoURL)
self.present(self.playerController, animated: true) {
self.playerController.player?.play()
}
add a comment |
Swift 3.0 Translation of Objective-C Answer
let videoURL: URL = URL(string: contentURLString)!
let playerViewController = AVPlayerViewController()
self.playerController = playerViewController
self.playerController.player = AVPlayer(url: videoURL)
self.present(self.playerController, animated: true) {
self.playerController.player?.play()
}
add a comment |
Swift 3.0 Translation of Objective-C Answer
let videoURL: URL = URL(string: contentURLString)!
let playerViewController = AVPlayerViewController()
self.playerController = playerViewController
self.playerController.player = AVPlayer(url: videoURL)
self.present(self.playerController, animated: true) {
self.playerController.player?.play()
}
Swift 3.0 Translation of Objective-C Answer
let videoURL: URL = URL(string: contentURLString)!
let playerViewController = AVPlayerViewController()
self.playerController = playerViewController
self.playerController.player = AVPlayer(url: videoURL)
self.present(self.playerController, animated: true) {
self.playerController.player?.play()
}
answered Jan 27 '17 at 0:04
mitch10emitch10e
417
417
add a comment |
add a comment |
For using AVPlayer with remote file, create a sample project and add the following lines in the viewDidLoad() of the ViewController.
NSURL *videoURL = [NSURL URLWithString:contentURLString];
//Use AVPlayerViewController to use default Apple Controls
AVPlayerViewController *playerViewController = [AVPlayerViewController new];
self.playerController = playerViewController;
self.playerController.player = [AVPlayer playerWithURL:videoURL];
[self presentViewController:self.playerController animated:YES completion:^{
//Start Playback
[self.playerController.player play];
}];
The question is tagged "swift", not "objective-c". Please replace your Objective-C example with a Swift example.
– ayaio
Jan 25 '17 at 9:43
add a comment |
For using AVPlayer with remote file, create a sample project and add the following lines in the viewDidLoad() of the ViewController.
NSURL *videoURL = [NSURL URLWithString:contentURLString];
//Use AVPlayerViewController to use default Apple Controls
AVPlayerViewController *playerViewController = [AVPlayerViewController new];
self.playerController = playerViewController;
self.playerController.player = [AVPlayer playerWithURL:videoURL];
[self presentViewController:self.playerController animated:YES completion:^{
//Start Playback
[self.playerController.player play];
}];
The question is tagged "swift", not "objective-c". Please replace your Objective-C example with a Swift example.
– ayaio
Jan 25 '17 at 9:43
add a comment |
For using AVPlayer with remote file, create a sample project and add the following lines in the viewDidLoad() of the ViewController.
NSURL *videoURL = [NSURL URLWithString:contentURLString];
//Use AVPlayerViewController to use default Apple Controls
AVPlayerViewController *playerViewController = [AVPlayerViewController new];
self.playerController = playerViewController;
self.playerController.player = [AVPlayer playerWithURL:videoURL];
[self presentViewController:self.playerController animated:YES completion:^{
//Start Playback
[self.playerController.player play];
}];
For using AVPlayer with remote file, create a sample project and add the following lines in the viewDidLoad() of the ViewController.
NSURL *videoURL = [NSURL URLWithString:contentURLString];
//Use AVPlayerViewController to use default Apple Controls
AVPlayerViewController *playerViewController = [AVPlayerViewController new];
self.playerController = playerViewController;
self.playerController.player = [AVPlayer playerWithURL:videoURL];
[self presentViewController:self.playerController animated:YES completion:^{
//Start Playback
[self.playerController.player play];
}];
answered Jan 25 '17 at 9:32
Vinay KiniVinay Kini
311
311
The question is tagged "swift", not "objective-c". Please replace your Objective-C example with a Swift example.
– ayaio
Jan 25 '17 at 9:43
add a comment |
The question is tagged "swift", not "objective-c". Please replace your Objective-C example with a Swift example.
– ayaio
Jan 25 '17 at 9:43
The question is tagged "swift", not "objective-c". Please replace your Objective-C example with a Swift example.
– ayaio
Jan 25 '17 at 9:43
The question is tagged "swift", not "objective-c". Please replace your Objective-C example with a Swift example.
– ayaio
Jan 25 '17 at 9:43
add a comment |
AVplayer won't play remote url video unless server support Http Range: parameter. Otherwise show blank black screen
add a comment |
AVplayer won't play remote url video unless server support Http Range: parameter. Otherwise show blank black screen
add a comment |
AVplayer won't play remote url video unless server support Http Range: parameter. Otherwise show blank black screen
AVplayer won't play remote url video unless server support Http Range: parameter. Otherwise show blank black screen
answered Nov 13 '18 at 22:29
Neven GrubisicNeven Grubisic
1
1
add a comment |
add a comment |
I had the same symptoms, I tried playing a sample video from URL.
However I got an empty Player view, but the video was not playing.
There was no error message when testing on a device, but when testing on simulator I got the following message:
The resource could not be loaded because the App Transport Security policy requires the use of a secure connection.
So the problem was basically the HTTP-Protocol.
Solution A: Use a video source with https.
Solution B: Change the App Transport Security policies in your info-file (as described in this topic)
add a comment |
I had the same symptoms, I tried playing a sample video from URL.
However I got an empty Player view, but the video was not playing.
There was no error message when testing on a device, but when testing on simulator I got the following message:
The resource could not be loaded because the App Transport Security policy requires the use of a secure connection.
So the problem was basically the HTTP-Protocol.
Solution A: Use a video source with https.
Solution B: Change the App Transport Security policies in your info-file (as described in this topic)
add a comment |
I had the same symptoms, I tried playing a sample video from URL.
However I got an empty Player view, but the video was not playing.
There was no error message when testing on a device, but when testing on simulator I got the following message:
The resource could not be loaded because the App Transport Security policy requires the use of a secure connection.
So the problem was basically the HTTP-Protocol.
Solution A: Use a video source with https.
Solution B: Change the App Transport Security policies in your info-file (as described in this topic)
I had the same symptoms, I tried playing a sample video from URL.
However I got an empty Player view, but the video was not playing.
There was no error message when testing on a device, but when testing on simulator I got the following message:
The resource could not be loaded because the App Transport Security policy requires the use of a secure connection.
So the problem was basically the HTTP-Protocol.
Solution A: Use a video source with https.
Solution B: Change the App Transport Security policies in your info-file (as described in this topic)
edited Nov 26 '18 at 12:18
Wasif Ali
7051823
7051823
answered Nov 26 '18 at 10:27
x23b5x23b5
364
364
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f37594060%2favplayer-wont-playing-video-from-url%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
AVPlayer not playing video
Just not playing? Or is there an error message? What are the symptoms?– ayaio
Jun 2 '16 at 14:01
just not playing video.
– Murat Kaya
Jun 2 '16 at 14:07
is there a black blank screen??
– Harris
Jun 2 '16 at 14:16
2
While playing remote files, you are supposed to make use of KVO to get notified for changes in player status. You should then be able to tell whether the playback has failed or not.
– Xcoder
Jun 2 '16 at 14:31
See this question for more on what Xcoder is talking about stackoverflow.com/questions/5401437/…
– naomimichiko
Jun 2 '16 at 17:13