Viblast / ios-player-sdk

Viblast Player iOS SDK - native video playback of MPEG-DASH and HLS for live streaming. Extendable with P2P delivery through Viblast PDN.
http://viblast.com/player/
Other
91 stars 17 forks source link

Is it possible to use Viblast with Swift? #7

Closed rpelorosso closed 8 years ago

rpelorosso commented 8 years ago

Hi!

I have a Swift based project and would like to use Viblast, is it possible to use it with Swift?

Thank you!

ivermolaev commented 8 years ago

Prove me if am I wrong but I think you can use Objective-C classes from Swift code?

mitchellporter commented 8 years ago

@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.

rpelorosso commented 8 years ago

Indeed I could! Thank you guys! Creating a bridging header allowed me to use it in Swift. Thanks!

p4vlos commented 6 years ago

@rpelorosso did you manage to do that?

rpelorosso commented 6 years ago

@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.

p4vlos commented 6 years ago

@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 :/

rpelorosso commented 6 years ago

@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:

https://github.com/rpelorosso/ViBlast-Swift-Test

Akila-Arun commented 3 years ago

@rpelorosso I'm getting bitcode error!! how to use VBPlayer.a file??