logo
down
shadow

Cannot stream video with swift 2 AVPlayerViewController


Cannot stream video with swift 2 AVPlayerViewController

By : Alice O'Leary
Date : November 28 2020, 09:01 AM
I think the issue was by ths following , Ok so I do it the import AVkit method. Go to your target file and go to general. Add AVKit.framework, I make sure it is embedded as well as linked frameworks and libraries. Then I go make a new file and make it of subclass AVPlayerViewController. Then I make sure that AVKit is imported in that class. Next I do the following code and just transition to that view and see the video play each time. Call the function and that should work.
code :
    func playVideo() {

        let myBaseUrl = "http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4"

        guard let url = NSURL(string: myBaseUrl) else {
            print("movie trailer not found")
            return
        }
      player = AVPlayer(URL: url)

      player?.play()

    }


Share : facebook icon twitter icon
How to play video with AVPlayerViewController (AVKit) in Swift

How to play video with AVPlayerViewController (AVKit) in Swift


By : Sazzad Hossain
Date : March 29 2020, 07:55 AM
it should still fix some issue How do you play a video with AV Kit Player View Controller in Swift? , Swift 3.x - 5.x
Necessary: import AVKit, import AVFoundation
code :
let videoURL = URL(string: "https://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4")
let player = AVPlayer(url: videoURL!)
let playerViewController = AVPlayerViewController()
playerViewController.player = player
self.present(playerViewController, animated: true) {
    playerViewController.player!.play()
}
let videoURL = URL(string: "https://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4")
let player = AVPlayer(url: videoURL!)
let playerLayer = AVPlayerLayer(player: player)
playerLayer.frame = self.view.bounds
self.view.layer.addSublayer(playerLayer)
player.play()
NSURL *videoURL = [NSURL URLWithString:@"https://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4"];
AVPlayer *player = [AVPlayer playerWithURL:videoURL];
AVPlayerViewController *playerViewController = [AVPlayerViewController new];
playerViewController.player = player;
[self presentViewController:playerViewController animated:YES completion:^{
  [playerViewController.player play];
}];
NSURL *videoURL = [NSURL URLWithString:@"https://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4"];
AVPlayer *player = [AVPlayer playerWithURL:videoURL];
AVPlayerLayer *playerLayer = [AVPlayerLayer playerLayerWithPlayer:player];
playerLayer.frame = self.view.bounds;
[self.view.layer addSublayer:playerLayer];
[player play];
Pre-Roll Video Ad with AVPlayerViewController

Pre-Roll Video Ad with AVPlayerViewController


By : cordovacoder
Date : March 29 2020, 07:55 AM
it should still fix some issue You need to call preparePrerollAds in your viewDidLoad to download the advertisement before attempting to present it.
code :
[AVPlayerViewController preparePrerollAds];
Play a video from Youtube in a AVPlayerViewController in Swift

Play a video from Youtube in a AVPlayerViewController in Swift


By : gaurav
Date : March 29 2020, 07:55 AM
Hope that helps AVPlayer only plays movie files, and YouTube videos aren't directly exposed as movie files at their URL. It looks like the preferred way to handle YouTube videos is to embed a web view into your app. See this page for information from Google on how to do that.
In swift, how to detect touch while playing video in AVPlayerViewController

In swift, how to detect touch while playing video in AVPlayerViewController


By : Mohammed Salahudeen
Date : March 29 2020, 07:55 AM
it fixes the issue The solution is to create a Base class of AVPlayerViewController and override touches​Began(_:​with:​) method:
Swift 2:
code :
class CustomAVPlayerViewController: AVPlayerViewController {
    override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
        print("touchesBegan")
    }
}
let videoURL = NSURL(string: "https://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4")
let player = AVPlayer(URL: videoURL!)
let playerViewController = CustomAVPlayerViewController()
playerViewController.player = player
self.presentViewController(playerViewController, animated: true) {
    playerViewController.player!.play()
}
class CustomAVPlayerViewController: AVPlayerViewController {
    override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
        print("touchesBegan")
    }
}
let videoURL = URL(string: "https://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4")
let player = AVPlayer(url: videoURL!)
let playerViewController = CustomAVPlayerViewController()
playerViewController.player = player
self.present(playerViewController, animated: true) {
    playerViewController.player!.play()
}
AVPlayerViewController video with swift 2.0 xcode 7 beta 3

