How to play a video? (1 Viewer)

kaybe

Retired Team Member
  • Premium Supporter
  • May 13, 2005
    85
    0
    Germany
    Hello, I am writing a plugin and want to show a video in the middle of the screen.
    The problem I have is, that there is no picture, only sound.
    Perhaps someone could help me.
    I put my code in the plugin template, so its easy to read.
    To start the player you have to push buttonOne.


    Code:
    using System;
    using System.Windows.Forms;
    using MediaPortal.GUI.Library;
    using MediaPortal.Player;
    using MediaPortal.Dialogs;
    namespace OurPlugin
    {
    
    	public class Class1 : GUIWindow, ISetupForm
    	{
    		[SkinControlAttribute(2)]
    		protected GUIButtonControl buttonOne = null;
    		[SkinControlAttribute(3)]
    		protected GUIButtonControl buttonTwo = null;
    		[SkinControlAttribute(99)]
    		protected GUIVideoControl contr = null;
    
    		public Class1()
    		{
    
    		}
    
    		#region ISetupForm Members
    
    		// Returns the name of the plugin which is shown in the plugin menu
    		public string PluginName()
    		{
    			return "MyFirstPlugin";
    		}
    		// Returns the description of the plugin is shown in the plugin menu
    		public string Description()
    		{
    			return "My First plugin tutorial";
    		}
    
    		// Returns the author of the plugin which is shown in the plugin menu
    		public string Author()
    		{
    			return "kaybe";
    		}
    
    		// show the setup dialog
    		public void ShowPlugin()
    		{
    			MessageBox.Show("Nothing to configure, this is just an example");
    		}
    
    		// Indicates whether plugin can be enabled/disabled
    		public bool CanEnable()
    		{
    			return true;
    		}
    		// get ID of windowplugin belonging to this setup
    		public int GetWindowId()
    		{
    			return 5678;
    		}
    		// Indicates if plugin is enabled by default;
    		public bool DefaultEnabled()
    		{
    			return true;
    		}
    
    		// indicates if a plugin has its own setup screen
    		public bool HasSetup()
    		{
    			return true;
    		}
    		
    		public bool GetHome(out string strButtonText, out string strButtonImage, out string strButtonImageFocus, out string strPictureImage)
    		{
    			strButtonText = PluginName();
    			strButtonImage = String.Empty;
    			strButtonImageFocus = String.Empty;
    			strPictureImage = String.Empty;
    			return true;
    		}
    		#endregion
    
    		public override int GetID
    		{
    			get
    			{
    				return 5678;
    			}
    			set
    			{
    			}
    		}
    
    		public override bool Init()
    		{
    			return Load(GUIGraphicsContext.Skin + @"\VorlageScreen.xml");
    		}
    
    
    		protected override void OnClicked(int controlId, GUIControl control, MediaPortal.GUI.Library.Action.ActionType actionType)
    		{
    			if (control == buttonOne)
    				OnButtonOne();
    			if (control == buttonTwo)
    				OnButtonTwo();
    			base.OnClicked(controlId, control, actionType);
    		}
    
    		private void OnButtonOne()
    		{
    			if (contr != null)
    				GUIGraphicsContext.VideoWindow = new System.Drawing.Rectangle(contr.XPosition, contr.YPosition, contr.Width, contr.Height);
    			g_Player.Play(@"d:\video\test.dvr-ms");
    		}
    
    		private void OnButtonTwo()
    		{
    			GUIDialogOK dlg = (GUIDialogOK)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_OK);
    			dlg.SetHeading("Button has been pressed");
    			dlg.SetLine(1, "You pressed button 2");
    			dlg.SetLine(2, String.Empty);
    			dlg.SetLine(3, String.Empty);
    			dlg.DoModal(GUIWindowManager.ActiveWindow);
    		}
    	}
    }

    and the screenfile

    Code:
    <window>
    	<id>5678</id>
    	<defaultcontrol>2</defaultcontrol>
    	<allowoverlay>no</allowoverlay>
    	<controls>
    		<control>
    			<description>BackGround</description>
    			<type>image</type>
    			<id>1</id>
    			<posX>0</posX>
    			<posY>0</posY>
    			<width>720</width>
    			<height>576</height>
    			<texture>background.png</texture>
    		</control>
    		<control>
    			<description>an Image</description>
    			<type>image</type>
    			<id>1</id>
    			<posX>75</posX>
    			<posY>370</posY>
    			<texture>hover_my videos.png</texture>
    		</control>
    		<control>
    			<description>text label</description>
    			<type>label</type>
    			<id>1</id>
    			<posX>250</posX>
    			<posY>70</posY>
    			<label>Some text</label>
    			<font>font16</font>
    			<align>right</align>
    			<textcolor>ffffffff</textcolor>
    		</control>
    		<control>
    			<description>Try Me</description>
    			<type>button</type>
    			<id>2</id>
    			<posX>60</posX>
    			<posY>97</posY>
    			<label>Try Me</label>
    			<onleft>2</onleft>
    			<onright>2</onright>
    			<onup>2</onup>
    			<ondown>3</ondown>
    		</control>
    		<control>
    			<description>Or Me</description>
    			<type>button</type>
    			<id>3</id>
    			<posX>60</posX>
    			<posY>131</posY>
    			<label>Or Me</label>
    			<onleft>2</onleft>
    			<onright>2</onright>
    			<onup>2</onup>
    			<ondown>2</ondown>
    		</control>
    		<control>
    			<type>videowindow</type>
    			<description>video window</description>
    			<id>99</id>
    			<posX>300</posX>
    			<posY>107</posY>
    			<width>220</width>
    			<height>184</height>
    			<colordiffuse>ffffffff</colordiffuse>
    			<onleft>2</onleft>
    			<onright>2</onright>
    		</control>
    	</controls>
    </window>

    The plugin is working, except I have no videopicture, the videowindow stays black, I only hear sound.
    I tried to play the file with the video module, no problem.
    There is a picture and sound.

    Perhaps I miss something to initialise or something else, but I dont know what.
     

    ASiDiE

    Retired Team Member
  • Premium Supporter
  • January 14, 2005
    902
    5
    USA
    I know nothing about code or anything like that, and I am always open to new plug-ins. I would just like to know what this plug-in is going to do different that the way we play videos currently?
     

    Rudolph

    Portal Member
    December 18, 2005
    32
    0
    Nijkerk, Netherlands
    Your code shows video on my system in VMR 7 mode,
    as you can see in the log file below.

    however it seems to work only with VMR7, not with VMR9, that is shown in mediaportal log 2.
    I hope it helped.


    9-2-2006 22:54:15 window:OurPlugin.Class1 init
    9-2-2006 22:54:16 key:13 0xD (2)
    9-2-2006 22:54:16 player: file is not live tv, so stop timeshifting:C:\download\hp\mvn-hp401\mvn-hp401.avi
    9-2-2006 22:54:16 g_Player.Play(C:\download\hp\mvn-hp401\mvn-hp401.avi)
    9-2-2006 22:54:16 Loading external players plugins
    9-2-2006 22:54:16 found plugin:MediaPortal.ITunesPlayer.ITunesPlugin in plugins\ExternalPlayers\ExternalPlayers.dll
    9-2-2006 22:54:16 player:iTunes audio player. author: Frodo
    9-2-2006 22:54:16 found plugin:MediaPortal.FoobarPlugin.FoobarPlugin in plugins\ExternalPlayers\ExternalPlayers.dll
    9-2-2006 22:54:16 player:Foobar2000. author: int_20h
    9-2-2006 22:54:16 found plugin:MediaPortal.WinampPlayer.WinampPlugin in plugins\ExternalPlayers\ExternalPlayers.dll
    9-2-2006 22:54:16 player:Winamp. author: int_20h
    9-2-2006 22:54:16 VideoPlayer:play C:\download\hp\mvn-hp401\mvn-hp401.avi
    9-2-2006 22:54:16 VMR7Helper:AddVMR7
    9-2-2006 22:54:16 playingFalse radio:False
    9-2-2006 22:54:16 add filter:Default DirectSound Device to graph clock:Default DirectSound Device
    9-2-2006 22:54:17 added filter:Default DirectSound Device to graph
    9-2-2006 22:54:18 overlay: video WxH : 640x272
    9-2-2006 22:54:18 overlay: video AR : 640:272
    9-2-2006 22:54:18 overlay: screen WxH : 720x576
    9-2-2006 22:54:18 overlay: AR type : Normal
    9-2-2006 22:54:18 overlay: PixelRatio : 1
    9-2-2006 22:54:18 overlay: src : (0,0)-(640,272)
    9-2-2006 22:54:18 overlay: dst : (0,135)-(720,441)
    9-2-2006 22:54:18 VideoPlayer:Duration:4289,2
    9-2-2006 22:54:18 g_Player.OnStarted() C:\download\hp\mvn-hp401\mvn-hp401.avi media:Video
    9-2-2006 22:54:18 opening video database


    with VMR9 this is the result

    9-2-2006 23:11:25 window:OurPlugin.Class1 init
    9-2-2006 23:11:26 player: file is not live tv, so stop timeshifting:C:\download\hp\mvn-hp401\mvn-hp401.avi
    9-2-2006 23:11:26 g_Player.Play(C:\download\hp\mvn-hp401\mvn-hp401.avi)
    9-2-2006 23:11:26 Loading external players plugins
    9-2-2006 23:11:26 found plugin:MediaPortal.ITunesPlayer.ITunesPlugin in plugins\ExternalPlayers\ExternalPlayers.dll
    9-2-2006 23:11:26 player:iTunes audio player. author: Frodo
    9-2-2006 23:11:26 found plugin:MediaPortal.FoobarPlugin.FoobarPlugin in plugins\ExternalPlayers\ExternalPlayers.dll
    9-2-2006 23:11:26 player:Foobar2000. author: int_20h
    9-2-2006 23:11:26 found plugin:MediaPortal.WinampPlayer.WinampPlugin in plugins\ExternalPlayers\ExternalPlayers.dll
    9-2-2006 23:11:26 player:Winamp. author: int_20h
    9-2-2006 23:11:26 VideoPlayer:play C:\download\hp\mvn-hp401\mvn-hp401.avi
    9-2-2006 23:11:27 playingFalse radio:False
    9-2-2006 23:11:27 VideoPlayer9:exception while creating DShow graph Creating an instance of the COM component with CLSID {51B4ABF3-748F-4E3B-A276-C828330E926A} from the IClassFactory failed due to the following error: 80040273. at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandle& ctor, Boolean& bNeedSecurityCheck)
    at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean fillCache)
    at System.RuntimeType.CreateInstanceImpl(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean fillCache)
    at System.Activator.CreateInstance(Type type, Boolean nonPublic)
    at MediaPortal.Player.VMR9Util.AddVMR9(IGraphBuilder graphBuilder)
    at MediaPortal.Player.VideoPlayerVMR9.GetInterfaces()
    9-2-2006 23:11:27 player:ended
    9-2-2006 23:11:27 VideoPlayer9:cleanup DShow graph
    9-2-2006 23:11:27 window:MediaPortal.Dialogs.GUIDialogOK init
    9-2-2006 23:11:29 window:MediaPortal.Dialogs.GUIDialogOK init
    9-2-2006 23:11:32 player: file is not live tv, so stop timeshifting:C:\download\hp\mvn-hp401\mvn-hp401.avi
    9-2-2006 23:11:32 g_Player.Play(C:\download\hp\mvn-hp401\mvn-hp401.avi)
    9-2-2006 23:11:32 VideoPlayer:play C:\download\hp\mvn-hp401\mvn-hp401.avi
    9-2-2006 23:11:32 VideoPlayer9:exception while creating DShow graph Creating an instance of the COM component with CLSID {51B4ABF3-748F-4E3B-A276-C828330E926A} from the IClassFactory failed due to the following error: 80040273. at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandle& ctor, Boolean& bNeedSecurityCheck)
    at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean fillCache)
    at System.RuntimeType.CreateInstanceImpl(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean fillCache)
    at System.Activator.CreateInstance(Type type, Boolean nonPublic)
    at MediaPortal.Player.VMR9Util.AddVMR9(IGraphBuilder graphBuilder)
    at MediaPortal.Player.VideoPlayerVMR9.GetInterfaces()
    9-2-2006 23:11:32 player:ended
     

    kaybe

    Retired Team Member
  • Premium Supporter
  • May 13, 2005
    85
    0
    Germany
    mmh, not really. Its really curious.
    I was thinking about something with the renderer,
    but I have no idea what I can do.
    But thanks for your help.
     

    Ralph

    Retired Team Member
  • Premium Supporter
  • May 13, 2005
    692
    8
    Germany
    Home Country
    Germany Germany
    Same for me. I just can see the video when using vmr7.
    It seems to be something with vmr9?
    Maybe one of the devs can take a short look into that and help you out?

    Regards
    Ralph
     

    Users who are viewing this thread

    Top Bottom