Closed rpelorosso closed 8 years ago
Prove me if am I wrong but I think you can use Objective-C classes from Swift code?
@ivermolaev You can use objective-C classes in Swift just fine. @rpelorosso you need to look into creating a bridging header to properly import and use your objc classes in Swift.
Indeed I could! Thank you guys! Creating a bridging header allowed me to use it in Swift. Thanks!
@rpelorosso did you manage to do that?
@p4vlos It was a long time ago, but as it seems (having a look at old commits) I used a Bridging Header (NameOfProject-Bridging-Header.h
)
//
// Use this file to import your target's public headers that you would like to expose to Swift.
//
#import <AWSCore/AWSCore.h>
#import <AWSCognito/AWSCognito.h>
#import "VBPlayer.h"
#import "VBDisplayLayer.h"
#import "VBPlayer.h"
#import "PlayerView.h
And then I used it like this:
import UIKit
import AVKit
import AVFoundation
import MediaPlayer
class StreamVideoViewController: UIViewController, VBPlayerDelegate{
var player:VBPlayer?
@IBOutlet weak var playerView: PlayerView?
override func viewDidLoad() {
super.viewDidLoad()
// Init loading view
self.player = VBPlayer(CDN: "http://cdn3.viblast.com/streams/dash/vod-bunny/SNE_DASH_CASE3B_SD_REVISED.mpd")
self.player!.setDisplayLayer(self.playerView?.displayLayer())
self.player!.delegate = self;
self.player!.play()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func playerDidEnterStall(player: VBPlayer?) {
print("STALL")
}
func playerDidExitStall(player: VBPlayer?) {
print("EXIT STALL")
}
}
BUT I may be wrong! Please let me know if this worked for you. If not I can have a look at it myself.
@rpelorosso Don't we need to import VBPlayer
in the View Controller?
I don't know why but it doesn't work in any way :/
@p4vlos There's no need to import the library, as the bridging header file takes care of it. The ViBlast classes will be available to any swift file. I've created a small project that uses ViBlast in Swift. You can find it here:
@rpelorosso I'm getting bitcode error!! how to use VBPlayer.a file??
Hi!
I have a Swift based project and would like to use Viblast, is it possible to use it with Swift?
Thank you!