English 中文(简体)
安伯
原标题:Android Video Upload to Youtube

我正在开发一个显示器,把一张卡片中的录像带上你管,然后把你管录像带回。 然而,我未能成功这样做。

我以行动努力:

public void onUploadClick(View v) {
 Intent uploadIntent = new Intent(Intent.ACTION_SEND);
 // In a real app, video would be captured from camera.
 File f = new File("/sdcard/test.mov");
 uploadIntent.setDataAndType(Uri.fromFile(f), "video/quicktime");
 startActivity(Intent.createChooser(uploadIntent, "Upload"));
}

But, oddly, with this implementation I do not have Youtube as an option for the upload. I have Bluetooth, Mail, Dropbox, Facebook, Flickr, Gmail and Handcent. But not Youtube. Any thoughts on this? Besides, is it possible using this method to have the url of the youtube video after uploaded? How?

I have also tried using Youtube API for Java, and again no success. I added all the libraries needed (gdata-client-1.0.jar, gdata-media-1.0.jar and gdata-youtube-2.0,jar). However, when I run it I get a NoClassDefFoundError for com.google.gdata.client.youtube.YouTubeService, despite having the right libs and imports. Here is the code I am using:

YouTubeService service = new YouTubeService(clientID, developer_key);
VideoEntry newEntry = new VideoEntry();

YouTubeMediaGroup mg = newEntry.getOrCreateMediaGroup();
mg.setTitle(new MediaTitle());
mg.getTitle().setPlainTextContent("My Test Movie");
mg.addCategory(new MediaCategory(YouTubeNamespace.CATEGORY_SCHEME, "Autos"));
mg.setKeywords(new MediaKeywords());
mg.getKeywords().addKeyword("cars");
mg.getKeywords().addKeyword("funny");
mg.setDescription(new MediaDescription());
mg.getDescription().setPlainTextContent("My description");
mg.setPrivate(false);
mg.addCategory(new MediaCategory(YouTubeNamespace.DEVELOPER_TAG_SCHEME, "mydevtag"));
mg.addCategory(new MediaCategory(YouTubeNamespace.DEVELOPER_TAG_SCHEME, "anotherdevtag"));

newEntry.setGeoCoordinates(new GeoRssWhere(37.0,-122.0));
// alternatively, one could specify just a descriptive string
// newEntry.setLocation("Mountain View, CA");

MediaFileSource ms = new MediaFileSource(new File("file.mov"), "video/quicktime");
newEntry.setMediaSource(ms);

String uploadUrl =
  "http://uploads.gdata.youtube.com/feeds/api/users/default/uploads";

VideoEntry createdEntry = service.insert(new URL(uploadUrl), newEntry);

To sum up, my questions are: - What am I doing wrong in both approaches? - Regarding my simple objective of uploading a video to youtube and getting its youtube link after, which method do you recommend? Even if it s neither of those above.

谢谢。

---- Update 04/10 ----

  • After trying with a differente phone I found out that Youtube not showing up as choice to upload the video is my phone s problem (probably due to the ROM). However, even if it does work using intents is not the way to go because I cannot get the URL back and that is essential.
  • After some research it seems that the second method is not possible. The Youtube API for Java does not work in Android.

That being said, I am looking for suggestions on how to upload a video to Youtube in Android. What I really want is to choose a video file, upload it to Youtube and get the youtube URL. Preferably without any interference from the user, who only chooses the file and then the uploading and URL retrieving runs "in the background". Any suggestions? What is the easiest and fastest way to achieve this?

感谢。

问题回答

您可以使用RESTfulube的透镜,并完成可消耗的上载。 守则实例:。 另外,你们是否尝试过行动?

Regarding the first approach: I tried on 3 different phones, all of different brands and different versions of Android and this is how each acted when I clicked share and picked YouTube:

act=android.intent.action.SEND 台风=video/mp4

act=android.intent.action.SEND typ=video/3gpp flg=0x3000000 cmp=com.google.android.apps.uploader/.clients.youtube.YouTubeSettingsActivity

act=android.intent.action.SEND_MULTIPLE 台风=video/* cmp=com.google.android.apps.uploader/.clients.youtem.YouTubeSettingsActative

因此,它希望你回到正确的轨道上来。 我将尝试改变奇迹。 从录像/∗开始,可能只是看它是否发挥作用。

作为一个旁观,奥赫可能会看着诱惑力,但是,如果YouTubeSettingsActative在几天后加以改变,则可能很危险。

Personally, I like the first approach because it integrates nicely with other apps. Like say your users want to use something other than YouTube, they can choose what they want. I m not sure about getting back a URL though.





相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...

热门标签