Skip to content

lacyrhoades/MotionJpegController

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MotionJpegController

Live stream controller for MJPEG streams

Using the "StreamView"

    let streamView = MotionJpegStreamView()

    streamView.didStartStreaming = {
        self.state = .streaming
    }

    streamView.didStopStreaming = {
        self.state = .stopped
    }


    streamView.streamDidError = {
        self.state = .loading
        self.streamView.stopStream()
        DispatchQueue.main.async {
            self.getStreamURL() { url in
                streamView.startStream(from: url)
            }
        }
    }

    self.getStreamURL() { url in
        streamView.startStream(from: url)
    }

    streamView.stopStream()

Using just the "Controller"

    let motionJpegController = MotionJpegController(withURL: from)

    motionJpegController.newImageData = { imageData in
        DispatchQueue.global().async {
            if let newImage = UIImage(data: imageData as Data) {
                DispatchQueue.main.async {
                    self.imageView.image = newImage
                }
            }
        }
    }
        
    motionJpegController.willRetryLoading = { retryCount in
        // will retry for the n'th time
    }
    
    motionJpegController.didFinishLoading = {
        // now streaming
    }
    
    // start streaming and retry forever
    motionJpegController?.start()

    // stop streaming
    motionJpegController?.stop()

About

Live stream controller for MJPEG streams

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published