Playing HLS (m3u8 playlist) on Windows Phone 8.1 - c#

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");

Related

MediaElement Windows Phone 8.1 does not play links to resources

MediaElement Windows Phone 8.1 does not play links to resources, for example http://kgot-fm.akacast.akamaistream.net/7/449/31707/v1/auth.akacast.akamaistream.net/kgot-fm, but plays links. mp3. Windows 8 running all references. What's the problem? and how to fix it? the same code.
//only works in windows 8.1
<MediaElement x:Name="MediaElement"
Source="http://kgot-fm.akacast.akamaistream.net/7/449/31707/v1/auth.akacast.akamaistream.net/kgot-fm"
AutoPlay="True" Margin="199,320,114,252" Width="100" Height="100"/>
//works in windows 8, and in windows phone 8.1
<MediaElement x:Name="MediaElement"
Source="http://radio02-cn03.akadostream.ru:8114/businessfm96.mp3"
AutoPlay="True" Margin="199,320,114,252" Width="100" Height="100"/>
If you subscribe to MediaElement.MediaFailed:
MediaElement.MediaFailed += MediaElement_MediaFailed;
then you will see that using the first link you get:
MF_MEDIA_ENGINE_ERR_SRC_NOT_SUPPORTED : HRESULT - 0xC00D2EE0
which means (HRESULT) that:
0xC00D2EE0 NS_E_UNKNOWN_PROTOCOL
The specified protocol is not supported.
The list of supported audio and video formats you will find here.
from the c# set the string as uri
MediaElement.Source = new Uri("http://kgot-fm.akacast.akamaistream.net/7/449/31707/v1/auth.akacast.akamaistream.net/kgot-fm");

Windows phone 8 placeholder issue with Windows Phone Toolkit

I'm developing a windows phone 8 app. I'm new to windows phone 8 development.
I need to add placeholder for text box . I searched in Google & Stack Overflow i got one solution by using The windows phone Toolkit.
I try with following Code.
Step-1: Add Windows Phone Toolkit In Reference By Using Nuget gallery
Step-2: Add namespace in page header
xmlns:xtk="using:WinRTXamlToolkit.Controls"
Step-3: My Textbox XAML code
<TextBox Name="Usernametxt" Text="User Name"></TextBox>
<TextBox Name="Passwordtxt" Text="Password"></TextBox>
<TextBox Name="Emailtxt" Text="Eamail Address"></TextBox>
Step-4: I add the following code under the Usernametxt box [I don't know it's correct or not]
<xtk:WatermarkTextBox WatermarkText="some text" />
I got error in above line The Name WatermarkTextBox does not exist in namespace"using:WinRTXamlToolkit.controls"
I got this solution Here
I don't know how to use this property . I need to add placeholder for 4 to 5 textbox in same page.
Help me to solve this problem.
You are mixing up Windows Phone 8 and Windows 8.
You need a reference to correct toolkit
xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
And then you can
<toolkit:PhoneTextBox Hint="some text" Name="Usernametxt" />
Make sure you can got the right Nuget package, more details here.

Locating and reading a file stored locally

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();

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.

Image Control asynchronous

I have an image control that I want it to load the image asynchronously over the network. I see some sample code in the network saying something like:
<Image HorizontalAlignment="Left" Height="118" Margin="2,8,0,0" VerticalAlignment="Top" Width="167" x:Name="ImageThumbnail" Source="{Binding SummaryImageLink, IsAsync=True}" />
However, in Windows Phone 7, I cannot find anything like that. Does anybody know a way to do that without I have to code a lot myself
Unfortunately you are going to have to write, or include, more code yourself to do this properly. I have a similar solution with the goal to cache images after the first download. The image cache class is accessed via a IValueConverter, so once you have included the appropriate code, you only have to add a decorator on the Image object:
<Image Source="{Binding ElementName=ImageSource, Path=Text, Converter={StaticResource imageCacheConverter}}" Width="200" />
Full details here and source code here: http://www.ben.geek.nz/2010/07/one-time-cached-images-in-windows-phone-7/
David Anson's work with LowProfileImageLoader may be of interest to you.
Keep a low profile [LowProfileImageLoader helps the Windows Phone 7 UI thread stay responsive by loading images in the background] - Delay's Blog
Alternatively you can asynchronously download the picture (for ex. with a BackgroundWorker) and assign it as source for your image control only when the download has completed.

Categories