Playing HLS (m3u8 playlist) on Windows Phone 8.1

十年热恋 提交于 2019-11-29 15:31:05

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.

  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");
    
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!