Live Video

Hi all,

Since the Internet has moved on since the days of local video, does anyone have any idea / plugin / suggestions as to how we might look at RTMP live video streaming?

The same question has been asked on and off for the past 9 years or so, but hopefully now, with a new structure for Solar2D this might be a bit more possible, especially as it’s become more common.

Any ideas anyone? Happy to consider a paid job if anyone thinks it’s something that could be done? :slight_smile:

2 Likes

Oh, just a side note: Live audio too would be useful to others too I’m sure! While that may or may not be useful in games (live chat?), some of us are still building business tools using Solar2D when we probably shouldn’t! :slight_smile:

Are you looking mainly for a video chat solution? I think it would be neat if we got a plugin to do solar-magically do it for us.

Maybe there’s some open source solutions for iOS and Android and we could cook something up

1 Like

There is an opensource program called Jitsi, I don’t know if it can be integrated with iOS and Android code, but through a webview it is possible to insert it for video calls.

2 Likes

Well, not video “chat” as such, more broadcasting to many for a live quiz app.

Webview is an option as @jdsmedeirosbr point out, and I will use that if I had to, I was more curious as to whether in 2020 we should be looking at a more native solution if that was possible. To my knowledge Solar2D only continues to play static video or sound. It would be nice if we could look to something that could view (or even broadcast, I dunno?) live video and sound.

Just my thoughts anyway!

2 Likes

That would be awesome! Is there a way to send a texture to a display object in a native plugin? We could probably do a native plugin which gets video streams from iOS and Android using swift and kotlin, and then just pass it over to Solar as a texture. Then you would just add it as a .fill

1 Like

External textures are made for this sort of thing.

2 Likes

I’ve been toying around with this a bit more (sadly, had to go with webview), but unfortunately autoplay in android at least is starting muted.

It appears the solution natively is to set setMediaPlaybackRequiresUserGesture = false

I could go native, but I’d prefer to avoid it if possible. I’m wondering if @vlads could maybe give us an option for this somewhere? Looking through the forums a few have asked about it previously, and given we’re using video more and more these days, I think it would be a nice addition. :slight_smile:

Unless someone else has any ideas of course?

Oh, it also appears the corresponding permission for iOS is mediaTypesRequiringUserActionForPlayback if anyone is interested: https://developer.apple.com/documentation/webkit/wkwebviewconfiguration/1851524-mediatypesrequiringuseractionfor

This should be fairly easy to do. You think this should be default or an option?

Thanks for getting back to me @vlads !

I did hope it would be a relatively simple change!

At a guess, it’s probably not going to harm to have it as default behaviour (it’s only in there to protect annoying popups I believe). An option is an… option of course :slight_smile:, but then it would need additional documentation and leave more room for error with others, although that’s just my opinion.

Do let me know if you can put it together, as previously mentioned (see inbox), I’m happy to throw some extra cash into the pot to help the project in addition to my sponsorship. It’s so good to see Solar2D moving forward, and I’d like to help ensure it stays that way if I can. :slight_smile:

I may cause you more pain than help here, but I’ve had a little go myself, and came up with the following two changes (Android and iOS), which might work.

Apologies if for some reason either of those aren’t right. I’m relying on Google and my poor understanding of both iOS and Android, but hopefully saves a bit of time if I got things right! :slight_smile:

**** Android *****

platform/android/sdk/src/com/ansca/corona/CoronaWebView.java

Line 61, add new line:
settings.setMediaPlaybackRequires(false);



****** iOS *************

platform/iphone/Rtt_IPhoneWebViewObject.mm

Before Line 118 add 2 new lines:
WKWebViewConfiguration *theConfiguration = [[WKWebViewConfiguration alloc] init];
theConfiguration.mediaTypesRequiringUserActionForPlayback = false;

Replace original line 118:

fWebView = [[WKWebView alloc] initWithFrame:webViewRect];

Becomes:

fWebView = [[WKWebView alloc] initWithFrame:webViewRect configuration:theConfiguration];

So… It appeared way harder than it seem :slight_smile:
Here. Try this release. I changed how webView created so it can get the native properties on iOS.
I added it to android directly, but for iOS, you would have to call this

webView:setNativeProperty( "mediaTypesRequiringUserActionForPlayback", 0 )

Right after the
Try this release: https://github.com/Shchvova/corona/releases/tag/1002

Thanks @vlads works perfectly for Android!

I’ll give iOS a test tomorrow when I’m in the office, unless someone else beats me to it first of course!

I think the setNativeProperty was a good idea! It potentially opens up other options at a later date now I think about it. Thanks again, will let you know once I’ve tried iOS, but certainly no build errors here so far! :slight_smile:

Hey @vlads

I only just got into the office to try a build on iOS however it seems the release has vanished (getting a 404 error). Any ideas?

Thanks!

Yes. I pulled it down. Does this work?
https://github.com/Shchvova/corona/releases/download/untagged-a0770140cc25badf9100/Solar2D-macOS-2020.1002.dmg

Another 404 I’m afraid! :frowning:

https://mega.nz/file/VepkACJI#6oYTWPnHQzzxar17STwqiWmmiLq0iIRt_EIYihcZkEs

Thanks @vlads all installed (if you want to remove the file).

I’ve not done an iOS build for some time, so having to upgrade xCode, etc. I’ve got Solar2D installed (and it seems to run fine), but I’ve ran out of time for today in the office. Will head in tomorrow and let you know it builds / run ok. Thanks for your patience! :slight_smile:

Hey @vlads

I finally managed to get the App built for iOS and tested. All seems to work beautifully!

Thanks once more for all your efforts with this one. Do feel free to merge these changes with the next release, I really do think they could come in useful for one or two others.

Please do send me a PM with your PayPal email address. While I already support you on Github, I’d still like to send you an additional thankyou for your efforts and patience! :slight_smile: