i want play video in media element from shearing file in networking . how can do it ?
for example my local IP is 192.168.1.51 and shared folder name is 'SharedFileVideo' . i can access this file from windows explorer with \192.168.1.51\SharedFileVideo\video.mp4 but when i use \192.168.1.51\SharedFileVideo or file://192.168.1.51/SharedFileVideo/video.mp4 in Uri for source of element media doesn't play my video .
how can bind video from file shared in networking for medial element in uwp .
many thanks
To play a video file in shared folder on network, we can get the StorageFile first and then use the SetSource method to set the source to the file. To access files in the shared folder, we need declare some capabilities in the app manifest.
Universal Naming Convention (UNC) is the naming system commonly used in Microsoft Windows for accessing shared network folders. For more info, please see File access permissions.
So we can set Package.appxmanifest like following:
<Applications>
<Application Id="App" Executable="$targetnametoken$.exe" EntryPoint="UWPApp.App">
<uap:VisualElements DisplayName="UWPApp" Square150x150Logo="Assets\Square150x150Logo.png" Square44x44Logo="Assets\Square44x44Logo.png" Description="UWPApp" BackgroundColor="transparent">
<uap:DefaultTile Wide310x150Logo="Assets\Wide310x150Logo.png">
</uap:DefaultTile>
<uap:SplashScreen Image="Assets\SplashScreen.png" />
</uap:VisualElements>
<Extensions>
<uap:Extension Category="windows.fileTypeAssociation">
<uap:FileTypeAssociation Name="myvideotest">
<uap:DisplayName>MyVideoTest</uap:DisplayName>
<uap:SupportedFileTypes>
<uap:FileType>.mp4</uap:FileType>
</uap:SupportedFileTypes>
</uap:FileTypeAssociation>
</uap:Extension>
</Extensions>
</Application>
</Applications>
<Capabilities>
<Capability Name="internetClient" />
<Capability Name="privateNetworkClientServer" />
<Capability Name="internetClientServer" />
<uap:Capability Name="enterpriseAuthentication" />
</Capabilities>
And then in code-behind, retrieve the shared folder first.
StorageFolder folder = await StorageFolder.GetFolderFromPathAsync(#"\\192.168.1.51\SharedFileVideo");
After this, we can retrieve the video file and set it as MediaElement's source like:
StorageFile file = await folder.GetFileAsync("video.mp4");
var stream = await file.OpenAsync(Windows.Storage.FileAccessMode.Read);
MediaElement.SetSource(stream, file.ContentType);
Have you tried setting your source to:
\\192.168.1.51\SharedFileVideo\video.mp4
back slashes (\) not forward slashes (/) and make sure to start with a double back slash
i do this with my raspberry pi and it gets them fine
\\RASPBERRYPI\Films\OS1\Films\video.mp4
dont forget to do this in xaml youll need this:
<MediaElement Source="\\192.168.1.51\SharedFileVideo\video.mp4"/>
or for binding:
<MediaElement Source="{Binding Path=URI}"/>
and in code:
URI = #"\\192.168.1.51\SharedFileVideo\video.mp4";
as i said this works fine for me, i dont need synchronous programming and my machines and routers seem good enough not to cause lag or buffering issues
one other thing to remember if binding the source to a string then sometimes the media element needs telling to play. if so dont forget to tell it your manually loading video with the loaded behaviour tag.
so xaml:
<MediaElement Name="VideoPlayer" Source="{Binding Path=URI}" LoadedBehaviour="Manual"/>
and in code add:
URI = #"\\192.168.1.51\SharedFileVideo\video.mp4";
VideoPlayer.Play();
Related
A friend and I have tried to get the video player on Windows Phone 8.1 to play a m3u8 stream, but we've been unavailable to succeed.
What we've tried:
We've tried with playerframework.codeplex.com (Microsoft Player Framework), but it was unable to load the file.
We also tried with Windows Phone Streaming Media (https://phonesm.codeplex.com/), but we were unable to as much as use this one as we couldn't make sense of their documentation on how we actually had to load the file?
Is there anybody who have worked with this kind of files before? I understand that m3u8 is not natively supported by Windows Phone 8.1
Download the player framework, consume the following DLL's:
Add the player to your xaml:
xmlns:mmppf="using:Microsoft.PlayerFramework"
xmlns:smmedia="using:SM.Media.MediaPlayer"
<mmppf:MediaPlayer IsFullScreenVisible="True" IsFullScreenEnabled="True" IsFullScreen="False" CurrentStateChanged="mPlayer_CurrentStateChanged" x:Name="mPlayer" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" IsFastForwardEnabled="False" IsInfoEnabled="False" IsLive="True" IsMoreEnabled="False" IsRewindEnabled="False" IsRightTapEnabled="False" IsScrubbingEnabled="False" IsSeekEnabled="False" IsSkipBackEnabled="False" IsSkipAheadEnabled="False" IsReplayEnabled="False" IsTimelineVisible="False" IsTimeElapsedVisible="False" IsTimeRemainingVisible="False" RequestedTheme="Dark">
<mmppf:MediaPlayer.Plugins>
<smmedia:StreamingMediaPlugin />
</mmppf:MediaPlayer.Plugins>
</mmppf:MediaPlayer>
Then set your stream VIA code - or XAML if the URL never changes.
#Mahesh Vemuri asked what if he has error that says StreamingMediaPlugin is not available or not found in namespace, here is my work around:
XAML:
xmlns:PlayerFramework="using:Microsoft.PlayerFramework"
<PlayerFramework:MediaPlayer Name="player"
Source="http://devimages.apple.com/iphone/samples/bipbop/bipbopall.m3u8"
AudioCategory="BackgroundCapableMedia"
IsAudioSelectionVisible="True">
<PlayerFramework:MediaPlayer.Plugins>
</PlayerFramework:MediaPlayer.Plugins>
</PlayerFramework:MediaPlayer>
And in your .xaml.cs file you simply do this:
SM.Media.MediaPlayer.StreamingMediaPlugin asd = new SM.Media.MediaPlayer.StreamingMediaPlugin();
player.Plugins.Add(asd);
player.Source = new Uri("address-to-m3u8");
It worked for me since "default" way didn't. Hope it helps someone else, too.
you can add them from xaml or cs. First add reference.
XAML
xmlns:local="clr-namespace:Microsoft.PlayerFramework;assembly=Microsoft.PlayerFramework"
xmlns:smmedia="clr-namespace:SM.Media.MediaPlayer;assembly=SM.Media.MediaPlayer.WP8"
<local:MediaPlayer Name="player"
HorizontalContentAlignment="Stretch"
AutoPlay="True"
Volume="0.7"
Source="http://devimages.apple.com/iphone/samples/bipbop/bipbopall.m3u8"
IsPlayPauseVisible="True">
<local:MediaPlayer.Plugins>
<smmedia:StreamingMediaPlugin />
</local:MediaPlayer.Plugins>
</local:MediaPlayer>
XAML & CS
xmlns:local="clr-namespace:Microsoft.PlayerFramework;assembly=Microsoft.PlayerFramework"
<local:MediaPlayer Name="player"
HorizontalContentAlignment="Stretch"
AutoPlay="True"
Volume="0.7"
IsPlayPauseVisible="True">
</local:MediaPlayer>
SM.Media.MediaPlayer.StreamingMediaPlugin asd = new SM.Media.MediaPlayer.StreamingMediaPlugin();
player.Plugins.Add(asd);
player.Source = new Uri("http://devimages.apple.com/iphone/samples/bipbop/bipbopall.m3u8");
I have a Windows Phone 8.1 Silverlight app that I need to switch to WMS. When using WMS, the tile definitions from WMAppManifest.xml are no longer used, all the tiles are defined in Package.appxmanifest.
The problem is, in Package.appxmanifest there is no UI for setting the tiles. When I open the file as XML, I can see no definition for a wide tile.
So how do I add the wide tile?
If I remember, I added the wide tile directly in the XML. And I've that kind of lines (check the Wide310x150Logo property) :
<Application Id="xxxxx" Executable="AGHost.exe" EntryPoint="View/MainPage.xaml">
<m3:VisualElements DisplayName="SeriesManiac" Square150x150Logo="Assets\150x150.png" Square44x44Logo="Assets\Logo.png" Description="SeriesManiac" ForegroundText="light" BackgroundColor="transparent" ToastCapable="true">
<m3:DefaultTile Wide310x150Logo="Assets\WideLogo.png" Square71x71Logo="Assets\71x71.png">
</m3:DefaultTile>
<m3:SplashScreen Image="Assets\Splashscreen.png" />
</m3:VisualElements>
<Extensions>
<Extension Category="windows.backgroundTasks" EntryPoint="AgHost.BackgroundTask">
<BackgroundTasks>
<Task Type="systemEvent" />
</BackgroundTasks>
</Extension>
</Extensions>
</Application>
I have two problems:
I need to start an app from another app.
I need to make two certain image links do just one action each (right now, both of them do both action).
Details for no. 1: i've directly called Process.Start("D:\\proba/ControlsBasics-WPF.appref-ms");
What do I do when I move the app or instal it on a different computer and the respective user does not have that pathway? I want to make a connection between two apps.
Details for no.2: right now, I have two image links (pic2) that open both a main window and an article . I need to make one of them open the main window and the other one open the article. I've done a printscreen so that you can see the codelines for the image links.
This is a very important problem for me and I hope I was clear enough.
Thank you.
http://i.stack.imgur.com/x3fVi.jpg
I've also added the code so that you can see it better:
<List x:TypeArguments="mskbm:ExperienceOptionModel" xmlns="clr-namespace:System.Collections.Generic;assembly=mscorlib" xmlns:mskbm="clr-namespace:Microsoft.Samples.Kinect.InteractionGallery.Models;assembly=InteractionGallery-WPF" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<mskbm:ExperienceOptionModel
Name="VIDEO"
ImageUri="pack://application:,,,/Content/HomeScreen/01.png"
OverlayImageUri="pack://application:,,,/Content/HomeScreen/play-overlay.png"
NavigableContextName="Video"
NavigableContextParameter="Content/Videos/K4W.wmv" />
<mskbm:ExperienceOptionModel
Name="VIDEO"
ImageUri="pack://application:,,,/Content/HomeScreen/02.png"
OverlayImageUri="pack://application:,,,/Content/HomeScreen/play-overlay.png"
NavigableContextName="Video"
NavigableContextParameter="Content/Videos/K4W_NISSAN.wmv" />
<mskbm:ExperienceOptionModel
Name="MAPPA PUNTI VENDITA"
ImageUri="pack://application:,,,/Content/img/03.png"
NavigableContextName="PannableContent"
NavigableContextParameter="pack://application:,,,/Content/PannableContentScreen/WorldMap.xaml" />
<mskbm:ExperienceOptionModel
Name="TUTORIAL KINECT"
ImageUri="pack://application:,,,/Content/img/05.png"
NavigableContextName="Article"
NavigableContextParameter="pack://application:,,,/Content/ArticleScreen/Article2.xaml" />
<mskbm:ExperienceOptionModel
Name="CATALOGO INTERATTIVO"
ImageUri="pack://application:,,,/Content/img/01.png"
NavigableContextName="Article"
NavigableContextParameter="pack://application:,,,/Content/ArticleScreen/Article2.xaml" />
<mskbm:ExperienceOptionModel
Name="INFO E CONTANTI"
ImageUri="pack://application:,,,/Content/img/06.png"
NavigableContextName="Article"
NavigableContextParameter="pack://application:,,,/Content/ArticleScreen/Article2.xaml" />
</List>
I have a metro app and I have added an existing file into a folder inside solution explorer. I have read the resources docs on msdn but can't get it figured out.
My sound file is located in Assets\SFX\Standard.wav, so how would I locate and play this file using MediaElement in my app from codebehind?
I am not sure why you would want to use MediaElement, perhaps you could try SoundPlayer?
System.Media.SoundPlayer player = new System.Media.SoundPlayer();
player.SoundLocation = "\Assets\SFX\Standard.wav";
player.Play();
Edit with MediaElement:
<MediaElement Name="TehSoundz" IsLooping="False" AutoPlay="False" Height="0" Width="0" Source="\Assets\SFX\Standard.wav" />
Codebehind:
TehSoundz.Play();
TehSoundz.Stop();
In my c#/WPF project, I added a jpg to the resources to embed into the exe file.
Now I want to use this jpg in an image tag, something like
<xmlns:prop="clr-namespace:MyProgram.Properties"
<Image Source="{Binding Source={StaticResource prop:LogoJpg}}"
My problem: it does not work. I got no idea, how to use the image. I could use files from the hdd, but I need the image to be embedded in the exe file.
First, add the image to your project, with a Build Action of "Resource" (not EmbeddedResource). For instance, I've added an image called "logo.jpg" to a folder called Images in my main project.
Then, in XAML, you use just use that resource as follows:
<Image Source="Images\logo.jpg" />
You can also use the pack syntax for the source:
<Image Source="pack://siteoforigin:,,,/Images/logo.jpg" />
Hope this helps.