2012-12-20 63 views
0

我正嘗試使用intent將視頻上傳到youtube。 的方式我有它設置描述here通過intent上傳到youtube

這裏的片段:

ContentValues content = new ContentValues(4); 
content.put(Video.VideoColumns.TITLE, "My Test"); 
content.put(Video.VideoColumns.DATE_ADDED, 
System.currentTimeMillis()/1000); 
content.put(Video.Media.MIME_TYPE, "video/mp4"); 
content.put(MediaStore.Video.Media.DATA, outputFile); 
ContentResolver resolver = getContentResolver(); 
Uri uri = resolver.insert(MediaStore.Video.Media.EXTERNAL_CONTENT_URI, 
content); 

Intent intent = new Intent(Intent.ACTION_SEND); 
intent.setType("video/*"); 
intent.putExtra(Intent.EXTRA_STREAM, uri); 
startActivity(Intent.createChooser(intent, "Share using")); 

我想已經設置標題字段。 否則,如果用戶沒有手動設置標題字段,則上傳的視頻將具有視頻文件名的標題。

+0

請分享解決方案,如果您發現請 – Geethu

回答

0

經過以下幾個環節

http://diablo-urban-o.com/post/9929911420/uploading-videos-to-youtube-from-android-part-ii

,並嘗試下面的代碼了。

ContentValues content = new ContentValues(4); 
content.put(Video.VideoColumns.TITLE, "Test"); 
content.put(Video.VideoColumns.DATE_ADDED, 
System.currentTimeMillis()/1000); 
content.put(Video.Media.MIME_TYPE, "video/mp4"); 
content.put(MediaStore.Video.Media.DATA, "/sdcard/myvideo.mp4"); 
ContentResolver resolver = getContext().getContentResolver(); 
Uri uri = resolver.insert(MediaStore.Video.Media.EXTERNAL_CONTENT_URI, content); 

希望這將幫助你...

+0

您發佈的代碼是我已經使用的相同。你發佈的鏈接是用於手動設置上傳到YouTube的。不需要Youtube應用程序。 我想如果沒有其他方法我想我會嘗試手動方法 – tomi

+0

肯定..讓我搜索其他方式... – itsrajesh4uguys

0

這裏是一個演示application,做想你想要的。使用來設置你想要的標題。

+0

不起作用。看到這裏: http://stackoverflow.com/questions/13954901/post-video-to-youtube – tomi

相關問題