Skip to content

MillmanY/MMRtmp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MMRtmp

CI Status Version License Platform

RTMP

  • Publish/Play (H264/AAC)
  • Action Message Format (AMF0/AMF3)

Demo

Play

Use RTMPPlayLayer class play rtmp video

  • Play Action

    displayLayer.play(host: "rtmp://184.72.239.149/vod", name: "BigBuckBunny_115k.mov")
    
  • Stop

     displayLayer.stop()
    
  • Seek

    displayLayer.seek(duration: 100)
    
  • Pause / UnPause

    displayLayer.pause()
    displayLayer.unPause()
    
  • Status Check

     displayLayer.playStatus { [unowned self] (status) in
        switch status {
        case .connect:
            self.pauseBtn.isHidden = false
            self.btnPlay.setTitle("Disconnected", for: .normal)
        case .failed(let err):
            print(err)
        case .unknown:
            self.pauseBtn.isHidden = true
        case .disconnected:
            self.btnPlay.setTitle("Play", for: .normal)
        case .pause:
            self.pauseBtn.setTitle("Resume", for: .normal)
        case .playStart:
            self.pauseBtn.setTitle("Pause", for: .normal)
            break
        }
    }
    

Publish

Use RTMPPublishLayer class publish video on server

  • Auth Layer

      publishLayer.authVideoAudio { (rc) in
      	if !rc {
      		let alert = UIAlertController.init(title: "Error", message: "you need auth your microphone and camera", preferredStyle: .alert)
      		let action = UIAlertAction.init(title: "confirm", style: .default, handler: nil)
      			alert.addAction(action)
      	}
      }
    
  • Publish

     publishLayer.publish(host: host, name: name)
    
  • Stop

     publishLayer.publish(host: host, name: name)
    
  • Status Check

     publishLayer.publishStatus { (status) in
         switch status {
         case .unknown, .disconnected:
             self.btnConnect.setTitle("Publish", for: .normal)
         case .connect:
             self.btnConnect.setTitle("Disconnect", for: .normal)
         case .failed(_):
             self.btnConnect.setTitle("Publish", for: .normal)
         case .publishStart:
             break
         }
      }
    
  • VideoFPS

      publishLayer.videoFPS = 30
    
pod 'MMRtmp'

Author

MillmanY, millmanyang@gmail.com

License

MMRtmp is available under the MIT license. See the LICENSE file for more info.

About

Implement RTMP play/publish protocl on swift

Resources

License

Stars

Watchers

Forks

Packages

No packages published