2

I saw on many applications that they can get the info of current playing youtube video's title, duration etc on there application.

See this response

title: Desiigner- Panda (OFFICIAL SONG) Prod. By: Menace
album: null
artist: Desiigner LOD
duration: 248000
position: 33154
positionTimestamp: 438260822
source: com.google.android.youtube
playing: true
artworkUri: null
supportedActions: 560

May I know how I can get this info on my application ?

mob_web_dev
  • 2,342
  • 1
  • 20
  • 42
  • Check the [YouTube Data API](https://developers.google.com/youtube/v3/) – shiftpsh Jun 27 '18 at 06:40
  • @shiftpsh let me check it – mob_web_dev Jun 27 '18 at 06:48
  • [YouTube Android Player API](https://developers.google.com/youtube/android/player/) exists too – shiftpsh Jun 27 '18 at 06:50
  • @shiftpsh But these api is for doing the youtube functionalities inside our app.My situation is different. I think there is other method without using the api. Please check the response above. It looks like the info gets from media controller . We get the same result when we use NotificationListener class. – mob_web_dev Jun 27 '18 at 07:00
  • Check: https://stackoverflow.com/questions/34389404/android-get-current-song-playing-and-song-changed-events-like-musixmatch – shiftpsh Jun 28 '18 at 03:47
  • @ianhanniballake MediaBrowser is failed to connect with Youtube Music – mob_web_dev Jul 02 '18 at 08:25

2 Answers2

0

Well, if you want to get data for Youtube Videos or play Youtube Videos on your app etc. you can use the YouTube Data API. It's easy to integrate and it's Google's official API for getting video data from youtube. If you want to use the whole Youtube API you can also look at the documentation. You can look at the Github samples for the API. Good Luck!

  • But my requirement is getting info from youtube app to my application – mob_web_dev Jun 27 '18 at 08:59
  • Can you please give an application that can get info from youtube app to itself. It would be super helpful, as I could give you information on how the app works. –  Jun 27 '18 at 10:52
  • Shazam,Musixmatch etc – mob_web_dev Jun 27 '18 at 12:07
  • I hope it is possible by media controller.But I don't know how to get the result – mob_web_dev Jun 27 '18 at 12:08
  • You can use, in my opinion, ContentProviders. Have a look here at the documentation and look if you use this: https://developer.android.com/guide/topics/providers/content-providers; –  Jun 27 '18 at 13:21
  • By the way, if you want to develop an application which searches for music videos and plays them I'll suggest you display a UI where the user searches and you can then use the Youtube API to play it in your app with custom controls. –  Jun 27 '18 at 13:44
  • @user9998656 Sorry, your answers are not relevant to my questions – mob_web_dev Jun 28 '18 at 13:35
0

They get this information via logcat:

enter image description here

Miguel
  • 1,577
  • 2
  • 15
  • 29