TVDatabase.GetRecordedTV question (1 Viewer)

tourettes

Retired Team Member
  • Premium Supporter
  • January 7, 2005
    17,301
    4,800
    You are using a wrong thread to start / stop the playback

    2009-06-13 09:27:10.744800 [Info.][11]: VMR9: Dispose() from wrong thread

    All graph related code must be run inside the main MediaPortal thread.
     

    pilehave

    Community Skin Designer
  • Premium Supporter
  • April 2, 2008
    2,566
    521
    Hornslet
    Home Country
    Denmark Denmark
    • Thread starter
    • Moderator
    • #12
    Would the anwser to this problem be something like this, found in the code of the TVPlugin?

    Code:
    work = new Work(new DoWorkHandler(this.PerformRequest));
            work.ThreadPriority = ThreadPriority.BelowNormal;
            GlobalServiceProvider.Get<IThreadPool>().Add(work, QueuePriority.Low);
     

    pilehave

    Community Skin Designer
  • Premium Supporter
  • April 2, 2008
    2,566
    521
    Hornslet
    Home Country
    Denmark Denmark
    • Thread starter
    • Moderator
    • #13
    I can avoid crashes by commenting out g_Player.Stop(true); so as you pointed out this is (one of) the problem(s).

    Now the video starts playback (sometimes at least) but a new Active Movie Window pops up/under and controls are dead. Guess I need some way to put control of the new stream in the hands of MediaPortal?

    Sometimes I get like 3-4 FFDShow icons in the task-manager, so definately some graphs hanging...

    I'm here tomorrow too if anyone can help, thanks a bunch so far :)
     

    tourettes

    Retired Team Member
  • Premium Supporter
  • January 7, 2005
    17,301
    4,800
    I can avoid crashes by commenting out g_Player.Stop(true); so as you pointed out this is (one of) the problem(s).

    Now the video starts playback (sometimes at least) but a new Active Movie Window pops up/under and controls are dead. Guess I need some way to put control of the new stream in the hands of MediaPortal?

    Sometimes I get like 3-4 FFDShow icons in the task-manager, so definately some graphs hanging...

    I'm here tomorrow too if anyone can help, thanks a bunch so far :)

    Not stopping the graph leaves the graph alive... and those other issues you are seeing are caused most likely by that (MP cannot play multiple videos at once -> active video window).
     

    pilehave

    Community Skin Designer
  • Premium Supporter
  • April 2, 2008
    2,566
    521
    Hornslet
    Home Country
    Denmark Denmark
    • Thread starter
    • Moderator
    • #15
    I tried going through the MovingPictures code to see if I missed the point here, but I don't see any specific thread-handling stopping playback? Is it because it is a window-plugin, and I'm doing a process-plugin?
     

    pilehave

    Community Skin Designer
  • Premium Supporter
  • April 2, 2008
    2,566
    521
    Hornslet
    Home Country
    Denmark Denmark
    • Thread starter
    • Moderator
    • #16
    OK, let me refrase ;)

    How do I stop the player already running, so I can start my own?

    In all the other plugins I have studied it's just a simple g_Player.Stop() that is called? Can I in any way even stop a player from a process plugin, that is running in a window-plugin?
     

    pilehave

    Community Skin Designer
  • Premium Supporter
  • April 2, 2008
    2,566
    521
    Hornslet
    Home Country
    Denmark Denmark
    • Thread starter
    • Moderator
    • #17
    I could really use some guidance as this is driving me mad :(

    How can I dispose the graph to clean up things and start my own?
     

    dvdfreak

    Portal Pro
    June 13, 2006
    979
    178
    Home Country
    Belgium Belgium
    That didn't work out actually, I had incorrectly misinterpreted the problem as a server-side problem while it was a client-side one with g_Player.

    What I did to fix this was use GUIWindowManager.SendThreadCallbackAndWait() to make sure the code in question runs on the main MP thread.
     

    pilehave

    Community Skin Designer
  • Premium Supporter
  • April 2, 2008
    2,566
    521
    Hornslet
    Home Country
    Denmark Denmark
    • Thread starter
    • Moderator
    • #20
    Oh, well that's pretty similar to what i stubled around with late last night, and it looks like it almost works, although I loose something in the process, as I cannot control playback or go back and forth between windows...my code is called like this:

    Code:
    GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU);
                    if (dlg == null) return;
                    dlg.Reset();
                    dlg.SetHeading("Recorded TV");
                    int counter = 0;
    
                    IList<Recording> recordings = Recording.ListAll();
                    foreach (Recording rec in recordings)
                    {
                        counter++;
                        GUIListItem item = new GUIListItem();
                        item.Label = rec.StartTime.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat);
                        item.Label2 = rec.Title;
                        item.PinImage = "";
                        dlg.Add(item);
                    }
    
    dlg.DoModal(GUIWindowManager.ActiveWindow);
    if (dlg.SelectedId > 0)
    {
    //I can track in the log that this works as expected, which is to read the filename of the selected recording
    GUIWindowManager.SendThreadCallbackAndWait(StopPlayback, 0, 0, recordings[dlg.SelectedId].FileName);
    }

    (recordings[dlg.SelectedId].FileName is an object containing the actual filename, something like D:\MP Recordings\MyRecording.ts)

    The function called, looks like this:

    Code:
            private int StopPlayback(int p1, int p2, object d)
            {
                if (g_Player.Playing)
                {
                    g_Player.Stop(true);
                }
                string fileName = d.ToString();
                string fileRTSP = RemoteControl.Instance.GetUrlForFile(fileName);
                Log.Info("PowerPlay - try to fetch stream " + fileRTSP); //This works
                if (g_Player.Play(fileRTSP, g_Player.MediaType.Recording))
                {
                    g_Player.SeekAbsolute(0);
                    g_Player.ShowFullScreenWindow();
                }
    
                return 0;
            }

    This is stolen from somewhere in MediaPortal and looks like it could work, and playback is actually started in fullscreen, but it is like as if focus is lost somehow...I can pause the new stream, will try and post logs when I get home (no tv-card at work!).

    One issue with the above code is that it is RTSP only (multiseat) but I don't really care as TVE2 is being dumped anyway.
     

    Users who are viewing this thread

    Top Bottom