コード例 #1
0
VideoSource::~VideoSource()
{ 

    // media list and media list player
    libvlc_media_list_player_stop(mediaListPlayer);
    libvlc_media_list_player_release(mediaListPlayer);
    libvlc_media_list_release(mediaList);

    // media player
    libvlc_video_set_callbacks(mediaPlayer, nullptr, nullptr, nullptr, nullptr);
    libvlc_media_player_stop(mediaPlayer);
        

    delete audioOutputStreamHandler;
    audioOutputStreamHandler = nullptr;


    libvlc_media_player_release(mediaPlayer);

    if (pixelData) {
        free(pixelData);
        pixelData = nullptr;
    }

    if (texture) {
        delete texture;
        texture = nullptr;
    }

    delete config;
    config = nullptr;

    DeleteCriticalSection(&textureLock);
}
コード例 #2
0
static void releaseMediaPlayer(JNIEnv *env, jobject thiz)
{
    libvlc_media_list_player_t* p_mlp = getMediaListPlayer(env, thiz);
    if (p_mlp)
    {
        libvlc_media_list_player_stop(p_mlp);
        libvlc_media_list_player_release(p_mlp);
        /* libvlc_media_list_player_release frees the media player, so
         * we don't free it ourselves. */
        setLong(env, thiz, "mInternalMediaPlayerInstance", 0);
        setLong(env, thiz, "mMediaListPlayerInstance", 0);
    }
}
コード例 #3
0
 /**
  * Stop playing media list
  */
 void stop()
 {
     libvlc_media_list_player_stop(*this);
 }
コード例 #4
0
void VideoSource::UpdateSettings()
{
    
    EnterCriticalSection(&textureLock);
    isRendering = false;
    LeaveCriticalSection(&textureLock);

    if (mediaPlayer) {
        libvlc_video_set_callbacks(mediaPlayer, nullptr, nullptr, nullptr, nullptr);
        libvlc_media_player_stop(mediaPlayer);
    }
    
    config->Reload();

    hasSetVolume = false;

    videoSize.x = float(config->width);
    videoSize.y = float(config->height);

    if (mediaPlayer == nullptr) {
        mediaPlayer = libvlc_media_player_new(vlc);
        libvlc_event_manager_t *em = libvlc_media_player_event_manager(mediaPlayer);
        libvlc_event_attach(em, libvlc_MediaPlayerEndReached, vlcEvent, this);
        libvlc_event_attach(em, libvlc_MediaPlayerPlaying, vlcEvent, this);
    }

    if (mediaListPlayer == nullptr) {
        mediaListPlayer = libvlc_media_list_player_new(vlc);
        libvlc_media_list_player_set_media_player(mediaListPlayer, mediaPlayer);
    } else {
        libvlc_media_list_player_stop(mediaListPlayer);
    }

    if (mediaList) {
        libvlc_media_list_lock(mediaList);
        while(libvlc_media_list_count(mediaList)) {
            libvlc_media_list_remove_index(mediaList, 0);
        }
        libvlc_media_list_unlock(mediaList);
    } else {
        mediaList = libvlc_media_list_new(vlc);
        libvlc_media_list_player_set_media_list(mediaListPlayer, mediaList);
    }

    

    char *utf8PathOrUrl;
    for(unsigned int i = 0; i < config->playlist.Num(); i++) {
        String &mediaEntry = config->playlist[i];
        String token = mediaEntry.GetToken(1, L':');
     
        // .. Yup.
        bool isStream = token.Length() >= 2 && token[0] == L'/' && token[1] == L'/';
        utf8PathOrUrl = config->playlist[i].CreateUTF8String();
        if (utf8PathOrUrl) {
            libvlc_media_t *media;
            if (!isStream) {
                media = libvlc_media_new_path(vlc, utf8PathOrUrl);
            } else {
                media = libvlc_media_new_location(vlc, utf8PathOrUrl);
            }
            
            libvlc_media_list_lock(mediaList);
            libvlc_media_list_add_media(mediaList, media);
            libvlc_media_list_unlock(mediaList);

            libvlc_media_release(media);
            Free(utf8PathOrUrl);
        }
    }

    if (!config->isPlaylistLooping) {
        remainingVideos = config->playlist.Num();
    }

    libvlc_video_set_callbacks(mediaPlayer, lock, unlock, display, this);
    libvlc_video_set_format_callbacks(mediaPlayer, videoFormatProxy, videoCleanupProxy);

    libvlc_media_list_player_set_playback_mode(mediaListPlayer, config->isPlaylistLooping ? libvlc_playback_mode_loop : libvlc_playback_mode_default);
    

    if (!audioOutputStreamHandler) {
        audioOutputStreamHandler = new AudioOutputStreamHandler(vlc, mediaPlayer);
    }

    audioOutputStreamHandler->SetOutputParameters(
        config->audioOutputType, 
        config->audioOutputTypeDevice,
        config->audioOutputDevice, 
        config->isAudioOutputToStream);
    
    audioOutputStreamHandler->SetVolume(config->volume);
    
    // set (possibly in vane) the volume.  If it doesn't work it will try later until it works
    // vlc... que pasa amigo
    hasSetVolume = libvlc_audio_set_volume(mediaPlayer, config->volume) == 0;
    
    EnterCriticalSection(&textureLock);
    isRendering = true;
    LeaveCriticalSection(&textureLock);

    libvlc_media_list_player_play(mediaListPlayer);
    
}