Exemple #1
0
void VlcAudio::setTrack(int track)
{
    if (_vlcMediaPlayer) {
        libvlc_audio_set_track(_vlcMediaPlayer, track);
        VlcError::showErrmsg();
    }
}
jint Java_org_videolan_libvlc_LibVLC_setAudioTrack(JNIEnv *env, jobject thiz, jint index)
{
    libvlc_media_player_t *mp = getMediaPlayer(env, thiz);
    if (mp)
        return libvlc_audio_set_track(mp, index);
    return -1;
}
        static void callback(const libvlc_event_t *e, void *opaque)
        {
            T * const t = reinterpret_cast<T *>(opaque);
            std::lock_guard<std::mutex> _(t->mutex);

            if (e->type == libvlc_MediaPlayerTimeChanged)
            {
                if (t->info)
                    t->info->time = e->u.media_player_time_changed.new_time;
            }
            else if (e->type == libvlc_MediaPlayerPlaying)
            {
                t->started = true;

                if (t->track_ids.video >= -1)
                {
                    libvlc_video_set_track(t->player, -1);
                    if (t->track_ids.video > 0)
                        libvlc_video_set_track(t->player, t->track_ids.video);
                }

                if (t->track_ids.audio >= -1)
                {
                    libvlc_audio_set_track(t->player, -1);
                    if (t->track_ids.audio >= 0)
                        libvlc_audio_set_track(t->player, t->track_ids.audio);
                }

                if (t->track_ids.text >= -1)
                {
                    libvlc_video_set_spu(t->player, -1);
                    if (t->track_ids.text >= 0)
                        libvlc_video_set_spu(t->player, t->track_ids.text);
                }
            }
            else if (e->type == libvlc_MediaPlayerEndReached)
            {
                t->end_reached = true;
                if (t->info)
                    t->info->end_reached = true;
            }
            else if (e->type == libvlc_MediaPlayerEncounteredError)
                t->encountered_error = true;

            t->condition.notify_one();
        }
