No smooth streaming video only audio in code behind with Silverlight 5 - c#

Backstory in Silverlight 5 dynamic stream URI setting.
My goal (as an artifact from the link) is to resolve why I'm rendering audio fine but not video for smooth streaming files in dynamically rendered (InitParam) smooth URIs.
Basically, I need to pass a dynamically generated smooth stream URI into the player and set "Media Source" correctly. Which I believe I've done.
Testing statically linked MediaSource="http://playready.directtaps.net/smoothstreaming/TTLSS720VC1/To_The_Limit_720.ism/Manifest"/ works fine for both video and audio.
However dynamically generating the PlayListItem doesn't.
The code..
MainPage.xaml
<UserControl x:Class="SilverlightApplicationDPCS.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:Core="clr-namespace:Microsoft.SilverlightMediaFramework.Core;assembly=Microsoft.SilverlightMediaFramework.Core"
xmlns:Media="clr-namespace:Microsoft.SilverlightMediaFramework.Core.Media;assembly=Microsoft.SilverlightMediaFramework.Core"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="400">
<Grid x:Name="LayoutRoot" Background="White" xmlns:smf="http://schemas.microsoft.com/smf/2010/xaml/player">
<smf:SMFPlayer HorizontalAlignment="Stretch" Margin="0"
x:Name="sMFPlayer" VerticalAlignment="Stretch" />
<Core:SMFPlayer AutoPlay="True" AutoLoad="True">
<Core:SMFPlayer.Playlist>
</Core:SMFPlayer.Playlist>
</Core:SMFPlayer>
</Grid>
MainPage.xaml.cs (overriding the consumption of the InitParam param for debug purposes statically setting uriString)
public partial class MainPage : UserControl
{
public MainPage()
{
InitializeComponent();
App currentApp = (App)Application.Current;
string uriString = "http://playready.directtaps.net/smoothstreaming/TTLSS720VC1/To_The_Limit_720.ism/Manifest";
if (sMFPlayer.Playlist.Count > 0)
sMFPlayer.Playlist.Clear();
sMFPlayer.Playlist.Add(new PlaylistItem
{
MediaSource = new Uri(uriString, UriKind.Absolute),
DeliveryMethod = DeliveryMethods.AdaptiveStreaming
});
sMFPlayer.Play();
All references below are version 2.012.0605.0, other than Microsoft.Web.Media.SmoothStreaming.dll version 2.0.157.18
Project References:
Microsoft.SilverlightMediaFramework.Core.dll
Microsoft.SilverlightMediaFramework.Plugins.dll
Microsoft.SilverlightMediaFramework.Plugins.SmoothStreaming.dll
Microsoft.SilverlightMediaFramework.Utilities.dll
Microsoft.Web.Media.SmoothStreaming.dll
Compiler Environment:
Microsoft Media Platform: Player Framework
Silverlight 5
Windows 7
Visual Studio 2015
Browser: Run-time Internet Explorer 11.
Fiddler shows video and audio smooth fragments..
GET http://playready.directtaps.net/smoothstreaming/TTLSS720VC1/To_The_Limit_720.ism/QualityLevels(688000)/Fragments(video=60050000) HTTP/1.1
GET http://playready.directtaps.net/smoothstreaming/TTLSS720VC1/To_The_Limit_720.ism/QualityLevels(128000)/Fragments(audio=61765079) HTTP/1.1
From the above StackOverlow link, where I'm left is:
Why I can't see video from multiple smooth streaming sources in Silverlight 5, nor player controls being operative, but hear audio and see video and audio packets in Fiddler is perplexing.
Grateful for any ideas to fix this.

Related

Adding xaml elements for VLC player to WPF application

I am making a video game in C# WPF. I have a huge number of MediaElements, that run mp3 and mp4 files when needed. Recently I read that there is a license fee for just using those file formats, and decided to convert them to ogg and ogv formats.
Just to be sure you understand: I am not trying to make my own video player. I only need a way to run relevant files, at the correct stages of my game.
I found some information on the web, and now trying to make a small test app, that just runs a video on start.
I installed those NuGet plugins (didn't know which one is needed):
Meta.Vlc, Vlc.DotNet.Core, Vlc.DotNet.Core.Interops, Vlc.DotNet.Wpf
That's my xaml file:
<Window x:Class="Test.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:wpf="clr-namespace:Vlc.DotNet.Wpf;assembly=Vlc.DotNet.Wpf"
xmlns:local="clr-namespace:Test"
mc:Ignorable="d"
Title="MainWindow" Height="350" Width="525" Loaded="Window_Loaded">
<Grid>
<MediaElement x:Name="movTest" Panel.ZIndex="1" HorizontalAlignment="Left" Height="319" Margin="10,0,0,0" VerticalAlignment="Top" Width="507" LoadedBehavior="Manual" Source="Resources/VideoFallingFromTable.ogv"/>
<wpf:VlcControl x:Name="movTest2" Panel.ZIndex="2" />
</Grid>
Now, I see that there is no "Source" for wpf:VlcControl.
Si, I tried to load the source from MediaElement.
private void Window_Loaded(object sender, RoutedEventArgs e)
{
movTest2.MediaPlayer.Play(movTest.Source);
}
But I get just black window and no sound. I guess I am doing something wrong.
Can you help me learn to run VLC player in WPF?
Thank you,
Evgenie
UPDATE:
I tried following code:
VlcControl thisVlcControl = new VlcControl();
Uri src = new Uri(movTest.Source.ToString(), UriKind.RelativeOrAbsolute);
thisVlcControl.MediaPlayer.Play(src);
For some reason, it worked with mp4 file, but not with ogv.

How to force a Windows 10 uwp webview app to load a url after suspend / resuming & auto reload when timing out

This (simplified) c# / XAML UWP Webview app displays a blank page after the app is resumed after about 90+ sec. when displaying a local security cam video stream webpage. It appears to timeout after about 90 sec while the app is being suspended and then upon resuming the webview page is blank. To give the sample code below something to display, I randomly picked a site from a web search and landed on http://www.porttampawebcam.com/. The few youtube and webcam pages I've tried didn't reproduce the issue of timing out like my local web cam server does after a min. or so of inactivity.
A button can be used to manually refresh / reload the page, but how can it be coded to ...
A) Force the url to load every time the app gets resumed?
B) Detect that the page has timed out and then reload as needed?
I've done a bit of research on this (using the webview control & UWP application lifecyles), browsed uwp apps on GitHub, and have made progress on several other parts of the app, but have yet to figure out a working solution on these two points.
App was built using the Blank App (Universal Windows) template in Visual Studio 2015.
XAML:
Mainpage.xaml
<Page
x:Class="WVMinimal.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid.RowDefinitions>
<RowDefinition Height="*" ></RowDefinition>
<RowDefinition Height="auto" ></RowDefinition>
</Grid.RowDefinitions>
<WebView Name="WV" Source="http://www.porttampawebcam.com"/>
</Grid>
</Page>
c#:
Mainpage.xaml.cs
using Windows.UI.Xaml.Controls;
// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x409
namespace UWPWebviewTest5
{
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class MainPage : Page
{
public MainPage()
{
this.InitializeComponent();
}
}
I know it's a bit late and maybe not 100% answering your question but maybe you could try to refresh the WebView content like this:
await WebView.ClearTemporaryWebDataAsync();
yourWebView.Navigate(new Uri("https://www.yourUri.com"));

Adding MediaElement to windows form error C#

Hi i just recently found out that you can use components from WPF and add into windows form just by creating them and later adding then into the form as element Host
So what i am trying to do is to create a video player using MediaElement and i also know that you can use Direct X or use Windows Media player for this put i want to custom make some controls in this so here is my question
when i try to add a the media element into my windows form it give me this error
here's my code for the mediaelement wpf
<UserControl x:Class="Videoplayer_2._0.MediaPlayer"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Videoplayer_2._0"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<Grid>
<MediaElement x:Name="mediaElement" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
</Grid>
</UserControl>
So is adding mediaElement just doesn't work or i did something wrong and also i added a WPF slider into the form also just saying because i have no idea if it will affect it or not
You just need to restart Visual Studio I think.

WP8 Map control with custom tiles

I'm trying to display a map control in my app targeting Windows Phone 8 but I want to use custom tiles from open street map.
I'm using this line :
mapControl.TileSources.Add(new TileSource("http://a.tile.openstreetmap.org/{zoomLevel}/{x}/{y}.png"));
When I launch the app the custom tiles are properly displayed, but there's still the default map tiles underneath them.
I tried to hide them, but I counld'nt even find where they exist in the map control and what is displaying them exactly.
I would like to know how I can remove those default tiles when loading custom tiles.
I tried to hide them, but I counld'nt even find where they exist in the map control and what is displaying them exactly.
PS : Here's the link to the "old" bing map control if you cannot find it in the latest WP Tools : http://www.microsoft.com/en-us/download/confirmation.aspx?id=2949
I tried this myself with the new WP8 "Nokia HERE maps" map control but was unable to achieve this. I had to resort to falling back to the older "Bing" based map control in Microsoft.Phone.Controls.Maps (marked as obsolete).
Here's how to remove the other layers in the older Microsoft.Phone.Controls.Maps control:
for (var i = Map.Children.Count - 1; i >= 0; i--)
{
MapTileLayer tileLayer = Map.Children[i] as MapTileLayer;
if (tileLayer != null)
{
Map.Children.RemoveAt(i);
}
}
Even though this older map control has been superseded in WP8 the newer control doesn't seem to support the same flexibility with layers and the "obsolete" control still works happily under WP8.1 if used in your app.
Here's my app which still uses the older control which is probably achieving what you're trying to do - NZ Topo Map app for Windows Phone.
Cut down Xaml for using the older map control in your app (you'll probably want to ignore my data bindings and replace them with your own):
<UserControl x:Class="TopoMap.Controls.Map"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:m="clr-namespace:Microsoft.Phone.Controls.Maps;assembly=Microsoft.Phone.Controls.Maps"
mc:Ignorable="d"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
d:DesignHeight="480" d:DesignWidth="480"
DataContext="{Binding Main, Source={StaticResource Locator}}">
<Grid x:Name="LayoutRoot" Background="Transparent">
<m:Map x:Name="MapBase" LogoVisibility="Collapsed" ScaleVisibility="Visible"
Loaded="Map_Loaded"
LayoutUpdated="Map_LayoutUpdated"
ZoomLevel="{Binding ZoomLevel, Mode=TwoWay}"
Center="{Binding Center, Mode=TwoWay}">
</m:Map>
</Grid>
</UserControl>
The important reference that you need it:
xmlns:m="clr-namespace:Microsoft.Phone.Controls.Maps;assembly=Microsoft.Phone.Controls.Maps"

WinRT C# Play a viddler video using MediaElement

I am trying to play a Viddler video in my application but i cant get it to work.
Here is my simple code:
XAML:
< MediaElement VerticalAlignment="Center" Visibility="Visible"
HorizontalAlignment="Center"
Name="myMediaElement" Height="350"
Width="640" />
And my c#:
myMediaElement = new MediaElement();
Uri url = new Uri("http://www.viddler.com/embed/5b17d44f/");
myMediaElement.Source = url;
myMediaElement.Play();
Any help would be great! When i arrive on the page, nothing happens, the application does not break it just does nothing....
Edit:
In the end I have just decided to call the http://www.viddler.com/embed/5b17d44f/ url into a Webview, its not the best idea but it works.
Dont create a new MediaElemet. You already have one created (XAML).
Set AutoPlay="True" in your XAML
Edit: Play works only if the media is already loaded.

Categories