AVPlayerViewController video with swift 2.0 xcode 7 beta 3


By : Bgs
Date : March 29 2020, 07:55 AM
will be helpful for those in need "SampleVideo_1080x720_1mb.mp4", ofType:"mp4"
Shouldn't this be ""SampleVideo_1080x720_1mb", ofType:"mp4"
Related Posts Related Posts :
  • Adding Multiple Images to UIPageViewController using Camera
  • Should I ever prefer operators overloading over functions/methods?
  • How to call/get date and time from a website in swift
  • rxswift error handle issue
  • PFFile as UIImageView
  • Sort dictionary keys by value, then by key
  • What's going on with this generic function?
  • How to implement a failable initializer for a class conforming to NSCoding protocol in Swift?
  • Swift: optional or implicit UILabel?
  • Swift: ¨Unrecognized selector sent to instance¨
  • Initialize a dictionary with non-optional empty arrays in Swift
  • Compare Day/Month in Swift Struct
  • swift reflection causes impossible nil value for any
  • Equatable in Swift
  • How to populate an SKShapeNode uniformly
  • Using AWS API Gateway generated SDK for both authenticated and anonymous access
  • Underscored properties in Swift classes?
  • Subclass of UIButton with rounded corners (swift)
  • Google API Maps don't show up on TabBar Application
  • Can't hide status bar in AVPlayerViewController's portrait mode
  • Send JSON Array and store in database using api calls
  • Return one of two possible classes instances
  • What is type of 123_456_789?
  • dispatch queue concurrent not work as except in swift
  • Calculate count of years
  • Swift property observer in protocol extension?
  • Calling function with optional type in Swift
  • in Swift, what does this specific syntax mean?
  • Nil cannot be assigned to type AVCaptureDeviceInput
  • Parse - Query with 'includeKey' not getting objects in proper subclass
  • Best way to set up multiple tableviewcell layouts
  • Swift Bridging Header for Obj-C
  • Swift dictionary with weak reference keys?
  • Commit failed - the repository is locked, XCode 7
  • How to convert Swift Bool? -> String?
  • Swift: Cannot convert value of type 'NSDate' to expected argument type 'NSDateComponents'
  • JSON parsing error in Swift 2.0
  • Varying value inside runAction() not changing
  • Swift - bar button item image / set size and width
  • Radio button UI in Swift
  • NSdate range total removing weekends Swift
  • Why isn't addTarget calling my target's action in an extension
  • How to make a cell hold multiple text labels in ios
  • Setter for dictionary property - OR: get last added item from dictionary
  • Extending Dictionary with constraints
  • Spritekit rotating multiple nodes around center
  • Swift: Trying to implement NSCoding
  • Array of String printing Optional, why?
  • Dynamic attributes (getters/setters) in Swift on data models
  • Setting file attributes in Swift
  • Window visible on all spaces (including other fullscreen apps)
  • How to draw lines on UIImage with swift ?
  • Is it possible use non read-only computed property in extension?
  • How do I save a MKPointAnnotation to Pars?
  • Take a snapshot of current screen with Metal in swift
  • Is there any way to determine sub-protocol conformance for instance conforming to generic protocol in Swift 2 (at runtim
  • Custom physics body adding unwanted extra line
  • Define a Swift protocol which requires a specific type of sequence
  • Swift tvOS in-app purchase doesn't respond
  • Swift calculate incremental average with reduce and
  • shadow
    Privacy Policy - Terms - Contact Us © animezone.co