4

I'm building an Android/iOS (using Angular/Ionic/Cordova under the hood) app where I'd like any user to be able to record a video and:

  • Either livestream or upload (after filming) the video to my app's private/official YouTube channel
  • All videos on this channel would preferably be private/not viewable to anyone other than "my app"
  • Then, inside of my app, the app backend would be integrated with my YouTube channel (via YouTube API) and would be allow users to search for and view my private videos from inside my app

So basically I'm trying to allow my app's backend to offer private video hosting/viewing but without having to solve video hosting myself, and to use YouTube as the video store instead.

My requirement for the videos to be private/unviewable from outside my app is not a hard requirement, just preferred if at all possible. My app architecture will be the following:

  • Android & iOS app frontends (with embedded YouTube players)
  • Java backend
  • YouTube for video hosting

Things I'm not too concerned about:

  • I know its possible via Android/iOS to access the camera from inside the app, I can figure out how to do this
  • I know its possible via the YouTube API for my Java backend to query YouTube for the correct videos to display and then present them to the end user inside the app/frontends; I can figure out how to do this
  • I know its possible to embed the YouTube player inside an Android/iOS app and to view a YouTube video from inside my app, I can figure out how to do this

But what I'm hung up on is:

How to allow my end users (in my app) to specify livestream vs bulk upload mode (I assume this is a config setting inside the YouTube API client) and then actually upload them to YouTube without exposing the channel's access/credential info to the end user.

I'm actually using Ionic/Cordova under the hood so if there's a library to help manage API integration and livestream/upload of videos that would be great but I didn't see any.

smeeb
  • 27,777
  • 57
  • 250
  • 447
  • you can try using an intermediate proxy approach as mentioned here - https://stackoverflow.com/questions/43954256/hiding-youtube-api-for-client-using-server which takes care of hiding sensitive info. – Gandhi Dec 05 '17 at 07:57

1 Answers1

4

Authentication & Credentials

It would likely make more sense and certainly be more within YouTube's guidelines to rely on your users to have their own YouTube account. With this method you would not need to worry about securing your own account's credentials and as an added bonus you can use Google authentication instead of building your own authentication backend.

Content Management

Instead of uploading all videos to your personal account, you can instead attach all of your user-submitted videos to a playlist and link the videos to your app that way. This would again allow you to utilize your users' credentials instead of your own and would fall inline with the YouTube API's intended use case.

Streaming vs. Bulk Uploading

YouTube already has an API built to handle streaming videos and an API for uploading a saved video. You can give your users either option in your app.

Bonus Round

Here are the Ionic plugins for the Cordova video player and native camera.

Tyler
  • 3,616
  • 3
  • 22
  • 34
  • Thanks so much @makinbacon (+1) - everything you said makes perfect sense (especially the concept of attaching videos to a playlist -- brilliant! Just a few points of clarification: let's say the user is livestreaming something. So in my app there would be something like a "*STREAM NOW!*" button. When they click it, my app would open up the native camera. Here is where my main mental blocker is: isn't the camera its own app?! – smeeb Dec 01 '17 at 10:43
  • If so, how is the video that their camera is recording (from inside the native camera "app") hitting the YouTube API from inside my app (either the Cordova frontend or my Java backend)? – smeeb Dec 01 '17 at 10:43
  • 2
    The camera opens as a modal within your app. It is basically a popup that runs the camera app without leaving your app. You can pass parameters to the camera such as a callback or whether or not to use the flash. It is similar in concept to an html iframe but more tightly integrated. For streaming the video I would recommend using a RTC (real time chat) plugin such as WebRTC. I googled around and found this on StackOverflow that goes into details on how to set up video streaming using Ionic: https://stackoverflow.com/questions/30858180/stream-video-from-phone-camera-using-ionic-framework – Tyler Dec 01 '17 at 15:45
  • Ahh thanks @makinbacon (+1 again), so just so I'm 100% crystal clear: **(1)** Users could enter their own YouTube channel information ahead of time (that would be used by the app for YouTube API integration. Maybe have them set this up in Account Settings & Preferences, etc. Then **(2)** while using the app, they select "*STREAM NOW!*" and the camera opens "inside my app" and I can configure the camera with any type of option (as you say: flash, callbacks, etc.) I wish. – smeeb Dec 02 '17 at 10:01
  • And then **(3)** as part of these options I can have them livestream (callback?) to their YouTube channel, using the channel info they previously saved in "Account Settings & Preferences". Then finally **(4)** my app would then associate this video with a playlist on my official channel? Would I be able to make that playlist association while livestreaming, or do I need to wait for the video to finish streaming (or be bulk uploaded) before I can associate someone else's stream/video with my playlist? – smeeb Dec 02 '17 at 10:02
  • And is this the general flow you're recommending here? If not, can you please clarify + correct me? And also, where/how would WebRTC snap into this flow/pipeline here? Thanks again so much! – smeeb Dec 02 '17 at 10:05
  • Yes, that is the flow I am suggesting. I do not know if the videos can be added to your playlist while they are live-streaming or if you have to add them after the fact, but you can consult the YouTube API documentation. RTC is just a method of transferring the data (video) in real time. You can reference the above-mentioned link for an example app that uses this method. – Tyler Dec 04 '17 at 16:15
  • @smeeb Has your question been answered? If you need further clarification on how RTC protocol can transmit a live video using Ionic, here is a fantastic video walkthrough: https://www.youtube.com/watch?v=U2LOpmCpK-g or you can open a new question specifically for that. – Tyler Dec 05 '17 at 16:55