Exemple #4
0
static void
_audio_track_set(struct _App *app)
{
   int track;

   _em_read_safe(app->em_read, &track, sizeof(track));

   libvlc_audio_set_track(app->mp, track);
}
Exemple #5
0
STDMETHODIMP VLCAudio::put_track(long track)
{
    libvlc_media_player_t *p_md;
    HRESULT hr = getMD(&p_md);
    if( SUCCEEDED(hr) )
    {
        libvlc_audio_set_track(p_md, track);
    }
    return hr;
};
Exemple #6
0
RuntimeNPObject::InvokeResult
LibvlcAudioNPObject::setProperty(int index, const NPVariant &value)
{
    /* is plugin still running */
    if( isPluginRunning() )
    {
        VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
        libvlc_exception_t ex;
        libvlc_exception_init(&ex);

        switch( index )
        {
            case ID_audio_mute:
                if( NPVARIANT_IS_BOOLEAN(value) )
                {
                    libvlc_audio_set_mute(p_plugin->getVLC(),
                                          NPVARIANT_TO_BOOLEAN(value), &ex);
                    RETURN_ON_EXCEPTION(this,ex);
                    return INVOKERESULT_NO_ERROR;
                }
                return INVOKERESULT_INVALID_VALUE;
            case ID_audio_volume:
                if( isNumberValue(value) )
                {
                    libvlc_audio_set_volume(p_plugin->getVLC(),
                                            numberValue(value), &ex);
                    RETURN_ON_EXCEPTION(this,ex);
                    return INVOKERESULT_NO_ERROR;
                }
                return INVOKERESULT_INVALID_VALUE;
            case ID_audio_track:
                if( isNumberValue(value) )
                {
                    libvlc_media_player_t *p_md = p_plugin->getMD(&ex);
                    RETURN_ON_EXCEPTION(this,ex);
                    libvlc_audio_set_track(p_md, numberValue(value), &ex);
                    RETURN_ON_EXCEPTION(this,ex);
                    return INVOKERESULT_NO_ERROR;
                }
                return INVOKERESULT_INVALID_VALUE;
            case ID_audio_channel:
                if( isNumberValue(value) )
                {
                    libvlc_audio_set_channel(p_plugin->getVLC(),
                                             numberValue(value), &ex);
                    RETURN_ON_EXCEPTION(this,ex);
                    return INVOKERESULT_NO_ERROR;
                }
                return INVOKERESULT_INVALID_VALUE;
            default:
                ;
        }
    }
    return INVOKERESULT_GENERIC_ERROR;
}
jboolean
Java_org_videolan_libvlc_MediaPlayer_nativeSetAudioTrack(JNIEnv *env,
                                                         jobject thiz,
                                                         jint index)
{
    vlcjni_object *p_obj = VLCJniObject_getInstance(env, thiz);

    if (!p_obj)
        return false;

    return libvlc_audio_set_track(p_obj->u.p_mp, index) == 0 ? true : false;
}
void VLCVideoTextureObjChunk::updateTime(void)
{
    if ((libvlc == NULL) || (vlcmediaplayer == NULL)) return;
    if (libvlc_media_player_is_playing(vlcmediaplayer) != 1) return;
    // only update if > MIN_TIME_DIFF ms offset
    long test = labs(libvlc_media_player_get_time(vlcmediaplayer) - this->getTimestamp());
    if (test > MIN_TIME_DIFF)
    {
        libvlc_media_player_set_time(vlcmediaplayer, this->getTimestamp());
        SLOG << "resyncing video: " << test << std::endl;

        if (!isSetToMute) 
        {
            libvlc_audio_set_track(vlcmediaplayer, -1);            
            isSetToMute = true;
        }

    }
}
void VlcMediaWidget::setCurrentAudioStream(int currentAudioStream)
{
	// skip the 'deactivate' audio channel
	libvlc_audio_set_track(vlcMediaPlayer, currentAudioStream + 1);
}
Exemple #10
0
void LiveWidget::audioMenuActionTriggered(QAction* action)
{
    libvlc_audio_set_track(this->vlcMediaPlayer, action->data().toInt());
}
Exemple #11
0
//AudioChannel
void VLCMediaController::setCurrentAudioChannel( const Phonon::AudioChannelDescription & audioChannel )
{
	current_audio_channel = audioChannel;
    libvlc_audio_set_track( p_vlc_media_player, audioChannel.index(), p_vlc_exception );
    checkException();
}
bool VLCVideoTextureObjChunk::createVLCInstance(libvlc_time_t start_time,
                                                bool          play)
{
    libvlc_media_t *m;

    char const *vlc_argv[] =
    {
        "-I", "dumy",      // No special interface
        "--ignore-config", // Don't use VLC's config        
        "--quiet",         // deactivates VLCs console outputs
        "--no-xlib",       // tell VLC to not use Xlib                   
        "--no-video-title-show", // no titles
    };

    int vlc_argc = sizeof(vlc_argv) / sizeof(*vlc_argv);

    // Initialize libVLC   
    if (libvlc == NULL)
    {
        libvlc = libvlc_new(vlc_argc, vlc_argv);
    }
    else
    {
        if (vlcmediaplayer != NULL)
        {
            ctx.idstr = NULL;
            libvlc_media_player_stop(vlcmediaplayer);
            libvlc_media_player_release(vlcmediaplayer);
            vlcmediaplayer = NULL;
            if (ctx.videothread != NULL) {
                ctx.videothread->runFunction(NULL, NULL); // reset thread structure: isInititialized=false
            }
            ctx.videothread = NULL;
        }
    }
    if (libvlc == NULL) 
    {
        SFATAL << "libvlc creation failed (plugin folder?)" << std::endl;
        return false;
    }
    m = libvlc_media_new_path(libvlc, getUrl().c_str());

    vlcmediaplayer = libvlc_media_player_new_from_media(m);

    libvlc_media_release(m);

    ctx.idstr = strdup((std::string("video") + getVideoID()).c_str());
    ctx.videothread = NULL;
    ctx.img = Image::create();
    ctx.img->set(OSG::Image::OSG_BGR_PF, getWidth(), getHeight());
    ctx.lock = Lock::create();

    this->setImage(ctx.img);
    this->setTarget(GL_TEXTURE_2D);
    ctx.self = this;


    vlceventmgr = libvlc_media_player_event_manager(vlcmediaplayer);
    // attach event to defined event handler callback
    libvlc_event_attach(vlceventmgr, libvlc_MediaPlayerEndReached, vlc_event, &ctx);

    libvlc_video_set_callbacks(vlcmediaplayer, vlc_lock, vlc_unlock, vlc_display, &ctx);
    libvlc_video_set_format(vlcmediaplayer, "RV24", getWidth(), getHeight(), getWidth() * 3);
    if (getIsMaster() == false) 
    {
        libvlc_audio_set_mute(vlcmediaplayer, 1);

        SLOG << "audiotracks:" << libvlc_audio_get_track_count(vlcmediaplayer) << std::endl;
        libvlc_audio_set_track(vlcmediaplayer, -1); // this may only work when media is playing!
        needsUpdate = true;


        SLOG << "not master, setting audio to mute!" << std::endl;
    }
    else SLOG << "this is handled as master!" << std::endl;

#if 0
    {
        SLOG << "available filters:" << std::endl;
        libvlc_module_description_t *list = libvlc_video_filter_list_get(libvlc);
        libvlc_module_description_t *iter = list;
        while (iter != NULL) {
            SLOG << iter->psz_name << std::endl;
            iter = iter->p_next;
        }
        libvlc_module_description_list_release(list);
    }
#endif


    libvlc_media_player_play(vlcmediaplayer);
    libvlc_media_player_set_time(vlcmediaplayer, start_time);
    if (!play) libvlc_media_player_pause(vlcmediaplayer); //not working?

    // add to static list
    //allVideoTextures.push_back(&ctx);

    lastSync = OSG::getTimeStamp();

    return true;
}