Page 1 of 1

[Solved]libvlc_event_attach not working,simple but confusing

Posted: 13 May 2014 21:29
by imanafa
Ok! I am new to vlc development world and actually just started learning about it a few days ago. First thing was writing a wrapper using C# which seems to be working good. Developed a simple player which worked OK but for one issue : Check Here, which I haven't been able to solve yet (I'm working on a solution and will update if it works).

For being able to access more of vlc features the next phase was subscribing to the event using "libvlc_event_attach" . Well I read about how to use delegates read this, and this to make that happen. And i was faced with this weird problem:I could access event manager and read the return value which was a pointer just fine, but the libvlc_event_attach would keep returning -1, and the log on vlc would show my event type as "Unknown Event".

The answer to that was right in front me the whole time and actually in one of the posts. I'm sure that many already know the answer but some one might have to put an hour or two like i did to find it out and this is the reason this post is made. Just to save you some time. You have to Set up the enum. Here is what i did after checking this out (i guess the memory management could be better but this works):

Code: Select all

enum event_type_t { MediaMetaChanged = 0, MediaSubItemAdded, MediaDurationChanged, MediaParsedChanged, MediaFreed, MediaStateChanged, MediaSubItemTreeAdded, MediaPlayerMediaChanged = 0x100, MediaPlayerNothingSpecial, MediaPlayerOpening, MediaPlayerBuffering, MediaPlayerPlaying, MediaPlayerPaused, MediaPlayerStopped, MediaPlayerForward, MediaPlayerBackward, MediaPlayerEndReached, MediaPlayerEncounteredError, MediaPlayerTimeChanged, MediaPlayerPositionChanged, MediaPlayerSeekableChanged, MediaPlayerPausableChanged, MediaPlayerTitleChanged, MediaPlayerSnapshotTaken, MediaPlayerLengthChanged, MediaPlayerVout, MediaPlayerScrambledChanged, MediaListItemAdded =0x1000, MediaListWillAddItem, MediaListItemDeleted, MediaListWillDeleteItem, MediaListViewItemAdded =0x10000, MediaListViewWillAddItem, MediaListViewItemDeleted, MediaListViewWillDeleteItem, MediaListPlayerPlayed, MediaListPlayerNextItemSet, MediaListPlayerStopped, MediaDiscovererStarted = 0x100000, MediaDiscovererEnded, VlmMediaAdded = 0x1000000, VlmMediaRemoved, VlmMediaChanged, VlmMediaInstanceStarted, VlmMediaInstanceStopped, VlmMediaInstanceStatusInit, VlmMediaInstanceStatusOpening, VlmMediaInstanceStatusPlaying, VlmMediaInstanceStatusPause, VlmMediaInstanceStatusEnd, VlmMediaInstanceStatusError }