Giter Club home page Giter Club logo

iosplayersdk's Introduction

Swift Platforms Swift Package Manager

Getting Started

TPStreamsSDK is a versatile iOS native SDK with support for both DRM (FairPlay) and non-DRM content.

Requirements

Before integrating TPStreamsSDK into your iOS application, ensure that your project meets the following requirement:

  • Minimum Deployment Version: iOS 14 or later
  • Swift: Version 5.5 or later

Integration using Swift Package Manager (SPM)

To add TPStreamsSDK to your Xcode project using Swift Package Manager, follow these steps:

  • Select File > Add Packages in Xcode.
  • In the search bar, enter the following URL: https://github.com/testpress/iOSPlayerSDK.
  • Select 'iOSPlayerSDK' from the search results. Click Add package button.

Once the package is added, you can start using TPStreamsSDK in your iOS application.

Initializing TPStreamsSDK

In the application(_:didFinishLaunchingWithOptions:) method in your AppDelegate, call TPStreamsSDK.initialize(withOrgCode:) to initialize the SDK with your organization code.

class AppDelegate: UIResponder, UIApplicationDelegate {
    func application(_ application: UIApplication,didFinishLaunchingWithOptions launchOptions [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
        TPStreamsSDK.initialize(withOrgCode: "YOUR_ORGANIZATION_CODE")
        return true
    }
}

Please note that the above code assumes you are using SwiftUI for your application. If you are using a different app architecture, you may need to adapt the integration steps accordingly.

Playing a Video with TPStreamsSDK

SwiftUI Integration

  1. Instantiate a TPAVPlayer by providing the appropriate assetID and accessToken.
  2. Embed the TPStreamPlayerView in your SwiftUI view.
struct ContentView: View {
	let player = TPAVPlayer(assetID: "YOUR_ASSET_ID", accessToken: "YOUR_ACCESS_TOKEN")

	var body: some View {
		VStack {
			TPStreamPlayerView(player: player)
				.frame(height: 240)
			Spacer()
		}
	}
}

UIKit Integration

  1. Instantiate a TPAVPlayer with the relevant assetID and accessToken.
  2. Create a TPStreamPlayerViewController and assign the previously created TPAVPlayer to the player attribute.
  3. Add the TPStreamPlayerViewController.view to the view hierarchy. This will display the video player within the specified playerContainer view.
class ViewController: UIViewController {
    @IBOutlet weak var playerContainer: UIView!

    var playerViewController: TPStreamPlayerViewController?
    var player: TPAVPlayer?

    override func viewDidLoad() {
        super.viewDidLoad()
        self.setupPlayerView()
        player?.play()
    }

    func setupPlayerView(){
        player = TPAVPlayer(assetID: "YOUR_ASSET_ID", accessToken: "YOUR_ACCESS_TOKEN")
        playerViewController = TPStreamPlayerViewController()
        playerViewController?.player = player

        addChild(playerViewController!)
        playerContainer.addSubview(playerViewController!.view)
        playerViewController!.view.frame = playerContainer.bounds
    }
}

TPAVPlayer is a wrapper class of AVPlayer that provides built-in support for playing our videos without requiring additional effort. It also supports FairPlay streaming for DRM-protected content.

Since TPAVPlayer is a wrapper class of AVPlayer, you can also use the TPAVPlayer with native iOS player to play Streams Videos.

For a practical implementation and usage of TPStreamsSDK, refer to our Sample iOS App.

iosplayersdk's People

Contributors

harinath01 avatar bharathwaaj avatar pruthiviraj27 avatar karthik-0 avatar

Watchers

 avatar Dinesh Kumar avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.