Playing HLS (m3u8 playlist) on Windows Phone 8.1

2019-01-28 08:39发布

问题:

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

回答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.



回答2:

@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.



回答3:

you can add them from xaml or cs. First add reference.

  1. 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>
    
  2. 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");