当前位置: 首页>>代码示例>>C#>>正文


C# MediaPlayer类代码示例

本文整理汇总了C#中MediaPlayer的典型用法代码示例。如果您正苦于以下问题:C# MediaPlayer类的具体用法?C# MediaPlayer怎么用?C# MediaPlayer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


MediaPlayer类属于命名空间,在下文中一共展示了MediaPlayer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetStartVideoPlaybackMessageWithCurrentPosition

        public override StartVideoPlaybackMessage GetStartVideoPlaybackMessageWithCurrentPosition(MediaPlayer mediaPlayer)
        {
            var message = base.GetStartVideoPlaybackMessageWithCurrentPosition(mediaPlayer);
            message.FullScreen = false;

            return message;
        }
开发者ID:hyptechdev,项目名称:SubSonic8,代码行数:7,代码来源:FullScreenVideoPlaybackViewModel.cs

示例2: OnCreate

		protected override void OnCreate(Bundle bundle)
		{
			base.OnCreate(bundle);

			this.SetContentView(Resource.Layout.Main);

			var playButton = this.FindViewById<Button>(Resource.Id.PlayPauseButton);
			var stopButton = this.FindViewById<Button>(Resource.Id.StopButton);
			var searchView = this.FindViewById<SearchView>(Resource.Id.SearchView);
			this.listView = this.FindViewById<ListView>(Resource.Id.listView1);
			this.timeDisplay = this.FindViewById<TextView>(Resource.Id.TimeDisplay);
			this.adapter = new SongResultsAdapter(this, new Song[0]);
			this.player = new MediaPlayer();
			
			this.switcher = this.FindViewById<ViewSwitcher>(Resource.Id.ViewSwitcher);
			this.loadingMessage = this.FindViewById<TextView>(Resource.Id.LoadingMessage);
			
			playButton.Click += this.PlayButton_Click;
			stopButton.Click += this.StopButton_Click;
			searchView.QueryTextSubmit += this.SearchView_QueryTextSubmit;
			searchView.QueryTextChange += this.SearchView_QueryTextChange;
			this.listView.ItemClick += this.ListView_ItemClick;
			this.player.BufferingUpdate += this.Player_BufferingUpdate;
			this.player.Error += this.Player_Error;

			this.ShowListViewMessage("Write in the search box to start.");
		}
开发者ID:jairov4,项目名称:Ownfy,代码行数:27,代码来源:MainActivity.cs

示例3: StartPlayback

        // Media set up

        //------------------------------------------------------------------------------
        //
        // StartPlayback
        //
        // News up a MediaPlayer, creates a playback item then 
        // MediaPlayer hands out a surface that can be put on brush
        // We call this below when we set up the tree init the composition
        //
        //------------------------------------------------------------------------------
        private void StartPlayback()
        {


            // MediaPlayer set up with a create from URI
            _mediaPlayer = new MediaPlayer();

            // Get a source from a URI. This could also be from a file via a picker or a stream

            var source = MediaSource.CreateFromUri(new Uri("http://go.microsoft.com/fwlink/?LinkID=809007&clcid=0x409"));
            var item = new MediaPlaybackItem(source);
            _mediaPlayer.Source = item;

            // MediaPlayer supports many of the starndard MediaElement vars like looping
            _mediaPlayer.IsLoopingEnabled = true;

            // Get the surface from MediaPlayer and put it on a brush
            _videoSurface = _mediaPlayer.GetSurface(_compositor);
            _videoVisual.Brush = _compositor.CreateSurfaceBrush(_videoSurface.CompositionSurface);

            // Play the video on app run.

            PlayVideo();

        }
开发者ID:flying19880517,项目名称:composition,代码行数:36,代码来源:CompositionVisualVideo.cs

示例4: WindowsMediaPlayerModel

        public WindowsMediaPlayerModel()
        {
            _mediaPlayer = new MediaPlayer();
            IsPlaying = false;

            _mediaPlayer.MediaEnded += (sender, args) => Stop();
        }
开发者ID:ReMinoer,项目名称:CoverMyOST,代码行数:7,代码来源:WindowsMediaPlayerModel.cs

示例5: HandleMediaPlayerMediaOpened

        void HandleMediaPlayerMediaOpened(MediaPlayer sender, object args)
        {
            if (isFirstOpen)
            {
                isFirstOpen = false;
                double percentage = ApplicationSettings.GetSettingsValue<double>(ApplicationSettings.CURRENT_TRACK_PERCENTAGE, 0.0);
                ApplicationSettings.PutSettingsValue(ApplicationSettings.CURRENT_TRACK_PERCENTAGE, 0.0);

                if (percentage > 0)
                {
                    Logger.Current.Init(LogType.PlayAction);

                    Logger.Current.Log(new CallerInfo(), LogLevel.Info, "Length Total {0}", mediaPlayer.NaturalDuration.Ticks);

                    mediaPlayer.Position = TimeSpan.FromTicks((long)(mediaPlayer.NaturalDuration.Ticks * percentage));
                }
            }

            int trackId = ApplicationSettings.GetSettingsValue<int>(ApplicationSettings.CURRENT_PLAYQUEUE_POSITION, 0);
            Logger.Current.Init(LogType.PlayAction);

            Logger.Current.Log(new CallerInfo(), LogLevel.Info, "Trying to play row {0}", trackId);

            playingTrack = TrackInfo.TrackInfoFromRowId(trackId);
            TrackChanged.Invoke(this, playingTrack);

            if (playAfterOpen)
            {
                sender.Play();
            }
            else
            {
                playAfterOpen = true;
            }
        }
