/// ------------------------------------------------------------------- /// <summary> /// Method name : SetVariable /// Author : Odysee /// Date : 10.11.2006 /// </summary> /// ------------------------------------------------------------------- public Error SetVariable(string strName, Int32 Value) { if (m_iVlcHandle == -1) { m_strLastError = "LibVlc is not initialzed"; return(Error.NoInit); } Error enmErr = Error.Success; try { // create vlc value vlc_value_t val = new vlc_value_t(); val.i_int = Value; // set variable enmErr = VLC_VariableSet(m_iVlcHandle, strName, val); } catch (Exception ex) { m_strLastError = ex.Message; return(Error.Execption); } if ((int)enmErr < 0) { m_strLastError = VLC_Error((int)enmErr); return(enmErr); } // OK return(Error.Success); }
public Error PressKey(string strKey) { if (m_iVlcHandle == -1) { m_strLastError = "LibVlc is not initialzed"; return(Error.NoInit); } Error enmErr = Error.Success; try { // create vlc value vlc_value_t valKey = new vlc_value_t(); // get variable enmErr = VLC_VariableGet(m_iVlcHandle, strKey, ref valKey); if (enmErr == Error.Success) {// set pressed enmErr = VLC_VariableSet(m_iVlcHandle, "key-pressed", valKey); } } catch (Exception ex) { m_strLastError = ex.Message; return(Error.Execption); } if ((int)enmErr < 0) { m_strLastError = VLC_Error((int)enmErr); return(enmErr); } // OK return(Error.Success); }
public Error PressKey(string strKey) { if (m_iVlcHandle == -1) { m_strLastError = "LibVlc is not initialzed"; return Error.NoInit; } Error enmErr = Error.Success; try { // create vlc value vlc_value_t valKey = new vlc_value_t(); // get variable enmErr = VLC_VariableGet(m_iVlcHandle, strKey, ref valKey); if (enmErr == Error.Success) {// set pressed enmErr = VLC_VariableSet(m_iVlcHandle, "key-pressed", valKey); } } catch (Exception ex) { m_strLastError = ex.Message; return Error.Execption; } if ((int)enmErr < 0) { m_strLastError = VLC_Error((int)enmErr); return enmErr; } // OK return Error.Success; }
static extern Error VLC_VariableGet(int iVLC, string Name, ref vlc_value_t value);
public VlcError GetVlcVariableChoiceList(ObjectType objectType, String propertyName, out String[] choices, out String[] choiceText) { try { using(VlcObject vobj = new VlcObject(this.vlcHandle, objectType)) { if(vobj.SubObject != IntPtr.Zero) { vlc_value_t idValues = new vlc_value_t(); vlc_value_t textValues = new vlc_value_t(); if(VlcError.Success == __var_Change(vobj.SubObject, propertyName, VarFlags.VLC_VAR_GETLIST, ref idValues, ref textValues)) { try { vlc_list_t idList = (vlc_list_t)Marshal.PtrToStructure( idValues.p_list, typeof(vlc_list_t)); vlc_list_t textList = (vlc_list_t)Marshal.PtrToStructure( textValues.p_list, typeof(vlc_list_t)); int choiceCount = idList.i_count; List<String> choiceList = new List<string>(choiceCount); List<String> choiceTextList = new List<string>(choiceCount); Dictionary<String, int> choiceDict = new Dictionary<string, int>(choiceCount); for(int index = 0; index < choiceCount; index++) { IntPtr idPtr = new IntPtr(idList.p_values.ToInt32() + index * Marshal.SizeOf(typeof(vlc_value_t))); vlc_value_t idValue = (vlc_value_t)Marshal.PtrToStructure( idPtr, typeof(vlc_value_t)); String choice = Marshal.PtrToStringAnsi(idValue.psz_name); choiceList.Add(choice); if(choiceDict.ContainsKey(choice)) { choiceDict[choice] = choiceDict[choice] + 1; } else { choiceDict[choice] = 1; } IntPtr textPtr = new IntPtr(textList.p_values.ToInt32() + index * Marshal.SizeOf(typeof(vlc_value_t))); vlc_value_t textValue = (vlc_value_t)Marshal.PtrToStructure( textPtr, typeof(vlc_value_t)); choiceTextList.Add(Marshal.PtrToStringAnsi(textValue.psz_string)); } int listIndex = 0; for(int index = 0; index < choiceCount; index++) { String choice = choiceList[listIndex]; if((choiceDict[choice] > 1) && (choiceTextList[listIndex] == null)) { choiceList.RemoveAt(listIndex); choiceTextList.RemoveAt(listIndex); choiceDict[choice] = choiceDict[choice] - 1; } else { listIndex++; } } for(int index = 0; index < choiceList.Count; index++) { if(choiceTextList[index] == null) { choiceTextList[index] = choiceList[index]; } } choices = choiceList.ToArray(); choiceText = choiceTextList.ToArray(); return VlcError.Success; } finally { __var_Change(vobj.SubObject, propertyName, VarFlags.VLC_VAR_FREELIST, ref idValues, ref textValues); } } } } } catch(Exception ex) { this.lastErrorMessage = ex.Message; } choices = new string[0]; choiceText = new string[0]; return VlcError.NoObj; }
private static int CurrentTrackChanged(IntPtr vlc, String variable, vlc_value_t old_val, vlc_value_t new_val, IntPtr param) { //Debug.WriteLine("CurrentTrackChanged: " + new_val.i_int.ToString()); GCHandle gch = (GCHandle)param; NativeLibVlc thisVlc = (NativeLibVlc)gch.Target; try { using(VlcObject vobj = new VlcObject(thisVlc.vlcHandle, ObjectType.VLC_OBJECT_INPUT)) { if(vobj.SubObject != IntPtr.Zero) { IntPtr resultString = IntPtr.Zero; input_Control(vobj.SubObject, input_query_e.INPUT_GET_INFO, Meta_information, Now_Playing, ref resultString); String nowPlaying = Marshal.PtrToStringAnsi(resultString); if(nowPlaying != thisVlc.previousNowPlaying) { thisVlc.previousNowPlaying = nowPlaying; Debug.WriteLine(String.Format("nowPlaying: {0}", nowPlaying)); thisVlc.VlcNowPlayingChanged(nowPlaying); } } } } catch(Exception ex) { thisVlc.lastErrorMessage = ex.Message; } return (int)VlcError.Success; }
public VlcError GetVlcVariableChoiceList(ObjectType objectType, String propertyName, out int[] choiceIds, out String[] choiceText) { try { using(VlcObject vobj = new VlcObject(this.vlcHandle, objectType)) { if(vobj.SubObject != IntPtr.Zero) { vlc_value_t idValues = new vlc_value_t(); vlc_value_t textValues = new vlc_value_t(); if(VlcError.Success == __var_Change(vobj.SubObject, propertyName, VarFlags.VLC_VAR_GETLIST, ref idValues, ref textValues)) { try { vlc_list_t idList = (vlc_list_t)Marshal.PtrToStructure( idValues.p_list, typeof(vlc_list_t)); vlc_list_t textList = (vlc_list_t)Marshal.PtrToStructure( textValues.p_list, typeof(vlc_list_t)); int choiceCount = idList.i_count; choiceIds = new Int32[choiceCount]; choiceText = new String[choiceCount]; for(int index = 0; index < choiceCount; index++) { IntPtr idPtr = new IntPtr(idList.p_values.ToInt32() + index * Marshal.SizeOf(typeof(vlc_value_t))); vlc_value_t idValue = (vlc_value_t)Marshal.PtrToStructure( idPtr, typeof(vlc_value_t)); choiceIds[index] = idValue.i_int; IntPtr textPtr = new IntPtr(textList.p_values.ToInt32() + index * Marshal.SizeOf(typeof(vlc_value_t))); vlc_value_t textValue = (vlc_value_t)Marshal.PtrToStructure( textPtr, typeof(vlc_value_t)); choiceText[index] = Marshal.PtrToStringAnsi(textValue.psz_string); } return VlcError.Success; } finally { __var_Change(vobj.SubObject, propertyName, VarFlags.VLC_VAR_FREELIST, ref idValues, ref textValues); } } } } } catch(Exception ex) { this.lastErrorMessage = ex.Message; } choiceIds = new int[0]; choiceText = new string[0]; return VlcError.NoObj; }
public VlcError SetVlcObjectFloat(ObjectType objectType, String propertyName, float value) { try { using(VlcObject vobj = new VlcObject(this.vlcHandle, objectType)) { if(vobj.SubObject != IntPtr.Zero) { vlc_value_t floatValue = new vlc_value_t(); floatValue.f_float = value; return __var_Set(vobj.SubObject, propertyName, floatValue); } } } catch(Exception ex) { this.lastErrorMessage = ex.Message; } return VlcError.NoObj; }
public String GetVlcObjectString(ObjectType objectType, String propertyName, String errorReturn) { try { using(VlcObject vobj = new VlcObject(this.vlcHandle, objectType)) { vlc_value_t stringValue = new vlc_value_t(); if((vobj.SubObject != IntPtr.Zero) && (VlcError.Success == __var_Get(vobj.SubObject, propertyName, ref stringValue))) { return Marshal.PtrToStringAnsi(stringValue.psz_string); } } } catch(Exception ex) { this.lastErrorMessage = ex.Message; } return errorReturn; }
public long GetVlcObjectLong(ObjectType objectType, String propertyName, long errorReturn) { try { using(VlcObject vobj = new VlcObject(this.vlcHandle, objectType)) { vlc_value_t longValue = new vlc_value_t(); if((vobj.SubObject != IntPtr.Zero) && (VlcError.Success == __var_Get(vobj.SubObject, propertyName, ref longValue))) { return longValue.i_time; } } } catch(Exception ex) { this.lastErrorMessage = ex.Message; } return errorReturn; }
public float GetVlcObjectFloat(ObjectType objectType, String propertyName, float errorReturn) { try { using(VlcObject vobj = new VlcObject(this.vlcHandle, objectType)) { vlc_value_t floatValue = new vlc_value_t(); if((vobj.SubObject != IntPtr.Zero) && (VlcError.Success == __var_Get(vobj.SubObject, propertyName, ref floatValue))) { return floatValue.f_float; } } } catch(Exception ex) { this.lastErrorMessage = ex.Message; } return errorReturn; }
static extern VlcError __var_Change(IntPtr p_this, String name, VarFlags varFlags, ref vlc_value_t value, ref vlc_value_t value2);
static extern VlcError __var_Get(IntPtr p_this, String name, ref vlc_value_t value);
static extern VlcError __var_Set(IntPtr p_vlc, String name, vlc_value_t value);
public Error SetVariable(string strName, Int32 Value) { if (m_iVlcHandle == -1) { m_strLastError = "LibVlc is not initialzed"; return Error.NoInit; } Error enmErr = Error.Success; try { // create vlc value vlc_value_t val = new vlc_value_t(); val.i_int = Value; // set variable enmErr = VLC_VariableSet(m_iVlcHandle, strName, val); } catch (Exception ex) { m_strLastError = ex.Message; return Error.Execption; } if ((int)enmErr < 0) { m_strLastError = VLC_Error((int)enmErr); return enmErr; } // OK return Error.Success; }
public VlcError SetVlcObjectString(ObjectType objectType, String propertyName, String value) { try { using(VlcObject vobj = new VlcObject(this.vlcHandle, objectType)) { if(vobj.SubObject != IntPtr.Zero) { vlc_value_t stringValue = new vlc_value_t(); IntPtr valuePtr = Marshal.StringToCoTaskMemAnsi(value); stringValue.psz_string = valuePtr; VlcError ret = __var_Set(vobj.SubObject, propertyName, stringValue); Marshal.ZeroFreeCoTaskMemAnsi(valuePtr); return ret; } } } catch(Exception ex) { this.lastErrorMessage = ex.Message; } return VlcError.NoObj; }
static extern Error VLC_VariableSet(int iVLC, string Name, vlc_value_t value);
private static extern Error VLC_VariableSet(int iVLC, string Name, vlc_value_t value);