2012-10-03 54 views
1

我剛開始玩的Windows 8開發,我想弄清楚如何製作一個視頻,其源是從一個URL從按下按鈕或雙擊視頻播放區域彈出到全屏。任何想法如何做到這一點?作爲一個後續,我也必須能夠將它最小化回到正常的播放窗口。有關如何使用xaml C#做到這一點的任何想法?微軟媒體平臺播放器框架,從按鈕按下(或雙擊視頻)使視頻全屏

參考: http://playerframework.codeplex.com/wikipage?title=Windows%208%20Metro%20Player:%20Install%20and%20configure%20-%20XAML/C

回答

2

玩家框架有一個名爲IsFullScreen管理全屏狀態的布爾屬性。但是,您需要親自完成工作以隱藏頁面上的多餘元素和/或調整mediaplayer的大小。建議的方法是設置此屬性並處理IsFullScreenChanged事件。例如:

<Grid Style="{StaticResource LayoutRootStyle}" x:Name="LayoutRoot"> 
    <Grid.ColumnDefinitions> 
     <ColumnDefinition Width="Auto"/> 
     <ColumnDefinition Width="*"/> 
    </Grid.ColumnDefinitions> 
    <Border x:Name="LeftPanel" Background="Red" Width="40"/> 
    <mmppf:MediaPlayer x:Name="player" Grid.Column="1" IsFullScreenVisible="True" Source="http://smf.blob.core.windows.net/samples/videos/wildlife.mp4"/> 
</Grid> 

public MainPage() 
{ 
    this.InitializeComponent(); 
    player.DoubleTapped += player_DoubleTapped; 
    player.IsFullScreenChanged += player_IsFullScreenChanged; 
} 

void player_IsFullScreenChanged(object sender, RoutedPropertyChangedEventArgs<bool> e) 
{ 
    LeftPanel.Visibility = e.NewValue ? Visibility.Collapsed : Visibility.Visible; 
} 

void player_DoubleTapped(object sender, DoubleTappedRoutedEventArgs e) 
{ 
    player.IsFullScreen = !player.IsFullScreen; 
} 

注:也有關於MediaPlayer的通話IsFullScreenVisible,你可以設置爲true以顯示默認的控制條上的全屏切換按鈕的屬性。

1

我用這個代碼爲fullWindow。它工作,但在全窗口它使用默認的transportcontrols

private void MediaPlayer_IsFullScreenChanged(object sender, Windows.UI.Xaml.RoutedPropertyChangedEventArgs<bool> e) 
      { 
       Microsoft.PlayerFramework.MediaPlayer mp = (sender as Microsoft.PlayerFramework.MediaPlayer); 
       mp.IsFullWindow = !mp.IsFullWindow; 
      } 
相關問題