2011-08-25 3 views
1

GWT 애플리케이션을 개발 중입니다. 내 애플리케이션에 YouTube 동영상을 삽입해야합니다.
BST 플레이어 API를 사용해 보았지만 플레이어에서 비디오를 가져 오는 데 성공하지 못했습니다.
내가 BST Player.jar을 다운로드하여 내 buildpath에 추가 한 다음 gwtapp.gwt.xml에서 다음 항아리를 상속 :GWT (BST Player API)에 YouTube 플레이어 삽입하기

simplePanel = new SimplePanel(); 
add(simplePanel); 
simplePanel.setSize("", ""); 
try { 
    // create the player, specifing URL of media 
    player = new ChromelessPlayer("http://www.youtube.com/watch?v=O3CZFfyed3M", "80%", "350px"); 
    CustomPlayerControl cpc = new CustomPlayerControl(player); 
    FlowPanel fp = new FlowPanel(); 
    fp.add(player); 
    fp.add(cpc); 
    simplePanel.setWidget(fp); // add player and custom control to panel. 
} catch (PluginVersionException e) { 
    // required Flash plugin version is not available, 
    // alert user possibly providing a link to the plugin download page. 
    simplePanel.setWidget(new HTML(".. some nice message telling the " + "user to download plugin first ..")); 
} catch(PluginNotFoundException e) { 
    // required Flash plugin not found, display a friendly notice. 
    simplePanel.setWidget(PlayerUtil.getMissingPluginNotice(e.getPlugin())); 
} 

내가 볼 수 있습니다 :

다음
**inherits name ='com.bramosystems.oss.player.core.Core'** 
**inherits name ='com.bramosystems.oss.player.youtube.YouTube'** 

나는 BST 페이지에 주어진 예 시도 YouTube 플레이어가있는 패널이지만 동영상로드 또는 재생을 볼 수 없었습니다. 나는 player.playMedia()을 시도했으며 도움이되지 않았습니다. 진행하고 비디오를 작동시키는 방법에 대한 아이디어가 있습니까?

답변

2

당신은 아마 대신 URL을 전달해야합니다 :

http://www.youtube.com/v/O3CZFfyed3M 
+0

멋진데! 감사. – Ashok

+0

이것은 매우 도움이되었지만 비디오를 블랙 라인으로 처리하고 있습니다. 어떤 방법 으로든 제거 할 수 있습니까? –

+0

나는 이것을 단순한 프레임과 함께 사용했다. 괜찮 았는데, 이것도 참조해라. http://stackoverflow.com/questions/14812679/vimeo-embedding-in-gwt –

2

내가 어떤 외부 라이브러리를 사용하여 vithout GWT에서 YouTube 동영상을 삽입 할 수있는 방법을 발견했다. 통합 수준은 매우 간단하므로 고급 사용을 할 수 없습니다. 여기에는 UIBinder 템플릿의 코드 조각이며, 해당 클래스 :

사용하고 HTMLPanel이 같은 개체 요소 넣어 :

<g:HTMLPanel> 

     <object ui:field="videoElement" 
       type="application/x-shockwave-flash" 
       width="640" height="480" data=""> 
     </object> 

</g:HTMLPanel> 

@UIField 
ObjectElement videoElement; 

[...] 

public void displayVideo(String videoId) { 
     String videoUrl = "http://www.youtube.com/v/".concat(videoId); 
     videoElement.setData(videoUrl); //change data attribute of object element 
     String innerHtml = "<param name=\"movie\" value=\""+ videoUrl +"\" />"; 
     //add param element, of course yo can add as many param elements as needed to customize 
     videoElement.setInnerHTML(innerHtml); 
} 

가 작동하게하려면 내가 패널 내부에이 비디오보기를 넣어 필요를 비디오를 보거나 업데이트하고 싶을 때마다 패널을 지우고 비디오보기를 다시 추가하십시오.

희망이 내가 YouTubes iframe이 API 라이브러리의 상단에이 GWT 래퍼를 만든

관련 문제