MediaPortal Forums HTPC/MediaCenter

Go Back   MediaPortal Forum » MediaPortal 1 » Help on Development » General Development (no feature request here!)


General Development (no feature request here!) You were able to fix an issue, or improved a feature? Post it here.

Reply
 
Thread Tools Display Modes
Old 2004-09-11, 18:13   #1 (permalink)
Retired Team Member
 
Join Date: Sep 2004
Location: Canada
Posts: 215
Thanks: 0
Thanked 0 Times in 0 Posts


Default Calling g_Player.Play from timer elapsed event not working

I have a timer elapsed event calling Player.g_Player.Play but it doesn't seem to fully work.

I've verified that the player works just calling Play from a button but when this is called from a TimerElasped event it doesn't work. It seems to stall.

Here is the output from the log:

11/09/2004 1:01:35 PM Player.Play(http://64.236.34.67:80/stream/8022)
11/09/2004 1:01:35 PM Loading external players plugins
11/09/2004 1:01:35 PM found plugin:MediaPortal.FoobarPlugin.FoobarPlugin in plugins\ExternalPlayers\FoobarExternalPlayer.dll
11/09/2004 1:01:35 PM player:Foobar2000. author: int_20h
11/09/2004 1:01:35 PM found plugin:MediaPortal.WinampPlayer.WinampPlugin in plugins\ExternalPlayers\WinampExternalPlayer.dll
11/09/2004 1:01:35 PM player:Winamp. author: int_20h

Any help would is appreciated.
devo is offline   Reply With Quote
Old 2004-09-11, 18:48   #2 (permalink)
Retired Team Member
 
Join Date: Sep 2004
Location: Canada
Posts: 215
Thanks: 0
Thanked 0 Times in 0 Posts


Default

steping through the code it makes it to this line then I can't step past it.

Line 63: m_player = new AxMicrosoft.MediaPlayer.Interop.AxWindowsMediaPlay er();

in AudioPlayerWMP9.cs

no exception happens though.
devo is offline   Reply With Quote
Old 2004-09-11, 19:25   #3 (permalink)
Portal Member
 
Mars Warrior's Avatar
 
Join Date: Aug 2004
Location: Airy Crater, Mars
Posts: 136
Thanks: 0
Thanked 0 Times in 0 Posts


Default

Might it be that the calls are made in a different context?

I don't know how you handle the timer event and call the Play method. Is it from that timer event callback procedure, main program, UI dialog...

Just guessing
__________________
Earth - The Final Frontier
Mars Warrior is offline   Reply With Quote
Old 2004-09-11, 20:03   #4 (permalink)
Retired Team Member
 
Join Date: Sep 2004
Location: Canada
Posts: 215
Thanks: 0
Thanked 0 Times in 0 Posts


Default

Quote:
Originally Posted by Mars Warrior
Might it be that the calls are made in a different context?

I don't know how you handle the timer event and call the Play method. Is it from that timer event callback procedure, main program, UI dialog...

Just guessing
Here is the event code

Code:
public void OnTimer(Object sender, ElapsedEventArgs e)
		{
			if(sender == _AlarmClock)
			{
				GUISpinControl ctlHour = (GUISpinControl)GetControl((int)Controls.CONTROL_ALARMTIMEHOUR);
				GUISpinControl ctlMinute = (GUISpinControl)GetControl((int)Controls.CONTROL_ALARMTIMEMINUTE);
	
				DateTime dtNow = DateTime.Now;
			
				if( dtNow.Hour == ctlHour.Value && dtNow.Minute == ctlMinute.Value)
				{
					_AlarmClock.Enabled = false;
					Player.g_Player.Play(_SongPath);
					GUIControl.SetControlLabel(GetID, (int)Controls.CONTROL_LABELSONGPATH,g_Player.Playing.ToString());
				}
			}
			
		}
devo is offline   Reply With Quote
Old 2004-09-11, 20:52   #5 (permalink)
Portal Member
 
Mars Warrior's Avatar
 
Join Date: Aug 2004
Location: Airy Crater, Mars
Posts: 136
Thanks: 0
Thanked 0 Times in 0 Posts


Default

Aha. If hitting play from the control does work, than it might indeed be some kind of context problem.

You might check out the Control.BeginInvoke Method (Delegate, Object[]) and EndInvoke methods which:

The delegate is called asynchronously, and this method returns immediately. You can call this method from any thread, even the thread that owns the control's handle. If the control's handle does not exist yet, this method searches up the control's parent chain until it finds a control or form that does have a window handle. If no appropriate handle can be found, BeginInvoke will throw an exception. Exceptions within the delegate method are considered untrapped and will be sent to the application's untrapped exception handler.

Note The BeginInvoke method calls the specified delegate back on a different thread pool thread. You should not block a thread pool thread for any length of time.
Note There are four methods on a control that are safe to call from any thread: Invoke, BeginInvoke, EndInvoke, and CreateGraphics. For all other method calls, you should use one of the invoke methods to marshal the call to the control's thread.


Altough I can't say for sure that it is INDEED a context problem, but if it is the BeginInvoke should solve it
__________________
Earth - The Final Frontier
Mars Warrior is offline   Reply With Quote
Old 2004-09-11, 21:28   #6 (permalink)
Retired Team Member
 
Join Date: Sep 2004
Location: Canada
Posts: 215
Thanks: 0
Thanked 0 Times in 0 Posts


Default

thanks for all your help.... it seems I was using a server timer from System.Timers.Timer namespace. I switched this over to a windows forms timer
System.Windows.Forms.Timer and it all works great now!!

On with the coding now
devo is offline   Reply With Quote
Old 2004-09-11, 23:13   #7 (permalink)
Portal Member
 
Mars Warrior's Avatar
 
Join Date: Aug 2004
Location: Airy Crater, Mars
Posts: 136
Thanks: 0
Thanked 0 Times in 0 Posts


Default

Quote:
Originally Posted by devo
thanks for all your help.... it seems I was using a server timer from System.Timers.Timer namespace. I switched this over to a windows forms timer
System.Windows.Forms.Timer and it all works great now!!

On with the coding now
So indirectly some kind of (thread) context problem. Well get on with the coding!
And BTW, for what will it be used??
__________________
Earth - The Final Frontier
Mars Warrior is offline   Reply With Quote
Old 2004-09-11, 23:31   #8 (permalink)
Retired Team Member
 
Join Date: Sep 2004
Location: Canada
Posts: 215
Thanks: 0
Thanked 0 Times in 0 Posts


Default

Quote:
Originally Posted by Mars Warrior
Quote:
Originally Posted by devo
thanks for all your help.... it seems I was using a server timer from System.Timers.Timer namespace. I switched this over to a windows forms timer
System.Windows.Forms.Timer and it all works great now!!

On with the coding now
So indirectly some kind of (thread) context problem. Well get on with the coding!
And BTW, for what will it be used??
Ya exactly, I was trying a few different things like creating a new worker thread but that didn't work either. I am glad it works now though.

I am working on an alarm plugin. I thought it would be a good way to get my hands dirty with the project and learn the architecture.
devo is offline   Reply With Quote
Reply

Bookmarks

Tags
calling, elapsed, event, gplayerplay, timer, working

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Auto Resume After Suspend Procedure Dado The old Bugreport Forum 28 2006-04-23 17:59
PVR Scheduler: cant make it work ethanx Codecs, External Players 1 2006-03-19 23:42
Hauppauge remote, not working. Haplo General Support 17 2006-02-18 04:24
Hauppauge 45 Buttons in My Video Fullscreen/back button bug miljbee The old Bugreport Forum 4 2006-02-10 18:51
Mediaportal crashing when power scheduler is activated Adrian2M General Support 0 2005-12-30 16:07


All times are GMT +1. The time now is 01:15.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0 Protected by Akismet Blog with WordPress