Mux

The Mux Developer Hub

Welcome to the Mux developer hub. You'll find comprehensive guides and documentation to help you start working with Mux as quickly as possible, as well as support if you get stuck. Let's jump right in!

Get Started

iOS Video Playback

This example requires familiarity with iOS development. See the full Apple Basic Playback Guide for a more in depth walkthrough.

// File: ViewController.swift

import UIKit
import AVFoundation
import AVKit

class ViewController: UIViewController {
    var playerController = AVPlayerViewController()
    var player:AVPlayer?
    
    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
        
        // Replace YOUR_PLAYBACK_ID with your asset's playback ID
        let url = URL(string: "https://stream.mux.com/YOUR_PLAYBACK_ID.m3u8")
        
        if let movieURL = url {
            self.player = AVPlayer(url: movieURL)
            self.playerController.player = self.player
        }
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

    // Create a UI button that calls this action
    @IBAction func PlayVideo(_ sender: Any) {
        self.present(self.playerController, animated: true, completion: {
            self.playerController.player?.play()
        })
    }
}

iOS Video Playback


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.