开发者ID:jevonsflash,项目名称:ProjectMato,代码行数:35,代码来源:PlayQueueManager.cs

示例6: MediaEventsHelper

        /// <summary>
        /// Constructor
        /// </summary>
        internal MediaEventsHelper(MediaPlayer mediaPlayer) 
        {
            _mediaOpened = new DispatcherOperationCallback(OnMediaOpened); 
            this.DispatcherMediaOpened += _mediaOpened; 

            _mediaFailed = new DispatcherOperationCallback(OnMediaFailed); 
            this.DispatcherMediaFailed += _mediaFailed;

            _mediaPrerolled = new DispatcherOperationCallback(OnMediaPrerolled);
            this.DispatcherMediaPrerolled += _mediaPrerolled; 

            _mediaEnded = new DispatcherOperationCallback(OnMediaEnded); 
            this.DispatcherMediaEnded += _mediaEnded; 

            _bufferingStarted = new DispatcherOperationCallback(OnBufferingStarted); 
            this.DispatcherBufferingStarted += _bufferingStarted;

            _bufferingEnded = new DispatcherOperationCallback(OnBufferingEnded);
            this.DispatcherBufferingEnded += _bufferingEnded; 

            _scriptCommand = new DispatcherOperationCallback(OnScriptCommand); 
            this.DispatcherScriptCommand += _scriptCommand; 

            _newFrame = new DispatcherOperationCallback(OnNewFrame); 
            this.DispatcherMediaNewFrame += _newFrame;

            SetSender(mediaPlayer);
        } 
开发者ID:sjyanxin,项目名称:WPFSource,代码行数:31,代码来源:mediaeventshelper.cs

示例7: Player

        /// <summary>
        /// A media player that takes control of a NotifyIcon icon,
        /// tooltip and balloon to display status.
        /// </summary>
        /// <param name="icon">
        /// The notify icon to use to display status.
        /// </param>
        public Player(NotifyIcon icon)
        {
            notifyIcon = icon;

            player = new MediaPlayer();
            player.BufferingStarted += OnBufferingStarted;
            player.BufferingEnded += OnBufferingEnded;
            player.MediaEnded += OnMediaEnded;
            player.MediaFailed += OnMediaFailed;

            idleIcon = Util.ResourceAsIcon("GaGa.NotifyIconPlayer.Resources.Idle.ico");
            playingIcon = Util.ResourceAsIcon("GaGa.NotifyIconPlayer.Resources.Playing.ico");
            playingMutedIcon = Util.ResourceAsIcon("GaGa.NotifyIconPlayer.Resources.Playing-muted.ico");

            bufferingIcons = new Icon[] {
                Util.ResourceAsIcon("GaGa.NotifyIconPlayer.Resources.Buffering1.ico"),
                Util.ResourceAsIcon("GaGa.NotifyIconPlayer.Resources.Buffering2.ico"),
                Util.ResourceAsIcon("GaGa.NotifyIconPlayer.Resources.Buffering3.ico"),
                Util.ResourceAsIcon("GaGa.NotifyIconPlayer.Resources.Buffering4.ico"),
            };

            bufferingIconTimer = new DispatcherTimer(DispatcherPriority.Background);
            bufferingIconTimer.Interval = TimeSpan.FromMilliseconds(300);
            bufferingIconTimer.Tick += OnBufferingIconTimerTick;
            currentBufferingIcon = 0;

            source = null;
            isIdle = true;

            UpdateIcon();
        }
开发者ID:asaveliev,项目名称:GaGa,代码行数:38,代码来源:Player.cs

示例8: RunTests

 public static void RunTests() {
     var player = new MediaPlayer();
     player.Play();
     player.Pause();
     player.Stop();
     player.AllSongs.TrackNames.PrintCollection();
 }
开发者ID:JohnPaine,项目名称:learning,代码行数:7,代码来源:LazyInstantiation.cs

示例9: MainPage

 public MainPage()
 {
     this.InitializeComponent();
     this.NavigationCacheMode = NavigationCacheMode.Required;
     initValue();
     mediaPlayer = BackgroundMediaPlayer.Current;
 }
开发者ID:sikyurabmt,项目名称:HQL,代码行数:7,代码来源:MainPage.xaml.cs

