0

I'm learning android app development.

I have a requirement for a user to be able to browse Youtube from my app, select a video which they can then save a link to within the app (at runtime).

The alternative to achieving this would be browsing youtube videos through the Youtube app, and choosing to 'share' them through my application.

I've looked into the YouTube Data API here: https://developers.google.com/youtube/v3/getting-started

My app is so far self contained - there is no interactivity with other applications, and it does not have a back end server. The database etc is stored on the phones internal local storage.

I only have 3 - 4 days to implement this, and I'm working in isolation. I don't know JSON, but my main concern is that I have no idea how significant an undertaking this is, and whether there are any hurdles that may make it take longer.

I would therefore appreciate it if anyone could advise me on the following:

1) I know this is highly subjective, but does 3-4 days sound sufficient, and are there any things that may hinder that? 2) Out of the two above options, is one easier to implement? 3) Is there an easier way of achieving this? 4) Are there any tutorials out there you would advise I follow?

javapalava
  • 711
  • 1
  • 6
  • 15
  • Anything can be achieved if you work hard enough, 3-4 days is a long time. You can have a look at [this guide](http://stacktips.com/tutorials/android/youtube-android-player-api-example) if you haven't already, it shows how you can implement the `YouTubePlayerView` into your app which looks like it's what you're looking for. Also take a look at [this](http://stackoverflow.com/questions/26458919/integrating-youtube-to-fragment). – px06 Aug 10 '16 at 10:26
  • Thanks so much @px06 - I love your positivity! I've looked at the first tutorial and it's really helpful. I guess the bit I'm not so sure about is the user adding it at runtime - they would just need to insert the URL into a text field right? Is there a way it could work similar to the way selecting an image from your picture gallery works? i.e. the application options, and a user selects a video? – javapalava Aug 10 '16 at 10:31
  • If you do something like [this](https://developers.google.com/youtube/v3/docs/search/list), get the search results and then display them how you'd like; I think you should be able to create your own activity that would display these results and you can also retrieve the links like this. Then you can save them as you want, and in addition the `YouTubePlayerView` will allow you to view the videos as you want. It sounds to me you're doing something like [this](http://itubeandroid.com/) it's not a *legal* app but works exactly the way you want yours to work. – px06 Aug 10 '16 at 10:40
  • I'm trying to create an online scrapbook. It looks like a grid, and the user can just add photos, and text into the grid squares at runtime. It would be great to enable them to also add links to videos, which is what I'm trying to achieve with this. Will have a look at the above - thanks so much. – javapalava Aug 10 '16 at 10:54

2 Answers2

1

Of course the first option would be better (browsing video on your app), however sharing the link from the youtube app is easier... This is how you do it:

Manifest (in an activity tag):

<intent-filter>
    <action android:name="android.intent.action.SEND" />
    <category android:name="android.intent.category.DEFAULT" />
    <data android:mimeType="text/plain" />
</intent-filter>

In your activity:

Bundle extras = getIntent().getExtras();
if(extras!=null) {
    String videoLink = extras.getString(Intent.EXTRA_TEXT);
}

I never tried to use the Youtube API so I can't answer to the other questions but if code hard you might achieve your goal within 3-4 days ! ;-)

I hope it will help!

Omar Aflak
  • 2,918
  • 21
  • 39
  • Thanks @A. Omar! Would this option avoid using the API? And would I need to do anything else? – javapalava Aug 10 '16 at 10:26
  • You're welcome! This method simply gets the link. Once you have the link you can save it in your internal storage. As you described the app here, you don't need anything else, so it could be an alternative (instead of using Youtube API). – Omar Aflak Aug 10 '16 at 10:31
  • Thanks so much. Yeah, I saw that it returned a String. The only downside is that the user would need to select which container to save the video into when it was retrieved by my application. That might involve a bit of an unecessary user step, but it's definitely something to consider as a back up if all else fails! Thank you :) – javapalava Aug 10 '16 at 10:41
  • Sorry @A. Omar ! I just have one more question if that's OK? How do I ensure that when they clicked the 'share' icon on a youtube video, that my app would display as an option? – javapalava Aug 10 '16 at 10:52
  • It is the manifest part in my code above. Isn't your app showing in the share list ? the intent-filter tag must be put between an activity tag (the one that should receive the intent) – Omar Aflak Aug 10 '16 at 10:57
  • I'm just using an emulator. I haven't tried it yet - I was just looking into it to understand how it works :) I will try it now! – javapalava Aug 10 '16 at 10:59
  • Okay let me know if something goes wrong. Also, could you please consider upvoting answers that helped you on the post? ;-) – Omar Aflak Aug 10 '16 at 11:13
0

what kind of videos you are looking for showing in your app.

Youtube API provides set of resources. for getting user playlist videos, home page recommended videos etc.

Short description: 1. Configure youtube API v3 in your project/app 2. Once you configure you need ask user to authenticate/login into google account and while doing so seek permissions for reading youtube data before fetching the data from youtube for first time till you logout. 3. Once permissions are granted, you can call youtube API methods and depending on your response show videos to the user.

Youtube developer page also provides the try option where you can feed the live data and validate the response. Link https://developers.google.com/youtube/v3/docs/activities/list#try-it

3-4 days might not be sufficient if you are in learning phase and it also depends on what data you are looking for.

Here is the reference: https://developers.google.com/youtube/v3/docs/

Here are the samples: https://developers.google.com/youtube/v3/code_samples/

Orion
  • 141
  • 4