How to create live streaming for multiple social media like Facebook, Youtube using RTMP in iOS - ios

I have done live streaming for a single platform like facebook using LFLivekit. When I am trying for two platforms it's not happening.
Code:
import UIKit
import LFLiveKit
class VideoViewController: UIViewController {
var sessionO: LFLiveSession =
{
let audioConfiguration = LFLiveAudioConfiguration.defaultConfiguration(for: LFLiveAudioQuality.high)
let videoConfiguration = LFLiveVideoConfiguration.defaultConfiguration(for: LFLiveVideoQuality.low3)
let session = LFLiveSession(audioConfiguration: audioConfiguration, videoConfiguration: videoConfiguration)
return session!
}()
override func viewDidLoad() {
super.viewDidLoad()
self.streamUrl = "live-api-s.facebook.com:80/rtmp/"
self.streamName = "17XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
self.sessionO.delegate = self
self.sessionO.preView = self.view
self.sessionO.running = true
}
override func viewDidAppear(_ animated: Bool)
{
super.viewDidAppear(animated)
let stream = LFLiveStreamInfo()
stream.url = "rtmp://\(self.streamUrl!)/LiveApp/\(self.streamName!)"
self.sessionO.startLive(stream)
}
}
Note: If I create one more session and stream also for youtube it is not working.

We need to create separate RTMP connection and create the listener.
fbRtmpStream = RTMPStream(connection: fbRtmpConnection)
ytRtmpStream = RTMPStream(connection: ytRtmpConnection)
self.fbRtmpConnection1.addEventListener(Event.RTMP_STATUS, selector:#selector(self.fbRtmpStatusHandler1(_:)), observer: self)
self.fbRtmpConnection1.connect("rtmp://live-api-s.facebook.com:80/rtmp/")
self.fbStreamName1 = "xxxxxx"
self.ytRtmpConnection.addEventListener(Event.RTMP_STATUS, selector:#selector(self.ytRtmpStatusHandler(_:)), observer: self)
self.ytRtmpConnection.connect("rtmp://a.rtmp.youtube.com/live2/LiveApp/")
self.ytStreamName = "xxxxxxxxx"

This might not be the solution you're looking for source
Multiple server upload main problem is the error handling more complex, for example, the way out of the problem,this has not yet been good how to deal with. source
So! LFLiveKit does not support multiple server

Related

AudioKit 5 Amplitude Envelope no sound

I'm new here and new with music apps (and programming in general).
I'm trying to build a synth app using AudioKit 5 for my final project.
I made an oscillator and tried to add Amplitude Envelope but no sound coming out.
(If I put the oscillator in the output - there is a sound.)
I saw this question in the internet several times in different types but without any solution.
Does anyone know what is the problem?
And if not - do you have other solution for envelope?
The code:
import AudioKit
import SoundpipeAudioKit
import UIKit
class TryingViewController: UIViewController {
var osc = Oscillator(waveform: Table(.sine), frequency: 440, amplitude: 0.8)
var engine = AudioEngine()
override func viewDidLoad() {
super.viewDidLoad()
}
#IBAction func onBtn(_ sender: UIButton) {
let envelope = AmplitudeEnvelope(osc)
envelope.attackDuration = 0.1
envelope.decayDuration = 0.01
envelope.sustainLevel = 0.5
envelope.releaseDuration = 0.3
osc.start()
do {
try engine.start()
} catch {
print(error, "Field")
}
engine.output = envelope
envelope.start()
}
#IBAction func offBtn(_ sender: UIButton) {
osc.stop()
}
}
Edit:
I add this code and it works now, thanks to Aurelius Prochazk!
var isGateOpend = false
.
.
.
if isGateOpend{
envelope.closeGate()
isGateOpend = false
} else {
envelope.openGate()
isGateOpend = true
}
I still have a click, but I will open another question about it if I won't figure it out.
Thanks in advance!
The AmplitudeEnvelope is a "Gated" Node meaning that it responds to openGate and closeGate which should be used instead of start stop since those are at the node level rather than control level.

How to implement Extensible Enterprise Single sign-on in ios13

We all know that Apple introduce Extensible Enterprise Single Sign-on Extension on iOS 13. Here
is the demo video presented by Apple.
There are two types of Extension,
Redirect and
Credential
I want to work with Redirect Extension.
The below code shown in demo video.
class ViewController: UIViewController {
var authController : ASAuthorizationController?
let authProvider = ASAuthorizationSingleSignOnProvider(identityProvider: URL(string: "https://example.com")!)
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
#IBAction func login(_ sender: Any) {
if self.authProvider.canPerformAuthorization {
let request = self.authProvider.createRequest()
request.requestedOperation = ASAuthorization.OpenIDOperation.operationLogin
self.authController = ASAuthorizationController(authorizationRequests: [request])
self.authController?.delegate = self
self.authController?.presentationContextProvider = self
self.authController?.performRequests()
} else {
print("failed to perform authorization")
}
}
}
How can I get the identity provider URL.
So my question is that how to implement Redirect Extension in my app and how to add identity provider url.
Thanks in Advance.

