Export to GitHub

android-youtube-player - issue #3

can't play video using OpenYouTubePlayerActivity


Posted on Sep 17, 2011 by Swift Camel

What steps will reproduce the problem? String url = "http://www.youtube.com/watch?v=w5fXOct6rJw";

    Uri uri = Uri.parse(url);
    String vid = uri.getQueryParameter("v"); 

    //Intent lVideoIntent = new Intent(null, Uri.parse(url), this,OpenYouTubePlayerActivity.class);

    Intent lVideoIntent = new Intent(null, Uri.parse("ytpl://"+ vid), this, OpenYouTubePlayerActivity.class);

    startActivity(lVideoIntent);

What is the expected output? What do you see instead? I get Communication Error, also the logs shows

09-17 01:27:02.416: ERROR/QueryYouTubeTask(5870): Error occurred while retrieving information from YouTube. 09-17 01:27:02.416: ERROR/QueryYouTubeTask(5870): java.lang.NullPointerException 09-17 01:27:02.416: ERROR/QueryYouTubeTask(5870): at java.net.URLDecoder.decode(URLDecoder.java:104) 09-17 01:27:02.416: ERROR/QueryYouTubeTask(5870): at java.net.URLDecoder.decode(URLDecoder.java:48) 09-17 01:27:02.416: ERROR/QueryYouTubeTask(5870): at com.keyes.youtube.YouTubeUtility.calculateYouTubeUrl(YouTubeUtility.java:133) 09-17 01:27:02.416: ERROR/QueryYouTubeTask(5870): at com.keyes.youtube.OpenYouTubePlayerActivity$QueryYouTubeTask.doInBackground(OpenYouTubePlayerActivity.java:398) 09-17 01:27:02.416: ERROR/QueryYouTubeTask(5870): at com.keyes.youtube.OpenYouTubePlayerActivity$QueryYouTubeTask.doInBackground(OpenYouTubePlayerActivity.java:1) 09-17 01:27:02.416: ERROR/QueryYouTubeTask(5870): at android.os.AsyncTask$2.call(AsyncTask.java:185) 09-17 01:27:02.416: ERROR/QueryYouTubeTask(5870): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:306) 09-17 01:27:02.416: ERROR/QueryYouTubeTask(5870): at java.util.concurrent.FutureTask.run(FutureTask.java:138) 09-17 01:27:02.416: ERROR/QueryYouTubeTask(5870): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1088) 09-17 01:27:02.416: ERROR/QueryYouTubeTask(5870): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:581) 09-17 01:27:02.416: ERROR/QueryYouTubeTask(5870): at java.lang.Thread.run(Thread.java:1019) 09-17 01:27:02.416: ERROR/QueryYouTubeTask(5870): Error playing video! 09-17 01:27:02.416: ERROR/QueryYouTubeTask(5870): java.lang.RuntimeException: Invalid NULL Url. 09-17 01:27:02.416: ERROR/QueryYouTubeTask(5870): at com.keyes.youtube.OpenYouTubePlayerActivity$QueryYouTubeTask.onPostExecute(OpenYouTubePlayerActivity.java:431) 09-17 01:27:02.416: ERROR/QueryYouTubeTask(5870): at com.keyes.youtube.OpenYouTubePlayerActivity$QueryYouTubeTask.onPostExecute(OpenYouTubePlayerActivity.java:1) 09-17 01:27:02.416: ERROR/QueryYouTubeTask(5870): at android.os.AsyncTask.finish(AsyncTask.java:417) 09-17 01:27:02.416: ERROR/QueryYouTubeTask(5870): at android.os.AsyncTask.access$300(AsyncTask.java:127) 09-17 01:27:02.416: ERROR/QueryYouTubeTask(5870): at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:429) 09-17 01:27:02.416: ERROR/QueryYouTubeTask(5870): at android.os.Handler.dispatchMessage(Handler.java:99) 09-17 01:27:02.416: ERROR/QueryYouTubeTask(5870): at android.os.Looper.loop(Looper.java:123) 09-17 01:27:02.416: ERROR/QueryYouTubeTask(5870): at android.app.ActivityThread.main(ActivityThread.java:3806) 09-17 01:27:02.416: ERROR/QueryYouTubeTask(5870): at java.lang.reflect.Method.invokeNative(Native Method) 09-17 01:27:02.416: ERROR/QueryYouTubeTask(5870): at java.lang.reflect.Method.invoke(Method.java:507) 09-17 01:27:02.416: ERROR/QueryYouTubeTask(5870): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839) 09-17 01:27:02.416: ERROR/QueryYouTubeTask(5870): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597) 09-17 01:27:02.416: ERROR/QueryYouTubeTask(5870): at dalvik.system.NativeStart.main(Native Method)

