private void OnArClicked(object o, EventArgs e) { VlcObject vo = _v.VlcObject.FindObject(VlcObjectType.VOut, VlcObjectSearchMode.Child); vo.SetStringValue("aspect-ratio", ""); //_v.Input.VideoAspectRatio = ""; }
private void OnPauseClicked(object o, EventArgs e) { VlcObject vout = _v.VlcObject.FindObject(VlcObjectType.VOut, VlcObjectSearchMode.Child); IList <string> choices; vout.GetListChoices("deinterlace", out choices); _v.VlcPlaylist.Pause(); }
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; }
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 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; }
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 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 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; }
public VlcError Stop() { try { using(VlcObject vobj = new VlcObject(this.vlcHandle, ObjectType.VLC_OBJECT_PLAYLIST)) { if(vobj.SubObject != IntPtr.Zero) { return playlist_LockControl(vobj.SubObject, playlist_command.PLAYLIST_STOP); } else { return VlcError.NoObj; } } } catch(Exception ex) { this.lastErrorMessage = ex.Message; return VlcError.Exception; } }
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; }
private void UnhookPlaylistChanges() { using(VlcObject vlc = new VlcObject(this.vlcHandle, ObjectType.VLC_OBJECT_PLAYLIST)) { if(vlc.SubObject != IntPtr.Zero) { __var_DelCallback(vlc.SubObject, Playlist_Current, this.currentTrackCallback, (IntPtr)this.gch); } } this.gch.Free(); }
private void HookPlaylistChanges() { using(VlcObject vlc = new VlcObject(this.vlcHandle, ObjectType.VLC_OBJECT_PLAYLIST)) { if(vlc.SubObject != IntPtr.Zero) { this.gch = GCHandle.Alloc(this); this.currentTrackCallback = new VarChangedCallback(CurrentTrackChanged); int isSet = __var_AddCallback(vlc.SubObject, Playlist_Current, this.currentTrackCallback, (IntPtr)this.gch); //Debug.WriteLine("__var_AddCallback playlistObject = " + isSet.ToString()); } } }
public VlcError SetConfigVariable(String name, String value) { using(VlcObject vlc = new VlcObject(this.vlcHandle, ObjectType.VLC_OBJECT_VLC)) { if(IntPtr.Zero == vlc.SubObject) { return VlcError.NoObj; } IntPtr p_item = config_FindConfig(vlc.SubObject, name); if(IntPtr.Zero == p_item) { return VlcError.NoVar; } try { module_config_t mod = (module_config_t)Marshal.PtrToStructure(p_item, typeof(module_config_t)); switch(mod.i_type) { case CONFIG_ITEM.CONFIG_ITEM_BOOL: { bool boolResult; if(Boolean.TryParse(value, out boolResult)) { __config_PutInt(vlc.SubObject, name, boolResult ? 1 : 0); } else { return VlcError.BadVar; } } break; case CONFIG_ITEM.CONFIG_ITEM_INTEGER: { int intResult; if(Int32.TryParse(value, out intResult)) { __config_PutInt(vlc.SubObject, name, intResult); } else { return VlcError.BadVar; } } break; case CONFIG_ITEM.CONFIG_ITEM_FLOAT: { float floatResult; if(Single.TryParse(value, out floatResult)) { __config_PutFloat(vlc.SubObject, name, floatResult); } else { return VlcError.BadVar; } } break; case CONFIG_ITEM.CONFIG_ITEM_STRING: __config_PutPsz(vlc.SubObject, name, value); break; default: return VlcError.BadVar; } } catch(Exception e) { this.lastErrorMessage = e.Message; return VlcError.Exception; } } return VlcError.Success; }
public VlcError GetConfigVariable(String name, out String value) { value = null; using(VlcObject vlc = new VlcObject(this.vlcHandle, ObjectType.VLC_OBJECT_VLC)) { if(IntPtr.Zero == vlc.SubObject) { return VlcError.NoObj; } IntPtr p_item = config_FindConfig(vlc.SubObject, name); if(IntPtr.Zero == p_item) { return VlcError.NoVar; } try { module_config_t mod = (module_config_t)Marshal.PtrToStructure(p_item, typeof(module_config_t)); switch(mod.i_type) { case CONFIG_ITEM.CONFIG_ITEM_BOOL: { bool result = (__config_GetInt(vlc.SubObject, name) == 0); value = result.ToString(); } break; case CONFIG_ITEM.CONFIG_ITEM_INTEGER: { int intResult = __config_GetInt(vlc.SubObject, name); value = intResult.ToString(); } break; case CONFIG_ITEM.CONFIG_ITEM_FLOAT: { float floatResult = __config_GetFloat(vlc.SubObject, name); value = floatResult.ToString(); } break; case CONFIG_ITEM.CONFIG_ITEM_STRING: value = __config_GetPsz(vlc.SubObject, name); break; default: return VlcError.BadVar; } } catch(Exception e) { this.lastErrorMessage = e.Message; return VlcError.Exception; } } return VlcError.Success; }
public VlcError ShowMessage(String message) { try { using(VlcObject vobj = new VlcObject(this.vlcHandle, ObjectType.VLC_OBJECT_INPUT)) { if(vobj.SubObject != IntPtr.Zero) { __vout_OSDMessage(vobj.SubObject, DEFAULT_CHAN, message); return VlcError.Success; } else { return VlcError.NoObj; } } } catch(Exception ex) { this.lastErrorMessage = ex.Message; return VlcError.Exception; } }
public VlcError PlaylistClear() { try { using(VlcObject vobj = new VlcObject(this.vlcHandle, ObjectType.VLC_OBJECT_PLAYLIST)) { if(vobj.SubObject != IntPtr.Zero) { return playlist_Clear(vobj.SubObject); } else { return VlcError.NoObj; } } } catch(Exception ex) { this.lastErrorMessage = ex.Message; return VlcError.Exception; } }
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 VlcError AddTarget(string target, string[] options, ref int itemId) { int optionsCount = 0; if(options != null) { optionsCount = options.Length; } try { using(VlcObject vobj = new VlcObject(this.vlcHandle, ObjectType.VLC_OBJECT_PLAYLIST)) { if(vobj.SubObject != IntPtr.Zero) { VlcError enmErr = playlist_AddExt(vobj.SubObject, target, target, Mode.Append, EndOfPlaylist, -1L, options, optionsCount); if(enmErr >= VlcError.Success) { itemId = (int)enmErr; } return enmErr; } else { return VlcError.NoObj; } } } catch(Exception ex) { this.lastErrorMessage = ex.Message; return VlcError.Exception; } }