Triggering video playback on BrightSign media players using Swift and UDP

Recently I designed and developed some iPad apps for a museum exhibit and one of the interesting challenges was figuring out how to trigger videos and slideshows on an LCD screen from the apps. Turns out, doing this is easy if you’re using BrightSign.

In this article, you’ll learn how to send UDP messages from an iOS device to a BrightSign media player using Swift 4. I am assuming you already know how to setup triggers for your BrightSign content, so I will not be covering that.

BrightSign is a digital signage media player that can stream images, video and audio to attached screens. Depending on the model you choose, it can do even more. If you’ve never heard of it, I hope you check it out!

To begin, create a new single view app in Xcode and add SwiftSocket to your project via Cocoapods:

pod 'SwiftSocket'

Add a UITextView and a UIButton to your storyboard and add corresponding outlets for them in your view controller.

Make sure you import SwiftSocket, and then add the following code:

import UIKit
import SwiftSocket

class ViewController: UIViewController {
    @IBOutlet weak var textView: UITextView!
    var client: UDPClient?

    let host = "" //1
    let port = 5000 //2
    override func viewDidLoad() {
        client = UDPClient(address: host, port: Int32(port)) //3
    @IBAction func sendButtonAction() {
        guard let client = client else { return }
        guard let stringToSend = textView.text else { return } //4
        switch client.send(string: stringToSend) {
        case .success:
            print("client sent message to server")
        case .failure(let error):
            print("failed: \(error)")

Here’s what’s happening:

  1. The host IP address is the IP address of the BrightSign player.
  2. The port is usually 5000, but you should double-check the BrightSign player documentation.
  3. In viewDidLoad I initialized the UDPClient with the host and port details, taking care that the port number is converted to Int32
  4. This is the message from the UITextView that you want to broadcast. This can be anything, and totally depends on the triggers you’ve assigned in your BrightSign content. e.g. “play=001” or “playFileName”
  5. In the switch statement I am sending the UDP message to the BrightSign and checking if the message was sent or if an error occurred.

That’s it! Hopefully, you can see how easy it is to control BrightSign content using an iOS device. Let me know if this helped you out.

If you don’t have a BrightSign player handy, you can even test the successful message broadcast using Terminal and the “nc -lvu” command.