What version of the product are you using? On what operating system? 2.3.3

Please provide any additional information below.

If i use below code it works

Intent myIntent = new Intent(Intent.ACTION_VIEW, Uri .parse("http://www.youtube.com/watch?v=s8I05iFWkQ0")); startActivity(myIntent);

Comment #1

Posted on Sep 17, 2011 by Swift Camel

I got below error when i tried on emulator,I used below source code String url = "http://www.youtube.com/watch?v=Aqyf2aYR1pQ&feature=featured";

    Uri uri = Uri.parse(url);
    String vid = uri.getQueryParameter("v"); 

Intent lVideoIntent = new Intent(null,Uri.parse("ytv://"+vid), this, IntroVideoActivity.class);

    startActivity(lVideoIntent);

09-17 22:43:04.529: DEBUG/dalvikvm(340): GC_CONCURRENT freed 100K, 69% free 318K/1024K, external 0K/0K, paused 1ms+1ms 09-17 22:43:04.529: DEBUG/jdwp(340): adbd disconnected 09-17 22:43:04.569: INFO/AndroidRuntime(340): NOTE: attach of thread 'Binder Thread #3' failed 09-17 22:43:06.039: INFO/ARMAssembler(66): generated scanline__00000177:03515104_00001002_00000000 [ 87 ipp] (110 ins) at [0x445ed6f0:0x445ed8a8] in 646678 ns 09-17 22:43:06.259: INFO/ActivityManager(66): Starting: Intent { dat=ytv://Aqyf2aYR1pQ cmp=com.markana/com.keyes.youtube.IntroVideoActivity } from pid 348 09-17 22:43:06.880: INFO/ActivityManager(66): Displayed com.markana/com.keyes.youtube.IntroVideoActivity: +575ms (total +2s393ms) 09-17 22:43:09.169: DEBUG/MediaPlayer(348): Couldn't open file on client side, trying server side 09-17 22:43:09.179: INFO/StagefrightPlayer(34): setDataSource('http://www.youtube.com/get_video?video_id=Aqyf2aYR1pQ&t=vjVQa1PpcFMvhUQn_YNtbecfsl_w2vtzxxnZR6xCN6M%3D&fmt=18') 09-17 22:43:09.201: INFO/NuHTTPDataSource(34): connect to www.youtube.com:80/get_video?video_id=Aqyf2aYR1pQ&t=vjVQa1PpcFMvhUQn_YNtbecfsl_w2vtzxxnZR6xCN6M%3D&fmt=18 @0 09-17 22:43:09.459: INFO/AwesomePlayer(34): mConnectingDataSource->connect() returned -1004 09-17 22:43:09.459: ERROR/MediaPlayer(348): error (1, -1004) 09-17 22:43:09.539: ERROR/MediaPlayer(348): Error (1,-1004) 09-17 22:43:09.539: DEBUG/VideoView(348): Error: 1,-1004

Can you guys let me know why media player is throwing -1004? so far no luck playing video with OpenYouTubePlayerActivity

Comment #2

Posted on Nov 4, 2011 by Swift Ox

the original defect was not formatting the url correctly. the openyoutubeplayer expects the url to be of the form ytv://. also, there were errors in the player interacting with the youtube apis that should now be fixed.

Comment #3

Posted on Nov 10, 2011 by Swift Camel

The issue is not fixed, I am still getting the error with new jar, also i made code changes to use ytv

11-10 11:40:43.354: ERROR/QueryYouTubeTask(15812): Error playing video! 11-10 11:40:43.354: ERROR/QueryYouTubeTask(15812): java.lang.RuntimeException: Invalid NULL Url. 11-10 11:40:43.354: ERROR/QueryYouTubeTask(15812): at com.keyes.youtube.OpenYouTubePlayerActivity$QueryYouTubeTask.onPostExecute(OpenYouTubePlayerActivity.java:418) 11-10 11:40:43.354: ERROR/QueryYouTubeTask(15812): at com.keyes.youtube.OpenYouTubePlayerActivity$QueryYouTubeTask.onPostExecute(OpenYouTubePlayerActivity.java:1) 11-10 11:40:43.354: ERROR/QueryYouTubeTask(15812): at android.os.AsyncTask.finish(AsyncTask.java:417) 11-10 11:40:43.354: ERROR/QueryYouTubeTask(15812): at android.os.AsyncTask.access$300(AsyncTask.java:127) 11-10 11:40:43.354: ERROR/QueryYouTubeTask(15812): at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:429) 11-10 11:40:43.354: ERROR/QueryYouTubeTask(15812): at android.os.Handler.dispatchMessage(Handler.java:99) 11-10 11:40:43.354: ERROR/QueryYouTubeTask(15812): at android.os.Looper.loop(Looper.java:130) 11-10 11:40:43.354: ERROR/QueryYouTubeTask(15812): at android.app.ActivityThread.main(ActivityThread.java:3859) 11-10 11:40:43.354: ERROR/QueryYouTubeTask(15812): at java.lang.reflect.Method.invokeNative(Native Method) 11-10 11:40:43.354: ERROR/QueryYouTubeTask(15812): at java.lang.reflect.Method.invoke(Method.java:507) 11-10 11:40:43.354: ERROR/QueryYouTubeTask(15812): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:840) 11-10 11:40:43.354: ERROR/QueryYouTubeTask(15812): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:598) 11-10 11:40:43.354: ERROR/QueryYouTubeTask(15812): at dalvik.system.NativeStart.main(Native Method)