示例10: MainWindow

        public MainWindow()
        {
            InitializeComponent();

            OscServer oscServer;
            
            oscServer = new OscServer(TransportType.Udp, IPAddress.Loopback, Port);

            oscServer.FilterRegisteredMethods = false;
			oscServer.RegisterMethod(AliveMethod);
            oscServer.RegisterMethod(TestMethod);
            oscServer.BundleReceived += new EventHandler<OscBundleReceivedEventArgs>(oscServer_BundleReceived);
			oscServer.MessageReceived += new EventHandler<OscMessageReceivedEventArgs>(oscServer_MessageReceived);
            oscServer.ReceiveErrored += new EventHandler<Bespoke.Common.ExceptionEventArgs>(oscServer_ReceiveErrored);
            oscServer.ConsumeParsingExceptions = false;

            oscServer.Start();
            Console.WriteLine("Server started.");

            //Start playing audio
            string audioFileName = "/file/path";
            mp = new MediaPlayer();
            mp.MediaOpened += new EventHandler(mp_MediaOpened);
            bool isPaused = false;
            bool isPlaying = false;
        }
开发者ID:JulianKemmerer,项目名称:Drexel-SeniorDesign,代码行数:26,代码来源:MainWindow.xaml.cs

示例11: OnCreate

        protected override void OnCreate (Bundle bundle)
        {
            base.OnCreate (bundle);

            // Set our view from the "main" layout resource
            SetContentView (Resource.Layout.Main);

            if(mLibVLC == null)
            {
                mLibVLC = new LibVLCLibVLC();
                mMediaPlayer = new MediaPlayer(mLibVLC);
            }

            // Get our button from the layout resource,
            // and attach an event to it
            Button button = FindViewById<Button> (Resource.Id.myButton);

            button.Click += delegate {
                button.Text = string.Format ("{0} clicks!", count++);

                var m = new MediaLibVLC(mLibVLC, Android.Net.Uri.Parse("http://www.montemagno.com/sample.mp3"));

                // Tell the media player to play the new Media.
                mMediaPlayer.Media = m;

                // Finally, play it!
                mMediaPlayer.Play();
            };
        }
开发者ID:zodsoft,项目名称:VlcXamarin,代码行数:29,代码来源:MainActivity.cs

示例12: Pause

        /// <summary>
        /// Pause
        /// </summary>
        private void Pause()
        {
            if (_mediaPlayer == null)
                _mediaPlayer = BackgroundMediaPlayer.Current;

            _mediaPlayer.Pause();
        }
开发者ID:rwecho,项目名称:Windows-Phone-Samples,代码行数:10,代码来源:BackgroundAudioTask.cs

示例13: SetUpProtectionManager

        public void SetUpProtectionManager(MediaPlayer mediaPlayer)
        {
            Log("Enter SetUpProtectionManager");

            if(mediaPlayer == null)
                throw new ArgumentException("SetUpProtectionManager was passed a null MediaPlayer");
            
            Log("Creating protection system mappings...");
            var protectionManager = new MediaProtectionManager();

            protectionManager.ComponentLoadFailed += new ComponentLoadFailedEventHandler(ProtectionManager_ComponentLoadFailed);
            protectionManager.ServiceRequested += new ServiceRequestedEventHandler(ProtectionManager_ServiceRequested);

            // The code here is mandatory and should be just copied directly over to the app
            // Ref: https://msdn.microsoft.com/en-us/library/windows/desktop/aa376846%28v=vs.85%29.aspx

            // Setup PlayReady as the ProtectionSystem to use by mediaFoundation: 
            var contentProtectionSystems = new PropertySet();
            contentProtectionSystems.Add(PlayReadyWinRTTrustedInput);
            protectionManager.Properties.Add(MediaProtectionSystemIdMapping, contentProtectionSystems);
            protectionManager.Properties.Add(MediaProtectionSystemId);
            protectionManager.Properties.Add(MediaProtectionContainerGuid);

            mediaPlayer.ProtectionManager = protectionManager;

            Log("Leave SetUpProtectionManager");
        }
开发者ID:huoxudong125,项目名称:Windows-universal-samples,代码行数:27,代码来源:PlayReadyHelper.cs

示例14: Mp3PlayerPlugin

 public Mp3PlayerPlugin()
 {
     player = new MediaPlayer();
     player.Volume = 100;
     FriendlyName = "Basic Mp3 Player";
     FriendlyStatus = "TODO: Return Current Status";
 }
开发者ID:andrewmyhre,项目名称:TomatoTimer,代码行数:7,代码来源:Mp3Player.cs

示例15: load

 public void load(MediaPlayer mp,String file)
 {
     mp.Position = TimeSpan.Zero;
     string url = @"C:\Users\Asura\Documents\Visual Studio 2012\Projects\Project Labyrinth(C-Sharp)\Pro Labyrinth(C-Sharp)\Sound\"+file+".wav";
     mp.Open(new Uri(url, UriKind.Relative));
     mp.Volume = 100;
 }
开发者ID:Easihh,项目名称:C-Sharp-Avenger,代码行数:7,代码来源:Sound.cs


注:本文中的MediaPlayer类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。