2013-06-19 63 views
0

想使用Salesforce CRM Content Documents來存儲這兩個視頻文件,並且還鏈接到外部視頻鏈接(可以說YouTube視頻)。事實上,我已經貢獻了兩個內容,一個是實際視頻,另一個是指向YouTube視頻的鏈接。我如何在Apex頁面訪問並顯示它們?如何在Apex頁面中顯示Salesforce CRM Content視頻?

+0

似乎ContentVersion的sObject的VersionData場是要走的路: http://www.salesforce.com/docs/developer/cookbook/index_Left.htm#CSHID= personal_to_public.htm | StartTopic = Content%2Fpersonal_to_public.htm | SkinName = webhelp 我應該編寫一個客戶端代碼(例如javascript)來調用webservice並檢索VersionData;儘管這將是一個新的挑戰。 –

回答

0

您可能需要調出以這種方式來避免省長限制

[NAME].force.com/sfc/servlet.shepherd/version/download/[CONTENTVERSIONID] 

可能也有得到這個工作需要一些額外的配置。請參考以下鏈接:

Make ContentVersion downloadable

0

我與我的代碼共享一部分你,我希望這有助於

1 SF ObjectYouTubevideoIDContentDocumentIdimgUrl場創建。

2創建通過這個邏輯

public void updateActionAndImege(){ 
     if(this.YouTubevideoID!=null && this.YouTubevideoID!=''){ 
      this.tendingAction = 'loadVideo(\''+YouTubevideoID+'\');'; 
      this.link = 'https://youtube.com/watch?v='+YouTubevideoID; 
     } 
     if(this.ContentDocumentId!=null && this.ContentDocumentId!=''){ 
      this.tendingAction = 'OverlayDialogElement.showFilePreview(\'docViewerOverlay\',\'title_'+ContentDocumentId+'\',\'/_swf/121310/sfc\',\''+ContentDocumentId+'\',\'chatter_bubble\',\'false\',\'docViewerContainer\',false,\'docx\',false);'; 
      this.link = '/'+ContentDocumentId; 
     } 
     if(this.imgUrl==null || this.imgUrl==''){ 
      if(this.YouTubevideoID!=null && this.YouTubevideoID!=''){ 
       this.imgUrl = 'https://img.youtube.com/vi/'+YouTubevideoID+'/hqdefault.jpg'; 
       isYouTubeImg = true;  
      } 
      if(this.ContentDocumentId!=null && this.ContentDocumentId!='') 
       this.imgUrl = 'https://c.cs15.content.force.com/sfc/servlet.shepherd/version/renditionDownload?rendition=THUMB720BY480&versionId='+ContentDocumentId+'&operationContext=CHATTER'; 
     } 

}

4示出了這個類頁

<img src="{!cl.imgUrl}" alt="Click to preview" class="contentThumbnail {!IF(cl.isYouTubeImg,'yt_thumb_small','')}" title="Click to preview" id="ext-gen4"/> 
<a class="view_m" href="javascript:{!cl.tendingAction}">View </a> 

6 JS對具有

public string link {get;set;} 
public string tendingAction {get;set;} 
public string link {get;set;} 

3填充此類YouTube加載

function loadVideo(videoID) { 
     loadPopup(); 
     if(ytplayer) { 
      ytplayer.loadVideoById(videoID); 
     } 
     else{ 
      loadPlayer(videoID); 
     } 
     } 

     // This function is called when an error is thrown by the player 
     function onPlayerError(errorCode) { 
     alert("An error occured of type:" + errorCode); 
     } 

     // This function is automatically called by the player once it loads 
     function onYouTubePlayerReady(playerId) { 
     ytplayer = document.getElementById("ytPlayer"); 
     ytplayer.addEventListener("onError", "onPlayerError"); 
     centerPopup(); 
     ytplayer.playVideo(); 
     } 

     // The "main method" of this sample. Called when someone clicks "Run". 
     function loadPlayer(videoID) { 
     // The video to load 
     var videoID = videoID; 
     // Lets Flash from another domain call JavaScript 
     var params = { allowScriptAccess: "always" }; 
     // The element id of the Flash embed 
     var atts = { id: "ytPlayer" }; 

     //var pageHeight = $(window).height(); 
     var pageWidth = $(window).width(); var tWidth; var tHeight; 
     if(pageWidth <= 760) {tHeight = 278; tWidth = 440;} 
     if(pageWidth > 760 && pageWidth <= 980){tHeight = 378; tWidth = 540;} 
     if(pageWidth > 980) {tHeight = 478; tWidth = 640;} 
     // All of the magic handled by SWFObject (http://code.google.com/p/swfobject/) 

     swfobject.embedSWF("https://www.youtube.com/v/" + videoID + 
          "?version=3&enablejsapi=1&playerapiid=player1", 
          "videoDiv", tWidth, tHeight, "9", null, null, params, atts); 
     } 
+0

Shimshon, 謝謝發佈這個答案!我認爲這將適用於YouTube鏈接內容,但我也在尋找一種呈現存儲實際視頻文件(而不是YouTube視頻鏈接)的視頻CRM內容的方式。我想,我應該創建一個使用ContentVersion.VersionData來提供視頻內容的頁面,以及另一個使用jscript(類似於您的)來顯示提供的視頻的頁面。 –

相關問題