Comment #4

Posted on Nov 15, 2011 by Swift Cat

I am also getting the same error.

11-15 18:22:41.446: ERROR/QueryYouTubeTask(1088): java.lang.RuntimeException: Invalid NULL Url. Not sure, how to fix it, I tried various combination but it fails at the same place saying, "Invalid Url"

Comment #5

Posted on Jan 20, 2012 by Massive Monkey

Same here. The developer says it was fixed on Nov 4, 2011 but no new jar posted to site. The latest one is from Nov 1, 2011 which is before this bug was reported. If this issue is fixed, we need the new jar!

Comment #6

Posted on Jan 20, 2012 by Massive Monkey

By the way, it works when on Wifi. I looked at the source and can't figure out why might be wrong.

Comment #7

Posted on Jan 20, 2012 by Massive Monkey

I patched the source and provided an update that works.

Instructions: 1) Load the jar into your project

2) Add to your manifest file:

3) Call the activity the same way as before:

String url = "http://www.youtube.com/watch?v=yourvideoid"; Uri uri = Uri.parse(url); String videoId = uri.getQueryParameter("v"); Intent videoIntent = new Intent(null, Uri.parse("ytv://" + videoId), this,OpenYouTubePlayerActivity.class); startActivity(videoIntent);

Attachments

Comment #8

Posted on Jan 25, 2012 by Massive Monkey

You can use the regular source if you dont want to use my jar. Attached is the activity I edited (source attached). Just drop the java into your project in place of the original and rebuild.

Attachments

Comment #9

Posted on Jan 30, 2012 by Happy Bird

Issue seems to still occur on Android 2.2 and 2.3

Comment #10

Posted on Mar 5, 2012 by Helpful Panda

i tried running the code but i keep getting the below error:

03-05 13:47:05.590: E/QueryYouTubeTask(9413): Error occurred while retrieving information from YouTube.

Does anyone have a clue about it?

Comment #11

Posted on Mar 7, 2012 by Massive Panda

My test Video url is http://www.youtube.com/watch?v=v_gQHtXsLtU.

and go down into the stack I found @ queryLatestPlaylistVideo() in YouTubeUtility.java, line 62 the lResp is a HTTP 404 NOT FOUND. So the real youtube link must be changed by now.

the url must be change over time. Is there more consitent way of this?

Attachments

Comment #12

Posted on Mar 7, 2012 by Massive Panda

btw the lGetMethod uri string is: http://gdata.youtube.com/feeds/api/playlists/v_gQHtXsLtU?v=2&max-results=50&alt=json

Comment #13

Posted on Mar 7, 2012 by Massive Panda

what's the valid url really???

Comment #14

Posted on Apr 3, 2012 by Helpful Monkey

Have you got a solution for this yet? I am in the same situation

Comment #15

Posted on Apr 24, 2012 by Helpful Rabbit

Can you help me?

