• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# MediaPlayer类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: Play

 public void Play(string filename, Action<Exception> failed = null)
 {
     Application.Current.Dispatcher.BeginInvoke(new Action(() =>
     {
         try
         {
             var path = string.Format(soundFilePath, "wav", filename);
             if (!System.IO.File.Exists(path))
             {
                 path = string.Format(soundFilePath, "mp3", filename);
             }
             if (!System.IO.File.Exists(path))
             {
                 throw new System.IO.FileNotFoundException();
             }
             if (mediaPlayer == null)
             {
                 mediaPlayer = new MediaPlayer { Volume = 1 };
             }
             mediaPlayer.Open(new Uri(path, UriKind.Absolute));
             mediaPlayer.Play();
         }
         catch (Exception ex)
         {
             AMing.Plugins.Core.GenericMessager.Current.SendToException(ex);
             if (failed != null)
                 failed(ex);
         }
     }));
 }
开发者ID:vista3344,项目名称:KcvPlugins,代码行数:30,代码来源:SoundsModules.cs


示例17: PlayVideo

		private void PlayVideo ()
		{
			try {
				if (path == "") {
					// Tell the user to provide an audio file URL.
					Toast.MakeText (this, "Please edit MediaPlayer Activity, " + "and set the path variable to your media file path." + " Your media file must be stored on sdcard.", ToastLength.Long).Show ();
					return;
				}
				mediaPlayer = new MediaPlayer (this);
				mediaPlayer.SetDataSource (path);
				mediaPlayer.SetDisplay (sholder);
				mediaPlayer.PrepareAsync ();
				mediaPlayer.SetOnPreparedListener (this);

				mediaPlayer.SetOnTimedTextListener (this);

				// TODO Auto-generated catch block
			} catch (IllegalArgumentException e) {
				// TODO Auto-generated catch block
				e.PrintStackTrace ();
			} catch (IllegalStateException e) {
				// TODO Auto-generated catch block
				e.PrintStackTrace ();
			} catch (SecurityException e) {
				// TODO Auto-generated catch block
				e.PrintStackTrace ();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.PrintStackTrace ();
			}
		}
开发者ID:shaxxx,项目名称:Xamarin.Vitamio,代码行数:31,代码来源:MediaPlayerSubtitle.cs


示例18: OnInfo

		public bool OnInfo (MediaPlayer mp, int what, int extra)
		{
			switch (what) {
			case MediaPlayer.MediaInfoBufferingStart:
				if (mVideoView.IsPlaying) {
					mVideoView.Pause ();
					pb.Visibility = ViewStates.Visible;
					downloadRateView.Text = "";
					loadRateView.Text = "";
					downloadRateView.Visibility = ViewStates.Visible;
					loadRateView.Visibility = ViewStates.Visible;

				}
				break;
			case MediaPlayer.MediaInfoBufferingEnd:
				mVideoView.Start ();
				pb.Visibility = ViewStates.Gone;
				downloadRateView.Visibility = ViewStates.Gone;
				loadRateView.Visibility = ViewStates.Gone;
				break;
			case MediaPlayer.MediaInfoDownloadRateChanged:
				downloadRateView.Text = "" + extra + "kb/s" + "  ";
				break;
			}
			return true;
		}
开发者ID:shaxxx,项目名称:Xamarin.Vitamio,代码行数:26,代码来源:VideoViewBuffer.cs


示例19: MainWindow

        public MainWindow()
        {
            InitializeComponent();
            _thisWindow = this;
            BackgroundMusicPlayer = new MediaPlayer();

            #region Music Stuff

            var uri = new Uri(BasePath, "Resources/intro.mp3");
            var mediaPlayer = MainWindow.BackgroundMusicPlayer;
            mediaPlayer.Open(uri);
            mediaPlayer.Play();

            #endregion

            CharacterSelect selectScreen = new CharacterSelect();

            selectScreen.ShowDialog();

            #region Music Stuff

            uri = new Uri(BasePath, "Resources/soundtrack.mp3");
            mediaPlayer.Open(uri);
            mediaPlayer.Play();
            BackgroundPosition = mediaPlayer.Position;

            #endregion

            Start();
        }
开发者ID:JARVADAHUT,项目名称:HerosAndMonstersGUI,代码行数:30,代码来源:MainWindow.xaml.cs


示例20: MediaPlayer_MediaOpened

 /// <summary>
 /// Fired when MediaPlayer is ready to play the track
 /// </summary>
 void MediaPlayer_MediaOpened(MediaPlayer sender, object args)
 {
     // wait for media to be ready
     sender.Play();
     Debug.WriteLine("New Track" + this.CurrentTrackName);
     TrackChanged.Invoke(this, CurrentTrackName);
 }
开发者ID:MichaelAi,项目名称:Aural-Player,代码行数:10,代码来源:BackgroundPlaylist.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# MediaPlayerLauncher类代码示例发布时间:2022-05-24
下一篇:
C# MediaItem类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap