/**
         * Create a new media player event for a given native event.
         * 
         * @param event native event
         * @param eventMask bit mask of enabled events (i.e. events to send notifications for)
         * @return media player event, or <code>null</code> if the native event type is not enabled or otherwise could not be handled
         */
        public MediaPlayerEvent CreateEvent(libvlc_event_t evt, int eventMask) {
            // Create an event suitable for the native event type...
            MediaPlayerEvent result = null;
            switch(evt.type) {
    
            // === Events relating to the media player ==============================
    
                case libvlc_event_e.libvlc_MediaPlayerMediaChanged:
    //                if(MediaPlayerEventType.set(eventMask, MediaPlayerEventType.MEDIA_CHANGED)) {
                        result = new MediaPlayerMediaChangedEvent(mediaPlayer, evt.u.md, mediaPlayer.Mrl(evt.u.md));
    //                }
                    break;
    
                case libvlc_event_e.libvlc_MediaPlayerNothingSpecial:
    //                if(MediaPlayerEventType.set(eventMask, MediaPlayerEventType.MEDIA_CHANGED)) {
                        result = new MediaPlayerNothingSpecialEvent(mediaPlayer);
    //                }
                    break;
    
                case libvlc_event_e.libvlc_MediaPlayerOpening:
    //                if(MediaPlayerEventType.set(eventMask, MediaPlayerEventType.OPENING)) {
                        result = new MediaPlayerOpeningEvent(mediaPlayer);
    //                }
                    break;
    
                case libvlc_event_e.libvlc_MediaPlayerBuffering:
    //                if(MediaPlayerEventType.set(eventMask, MediaPlayerEventType.BUFFERING)) {
                        result = new MediaPlayerBufferingEvent(mediaPlayer, evt.u.new_cache);
    //                }
                    break;
    
                case libvlc_event_e.libvlc_MediaPlayerPlaying:
    //                if(MediaPlayerEventType.set(eventMask, MediaPlayerEventType.PLAYING)) {
                        result = new MediaPlayerPlayingEvent(mediaPlayer);
    //                }
                    break;
    
                case libvlc_event_e.libvlc_MediaPlayerPaused:
    //                if(MediaPlayerEventType.set(eventMask, MediaPlayerEventType.PAUSED)) {
                        result = new MediaPlayerPausedEvent(mediaPlayer);
    //                }
                    break;
    
                case libvlc_event_e.libvlc_MediaPlayerStopped:
    //                if(MediaPlayerEventType.set(eventMask, MediaPlayerEventType.STOPPED)) {
                        result = new MediaPlayerStoppedEvent(mediaPlayer);
    //                }
                    break;
    
                case libvlc_event_e.libvlc_MediaPlayerForward:
    //                if(MediaPlayerEventType.set(eventMask, MediaPlayerEventType.FORWARD)) {
                        result = new MediaPlayerForwardEvent(mediaPlayer);
    //                }
                    break;
    
                case libvlc_event_e.libvlc_MediaPlayerBackward:
    //                if(MediaPlayerEventType.set(eventMask, MediaPlayerEventType.BACKWARD)) {
                        result = new MediaPlayerBackwardEvent(mediaPlayer);
    //                }
                    break;
    
                case libvlc_event_e.libvlc_MediaPlayerEndReached:
    //                if(MediaPlayerEventType.set(eventMask, MediaPlayerEventType.FINISHED)) {
                        result = new MediaPlayerEndReachedEvent(mediaPlayer);
    //                }
                    break;
    
                case libvlc_event_e.libvlc_MediaPlayerEncounteredError:
    //                if(MediaPlayerEventType.set(eventMask, MediaPlayerEventType.ERROR)) {
                        result = new MediaPlayerEncounteredErrorEvent(mediaPlayer);
    //                }
                    break;
    
                case libvlc_event_e.libvlc_MediaPlayerTimeChanged:
    //                if(MediaPlayerEventType.set(eventMask, MediaPlayerEventType.TIME_CHANGED)) {
                        result = new MediaPlayerTimeChangedEvent(mediaPlayer, evt.u.new_time);
    //                }
                    break;
    
                case libvlc_event_e.libvlc_MediaPlayerPositionChanged:
    //                if(MediaPlayerEventType.set(eventMask, MediaPlayerEventType.POSITION_CHANGED)) {
                        result = new MediaPlayerPositionChangedEvent(mediaPlayer, evt.u.new_position);
    //                }
                    break;
    
                case libvlc_event_e.libvlc_MediaPlayerSeekableChanged:
    //                if(MediaPlayerEventType.set(eventMask, MediaPlayerEventType.SEEKABLE_CHANGED)) {
                        result = new MediaPlayerSeekableChangedEvent(mediaPlayer, evt.u.new_seekable);
    //                }
                    break;
    
                case libvlc_event_e.libvlc_MediaPlayerPausableChanged:
    //                if(MediaPlayerEventType.set(eventMask, MediaPlayerEventType.PAUSABLE_CHANGED)) {
                        result = new MediaPlayerPausableChangedEvent(mediaPlayer, evt.u.new_pausable);
    //                }
                    break;
    
                case libvlc_event_e.libvlc_MediaPlayerTitleChanged:
    //                if(MediaPlayerEventType.set(eventMask, MediaPlayerEventType.TITLE_CHANGED)) {
                        result = new MediaPlayerTitleChangedEvent(mediaPlayer, evt.u.new_title);
    //                }
                    break;
    
                case libvlc_event_e.libvlc_MediaPlayerSnapshotTaken:
    //                if(MediaPlayerEventType.set(eventMask, MediaPlayerEventType.SNAPSHOT_TAKEN)) {
                        result = new MediaPlayerSnapshotTakenEvent(mediaPlayer, NativeString.String(evt.u.psz_filename));
    //                }
                    break;
    
                case libvlc_event_e.libvlc_MediaPlayerLengthChanged:
    //                if(MediaPlayerEventType.set(eventMask, MediaPlayerEventType.LENGTH_CHANGED)) {
                        result = new MediaPlayerLengthChangedEvent(mediaPlayer, evt.u.new_length);
    //                }
                    break;
    
                case libvlc_event_e.libvlc_MediaPlayerVout:
    //                if(MediaPlayerEventType.set(eventMask, MediaPlayerEventType.VIDEO_OUTPUT)) {
                        result = new MediaPlayerVoutEvent(mediaPlayer, evt.u.new_count);
    //                }
                    break;
    
                // === Events relating to the current media =============================
    
                case libvlc_event_e.libvlc_MediaMetaChanged:
    //                if(MediaPlayerEventType.set(eventMask, MediaPlayerEventType.MEDIA_META_CHANGED)) {
                        result = new MediaMetaChangedEvent(mediaPlayer, evt.u.meta_type);
    //                }
                    break;
    
                case libvlc_event_e.libvlc_MediaSubItemAdded:
    //                if(MediaPlayerEventType.set(eventMask, MediaPlayerEventType.MEDIA_SUB_ITEM_ADDED)) {
                        result = new MediaSubItemAddedEvent(mediaPlayer, evt.u.new_child);
    //                }
                    break;
    
                case libvlc_event_e.libvlc_MediaDurationChanged:
    //                if(MediaPlayerEventType.set(eventMask, MediaPlayerEventType.MEDIA_DURATION_CHANGED)) {
                        result = new MediaDurationChangedEvent(mediaPlayer, evt.u.new_duration);
    //                }
                    break;
    
                case libvlc_event_e.libvlc_MediaParsedChanged:
    //                if(MediaPlayerEventType.set(eventMask, MediaPlayerEventType.MEDIA_PARSED_CHANGED)) {
                        result = new MediaParsedChangedEvent(mediaPlayer, evt.u.new_status);
    //                }
                    break;

                case libvlc_event_e.libvlc_MediaFreed:
    //                if(MediaPlayerEventType.set(eventMask, MediaPlayerEventType.MEDIA_FREED)) {
                        result = new MediaFreedEvent(mediaPlayer);
    //                }
                    break;
    
                case libvlc_event_e.libvlc_MediaStateChanged:
    //                if(MediaPlayerEventType.set(eventMask, MediaPlayerEventType.MEDIA_STATE_CHANGED)) {
                        result = new MediaStateChangedEvent(mediaPlayer, evt.u.new_state);
    //                }
                    break;
            }
            return result;
        }
コード例 #2
0
        /**
         * Create a new media player event for a given native event.
         *
         * @param event native event
         * @param eventMask bit mask of enabled events (i.e. events to send notifications for)
         * @return media player event, or <code>null</code> if the native event type is not enabled or otherwise could not be handled
         */
        public MediaPlayerEvent CreateEvent(libvlc_event_t evt, int eventMask)
        {
            // Create an event suitable for the native event type...
            MediaPlayerEvent result = null;

            switch (evt.type)
            {
            // === Events relating to the media player ==============================

            case libvlc_event_e.libvlc_MediaPlayerMediaChanged:
                //                if(MediaPlayerEventType.set(eventMask, MediaPlayerEventType.MEDIA_CHANGED)) {
                result = new MediaPlayerMediaChangedEvent(mediaPlayer, evt.u.md, mediaPlayer.Mrl(evt.u.md));
                //                }
                break;

            case libvlc_event_e.libvlc_MediaPlayerNothingSpecial:
                //                if(MediaPlayerEventType.set(eventMask, MediaPlayerEventType.MEDIA_CHANGED)) {
                result = new MediaPlayerNothingSpecialEvent(mediaPlayer);
                //                }
                break;

            case libvlc_event_e.libvlc_MediaPlayerOpening:
                //                if(MediaPlayerEventType.set(eventMask, MediaPlayerEventType.OPENING)) {
                result = new MediaPlayerOpeningEvent(mediaPlayer);
                //                }
                break;

            case libvlc_event_e.libvlc_MediaPlayerBuffering:
                //                if(MediaPlayerEventType.set(eventMask, MediaPlayerEventType.BUFFERING)) {
                result = new MediaPlayerBufferingEvent(mediaPlayer, evt.u.new_cache);
                //                }
                break;

            case libvlc_event_e.libvlc_MediaPlayerPlaying:
                //                if(MediaPlayerEventType.set(eventMask, MediaPlayerEventType.PLAYING)) {
                result = new MediaPlayerPlayingEvent(mediaPlayer);
                //                }
                break;

            case libvlc_event_e.libvlc_MediaPlayerPaused:
                //                if(MediaPlayerEventType.set(eventMask, MediaPlayerEventType.PAUSED)) {
                result = new MediaPlayerPausedEvent(mediaPlayer);
                //                }
                break;

            case libvlc_event_e.libvlc_MediaPlayerStopped:
                //                if(MediaPlayerEventType.set(eventMask, MediaPlayerEventType.STOPPED)) {
                result = new MediaPlayerStoppedEvent(mediaPlayer);
                //                }
                break;

            case libvlc_event_e.libvlc_MediaPlayerForward:
                //                if(MediaPlayerEventType.set(eventMask, MediaPlayerEventType.FORWARD)) {
                result = new MediaPlayerForwardEvent(mediaPlayer);
                //                }
                break;

            case libvlc_event_e.libvlc_MediaPlayerBackward:
                //                if(MediaPlayerEventType.set(eventMask, MediaPlayerEventType.BACKWARD)) {
                result = new MediaPlayerBackwardEvent(mediaPlayer);
                //                }
                break;

            case libvlc_event_e.libvlc_MediaPlayerEndReached:
                //                if(MediaPlayerEventType.set(eventMask, MediaPlayerEventType.FINISHED)) {
                result = new MediaPlayerEndReachedEvent(mediaPlayer);
                //                }
                break;

            case libvlc_event_e.libvlc_MediaPlayerEncounteredError:
                //                if(MediaPlayerEventType.set(eventMask, MediaPlayerEventType.ERROR)) {
                result = new MediaPlayerEncounteredErrorEvent(mediaPlayer);
                //                }
                break;

            case libvlc_event_e.libvlc_MediaPlayerTimeChanged:
                //                if(MediaPlayerEventType.set(eventMask, MediaPlayerEventType.TIME_CHANGED)) {
                result = new MediaPlayerTimeChangedEvent(mediaPlayer, evt.u.new_time);
                //                }
                break;

            case libvlc_event_e.libvlc_MediaPlayerPositionChanged:
                //                if(MediaPlayerEventType.set(eventMask, MediaPlayerEventType.POSITION_CHANGED)) {
                result = new MediaPlayerPositionChangedEvent(mediaPlayer, evt.u.new_position);
                //                }
                break;

            case libvlc_event_e.libvlc_MediaPlayerSeekableChanged:
                //                if(MediaPlayerEventType.set(eventMask, MediaPlayerEventType.SEEKABLE_CHANGED)) {
                result = new MediaPlayerSeekableChangedEvent(mediaPlayer, evt.u.new_seekable);
                //                }
                break;

            case libvlc_event_e.libvlc_MediaPlayerPausableChanged:
                //                if(MediaPlayerEventType.set(eventMask, MediaPlayerEventType.PAUSABLE_CHANGED)) {
                result = new MediaPlayerPausableChangedEvent(mediaPlayer, evt.u.new_pausable);
                //                }
                break;

            case libvlc_event_e.libvlc_MediaPlayerTitleChanged:
                //                if(MediaPlayerEventType.set(eventMask, MediaPlayerEventType.TITLE_CHANGED)) {
                result = new MediaPlayerTitleChangedEvent(mediaPlayer, evt.u.new_title);
                //                }
                break;

            case libvlc_event_e.libvlc_MediaPlayerSnapshotTaken:
                //                if(MediaPlayerEventType.set(eventMask, MediaPlayerEventType.SNAPSHOT_TAKEN)) {
                result = new MediaPlayerSnapshotTakenEvent(mediaPlayer, NativeString.String(evt.u.psz_filename));
                //                }
                break;

            case libvlc_event_e.libvlc_MediaPlayerLengthChanged:
                //                if(MediaPlayerEventType.set(eventMask, MediaPlayerEventType.LENGTH_CHANGED)) {
                result = new MediaPlayerLengthChangedEvent(mediaPlayer, evt.u.new_length);
                //                }
                break;

            case libvlc_event_e.libvlc_MediaPlayerVout:
                //                if(MediaPlayerEventType.set(eventMask, MediaPlayerEventType.VIDEO_OUTPUT)) {
                result = new MediaPlayerVoutEvent(mediaPlayer, evt.u.new_count);
                //                }
                break;

            // === Events relating to the current media =============================

            case libvlc_event_e.libvlc_MediaMetaChanged:
                //                if(MediaPlayerEventType.set(eventMask, MediaPlayerEventType.MEDIA_META_CHANGED)) {
                result = new MediaMetaChangedEvent(mediaPlayer, evt.u.meta_type);
                //                }
                break;

            case libvlc_event_e.libvlc_MediaSubItemAdded:
                //                if(MediaPlayerEventType.set(eventMask, MediaPlayerEventType.MEDIA_SUB_ITEM_ADDED)) {
                result = new MediaSubItemAddedEvent(mediaPlayer, evt.u.new_child);
                //                }
                break;

            case libvlc_event_e.libvlc_MediaDurationChanged:
                //                if(MediaPlayerEventType.set(eventMask, MediaPlayerEventType.MEDIA_DURATION_CHANGED)) {
                result = new MediaDurationChangedEvent(mediaPlayer, evt.u.new_duration);
                //                }
                break;

            case libvlc_event_e.libvlc_MediaParsedChanged:
                //                if(MediaPlayerEventType.set(eventMask, MediaPlayerEventType.MEDIA_PARSED_CHANGED)) {
                result = new MediaParsedChangedEvent(mediaPlayer, evt.u.new_status);
                //                }
                break;

            case libvlc_event_e.libvlc_MediaFreed:
                //                if(MediaPlayerEventType.set(eventMask, MediaPlayerEventType.MEDIA_FREED)) {
                result = new MediaFreedEvent(mediaPlayer);
                //                }
                break;

            case libvlc_event_e.libvlc_MediaStateChanged:
                //                if(MediaPlayerEventType.set(eventMask, MediaPlayerEventType.MEDIA_STATE_CHANGED)) {
                result = new MediaStateChangedEvent(mediaPlayer, evt.u.new_state);
                //                }
                break;
            }
            return(result);
        }