Player:Player under controls:TabItem

Oct 18, 2011 at 6:44 PM

Hi,

I want to customize the source code downloaded here http://smf.codeplex.com/releases/view/63434#DownloadId=222620 so that I can have multiple tabs each tab contain each own player.

By that, I modify the MainView.xaml under Microsoft.HealthMonitor. I wrap this code

                     <Border Grid.Row="1" Grid.RowSpan="2" Grid.Column="1" BorderThickness="2" BorderBrush="Black">
                        <Grid>
                            <ContentControl x:Name="playerFrame0" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" Visibility="{Binding IsPlayerEmbedded, Converter={StaticResource VisibilityConverter}, ConverterParameter=VisibleIfNotTrue}">
                                <StackPanel VerticalAlignment="Center" HorizontalAlignment="Center">
                                    <TextBlock TextAlignment="Center" Text="{Binding Instruction}" FontSize="15"/>
                                    <TextBlock TextAlignment="Center" Text="Connection state: Connected" FontSize="15" Visibility="{Binding Connected, Converter={StaticResource VisibilityConverter}, ConverterParameter=VisibleIfTrue}"/>
                                    <TextBlock TextAlignment="Center" Text="Connection state: Not Connected" FontSize="15" Visibility="{Binding Connected, Converter={StaticResource VisibilityConverter}, ConverterParameter=VisibleIfNotTrue}"/>
                                </StackPanel>
                            </ContentControl>
                            <player:Player x:Name="Player0" VideoUrl="{Binding SmoothStreamingSource}"  Visibility="{Binding IsPlayerEmbedded, Converter={StaticResource VisibilityConverter}, ConverterParameter=VisibleIfTrue}" />
                        </Grid>
                    </Border>

using the controls:TabControl as:

           <controls:TabControl Grid.Row="1" Grid.Column="1" Grid.RowSpan="2">
                <controls:TabItem Header="Video#0" VerticalContentAlignment="Stretch" HorizontalContentAlignment="Stretch">
                    <Border Grid.Row="1" Grid.RowSpan="2" Grid.Column="1" BorderThickness="2" BorderBrush="Black">
                        <Grid>
                            <ContentControl x:Name="playerFrame0" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" Visibility="{Binding IsPlayerEmbedded, Converter={StaticResource VisibilityConverter}, ConverterParameter=VisibleIfNotTrue}">
                                <StackPanel VerticalAlignment="Center" HorizontalAlignment="Center">
                                    <TextBlock TextAlignment="Center" Text="{Binding Instruction}" FontSize="15"/>
                                    <TextBlock TextAlignment="Center" Text="Connection state: Connected" FontSize="15" Visibility="{Binding Connected, Converter={StaticResource VisibilityConverter}, ConverterParameter=VisibleIfTrue}"/>
                                    <TextBlock TextAlignment="Center" Text="Connection state: Not Connected" FontSize="15" Visibility="{Binding Connected, Converter={StaticResource VisibilityConverter}, ConverterParameter=VisibleIfNotTrue}"/>
                                </StackPanel>
                            </ContentControl>
                            <player:Player x:Name="Player0" VideoUrl="{Binding SmoothStreamingSource}"  Visibility="{Binding IsPlayerEmbedded, Converter={StaticResource VisibilityConverter}, ConverterParameter=VisibleIfTrue}" />
                        </Grid>
                    </Border>
                </controls:TabItem>
                <controls:TabItem Header="Video#1" VerticalContentAlignment="Stretch" HorizontalContentAlignment="Stretch">
                    <Border Grid.Row="1" Grid.RowSpan="2" Grid.Column="1" BorderThickness="2" BorderBrush="Black">
                        <Grid>
                            <ContentControl x:Name="playerFrame0" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" Visibility="{Binding IsPlayerEmbedded, Converter={StaticResource VisibilityConverter}, ConverterParameter=VisibleIfNotTrue}">
                                <StackPanel VerticalAlignment="Center" HorizontalAlignment="Center">
                                    <TextBlock TextAlignment="Center" Text="{Binding Instruction}" FontSize="15"/>
                                    <TextBlock TextAlignment="Center" Text="Connection state: Connected" FontSize="15" Visibility="{Binding Connected, Converter={StaticResource VisibilityConverter}, ConverterParameter=VisibleIfTrue}"/>
                                    <TextBlock TextAlignment="Center" Text="Connection state: Not Connected" FontSize="15" Visibility="{Binding Connected, Converter={StaticResource VisibilityConverter}, ConverterParameter=VisibleIfNotTrue}"/>
                                </StackPanel>
                            </ContentControl>
                            <player:Player x:Name="Player1" VideoUrl="{Binding SmoothStreamingSource}"  Visibility="{Binding IsPlayerEmbedded, Converter={StaticResource VisibilityConverter}, ConverterParameter=VisibleIfTrue}" />
                        </Grid>
                    </Border>

                </controls:TabItem>
            </controls:TabControl>

 The code complie fine and start fine also. I select Video#0 tab, the video played just fine. Switch to Video#1 tab, the video played also ok. But then here is the problem. If I switch back to Video#0 tab => No video at all. I event hit play nothing happen. I switch to Video#1, the video is also gone.

If anyone know how to fix this, please help to share.

Sorry for my newbies question in silverlight.

Truyen