Advertisement
Guest User

MusicPlayer.cs

a guest
Mar 2nd, 2018
89
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using Microsoft.Xna.Framework.Media;
  2. using System;
  3.  
  4. namespace AudioResumeTest
  5. {
  6.     public interface IMusicPlayer
  7.     {
  8.         bool IsMuted { get; set; }
  9.         bool IsRepeating { get; set; }
  10.         float Volume { get; set; }
  11.         TimeSpan PlayPosition { get; set; }
  12.  
  13.         void Play(Song s);
  14.         void Play(Song s, TimeSpan startPosition);
  15.         void Stop();
  16.     }
  17.  
  18.     public class MonoGameMusicPlayer : IMusicPlayer
  19.     {
  20.         public bool IsMuted { get => MediaPlayer.IsMuted; set => MediaPlayer.IsMuted = value; }
  21.         public bool IsRepeating { get => MediaPlayer.IsRepeating; set => MediaPlayer.IsRepeating = value; }
  22.         public float Volume { get => MediaPlayer.Volume; set => MediaPlayer.Volume = value; }
  23.         public TimeSpan PlayPosition { get => MediaPlayer.PlayPosition; set => MediaPlayer.PlayPosition = value; }
  24.  
  25.         public void Play(Song s)
  26.         {
  27.             MediaPlayer.Play(s);
  28.         }
  29.  
  30.         public void Play(Song s, TimeSpan startPosition)
  31.         {
  32.             MediaPlayer.Play(s, startPosition);
  33.         }
  34.  
  35.         public void Stop()
  36.         {
  37.             MediaPlayer.Stop();
  38.         }
  39.     }
  40. }
Advertisement
RAW Paste Data Copied
Advertisement