How to Enable Local Storage in Web Application Swift View

I am developing a small app in Swift3 for iOS, I previously developed it for Android where I had a problem that is replicated here. It happens that I have a webview where you have to upload some videos, youtube videos are reproduced without problems (both Android and iOS), the problem arises when you want to play a video for example with JWPlayer, the problem I had in Android Was that the property was not enabled to write to disk and the solution was as follows:
final WebView myBrowser;
myBrowser.getSettings().setDomStorageEnabled(true);
What would be the solution for Swift3?
I found this solution:
var prefs: WebPreferences? = webView.prefereces
prefs?._setLocalStorageDatabasePath("~/Library/Application Support/MyApp")
prefs?.localStorageEnabled = true
But I get an error:
Use of undeclared type WebPreferences
I pay attention to your comments, greetings and many thanks in advance.
I update my question.
import UIKit
import WebKit
class ViewController: UIViewController {
#IBOutlet var webView: WebView!
override func viewDidLoad() {
super.viewDidLoad()
webView.loadUrl( string: "www.google.com")
}
class WebView: WKWebView{
required init?(coder: NSCoder) {
if let _view = UIView(coder: coder){
super.init(frame: _view.frame, configuration: WKWebViewConfiguration())
autoresizingMask = _view.autoresizingMask
}else{
return nil
}
}
func loadUrl(string: String){
if let url = URL(string: string ) {
load(URLRequest(url: url))
}
}
}
}

Twitter Kit not Showing Videos in TimeLine

I seted a UITableViewController as TWTRTimeLineController and it shows tweets and everything but it doesn't recognizes videos. Thats really weird it shows them as only pictures. The code is very simple i don't know if Im forgetting anything.
import UIKit
import TwitterKit
class TimeLineController: TWTRTimelineViewController {
var navController: personalNavController!
override func viewDidLoad() {
super.viewDidLoad()
let client = TWTRAPIClient()
self.dataSource = TWTRSearchTimelineDataSource(searchQuery: "#CamNowAppBeta", APIClient: client)
self.showTweetActions = true
}
func tweetView(tweetView: TWTRTweetView, didTapVideoWithURL videoURL: NSURL){
}
}
TWTRTweetViewDelegate method didTapVideoWithURL must be removed

Cannot load/scroll full pdf in swift WebView.

I am trying to load a pdf using web view using swift. It can load only one page of the pdf, cannot scroll down more than one page. What can i do?
import UIKit
class ViewController: UIViewController,UIWebViewDelegate {
#IBOutlet var webViews: UIWebView!
var path = ""
override func viewDidLoad() {
super.viewDidLoad()
path = NSBundle.mainBundle().pathForResource("ibook", ofType: "pdf")!
let url = NSURL.fileURLWithPath(path)
/*webViews.scalesPageToFit = true
webViews.scrollView.scrollEnabled = true
webViews.userInteractionEnabled = true*/
webViews.delegate = self
self.webViews.loadRequest(NSURLRequest(URL: url!
))
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
func webViewDidStartLoad(webView : UIWebView) {
//UIApplication.sharedApplication().networkActivityIndicatorVisible = true
println("webViewDidStartLoad")
}
func webViewDidFinishLoad(webView : UIWebView) {
//UIApplication.sharedApplication().networkActivityIndicatorVisible = [enter image description here][1]false
webViews.scalesPageToFit = true
webViews.scrollView.scrollEnabled = true
webViews.userInteractionEnabled = true
println("webViewDidFinishLoad")
}
}
I've bumped into the similar problem while trying to display external pdf (not the bundled one), but I suppose you can use the same fix.
In your webViewDidFinishLoad, check if the url is actually a pdf one. Because in my case I know what I'm expecting, I used simple dumb checking. If url links to a pdf, you need to reload the web view to show it correctly and hence be able to scroll.
Here is a bit simplified code in objective C. It should be quite similar in Swift. Try something like this:
- (void)webViewDidFinishLoad:(UIWebView *)webView {
static BOOL isPdfReloaded = NO;
if (!isPdfReloaded && [webView.request.URL.absoluteString containsString:#".pdf"])
{
[webView reload];
isPdfReloaded = YES;
}
else
{
isPdfReloaded = NO;
}
}
The Best solution is to migrate from UIWebView to WkWebView

Resources