Attachments

Comment #16

Posted on Apr 24, 2012 by Helpful Rabbit

This is returned by the server,Every time I can not share the video to the server,I need help.Thank you

Attachments

Comment #17

Posted on Aug 5, 2012 by Happy Horse

is it working any way i have tired several times it didnt work

Comment #18

Posted on Aug 12, 2012 by Quick Elephant

OpenYouTubeActivity-1.2.jar work perfects, make sure the URI, "ytv://", not the "ytpl://"

Comment #19

Posted on Aug 22, 2012 by Massive Bear

got this error: "An error occurred during the retrieval of the video. This could be due to network issues or YouTube protocols. Please try again later."

im using the 1.2 jar file. HELP!!

Comment #20

Posted on Aug 23, 2012 by Grumpy Monkey

Post your code here

Comment #21

Posted on Aug 23, 2012 by Massive Bear

thats my code:

            String url = "http://www.youtube.com/watch?v=IuEPADM2yBI";

             Uri uri = Uri.parse(url);
             String id = uri.getQueryParameter("v");


            Intent lVideoIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("ytv://" + id), YouTube.this,      OpenYouTubePlayerActivity.class);
            startActivity(lVideoIntent);

Comment #22

Posted on Oct 12, 2012 by Swift Rhino

This also not working :( Is this working?

Comment #23

Posted on Oct 12, 2012 by Swift Rhino

It says "Sorry, this video cannot be played"

Comment #24

Posted on Oct 17, 2012 by Happy Kangaroo

Comment deleted

Comment #25

Posted on Oct 17, 2012 by Happy Kangaroo

Resolved this issue by adding Signature to the URL

fix: VideoStream.java (Line: 30) change: mUrl = lArgMap.get("url"); to: mUrl = lArgMap.get("url") + "&signature=" + lArgMap.get("sig");

Comment #26

Posted on Oct 19, 2012 by Happy Bird

i did that but i still get the error 1,403, it says i can't play the video

Comment #27

Posted on Oct 30, 2012 by Helpful Ox

HI, i have a all the embed urls of my you tube http://www.youtube.com/embed/ydk9WBianNw

in my data base how can i play all these videos in my android application using video view,

thanks in advance

Comment #28

Posted on Nov 30, 2012 by Massive Bird

that was not fixed, i still have the same issu with some video

Comment #29

Posted on Jan 7, 2013 by Massive Wombat

Thank for Srikanth. This problem is fixed. Thank again

Comment #30

Posted on Mar 26, 2013 by Happy Monkey

25 - thank you srikanth! that did the trick!

Comment #31

Posted on Mar 29, 2013 by Quick Monkey

Hi,

How can I edit this?

mUrl = lArgMap.get("url") + "&signature=" + lArgMap.get("sig");

when I try to edit it from the eclipse, it can't be edited.

Hope to help me to edit it.

Comment #32

Posted on Jul 12, 2013 by Happy Ox

How can play the mp4 formate videos.i got an error when i try to load the mp4 formate youtube video.please help he some one...

Comment #33

Posted on Jul 30, 2013 by Helpful Wombat

Hi, I don't get how to change VideoStream.java (Line: 30)? How i can even acess this file,i got only the jar without the code?

Thanks

Comment #34

Posted on Oct 11, 2013 by Massive Giraffe

25 srikanth...@gmail.com

Resolved this issue by adding Signature to the URL

fix: VideoStream.java (Line: 30) change: mUrl = lArgMap.get("url"); to: mUrl = lArgMap.get("url") + "&signature=" + lArgMap.get("sig");

Yes, it work perfectly. Thank bro

Comment #35

Posted on Dec 23, 2013 by Grumpy Dog

An error occurred during the retrieval of video. This could be due to network issues or YouTube protocols. Please try again later.

Comment #36

Posted on Jan 27, 2014 by Grumpy Panda

I fixed it using the #25 srikanth…@gmail.com suggestion. I'm attaching a new JAR.

Attachments

Comment #37

Posted on Feb 18, 2014 by Massive Camel

Please do anybody no why the videoview is small. The video aint going full screen

Attachments

Comment #38

Posted on Aug 20, 2014 by Grumpy Giraffe

1.3 works, however, it only works with some videos. I've seen elsewhere that suggested only videos that are explicitly marked as available for mobile will work with this.

Status: Fixed

Labels:
Type-Defect Priority-High