Exemplo n.º 1
0
VlcMediaPlayer::VlcMediaPlayer() :
    QWidget(0),
    videoWidget_(0),
    currentSource_("")
{
    ui_.setupUi(this);
    ui_.pauseButton->hide();

    try
    {
        videoWidget_ = new VlcVideoWidget(GenerateVlcParameters());

        connect(videoWidget_, SIGNAL(StatusUpdate(const PlayerStatus&)), SLOT(OnStatusUpdate(const PlayerStatus&)));
        connect(videoWidget_, SIGNAL(FrameUpdate(QImage)), SIGNAL(FrameUpdate(QImage)), Qt::QueuedConnection);
        
        connect(ui_.playButton, SIGNAL(clicked()), SLOT(PlayPause()));
        connect(ui_.pauseButton, SIGNAL(clicked()), SLOT(PlayPause()));
        connect(ui_.stopButton, SIGNAL(clicked()), SLOT(Stop()));
        connect(ui_.timeSlider, SIGNAL(sliderReleased()), SLOT(Seek()));
        
        ui_.verticalLayout->insertWidget(0, videoWidget_, 2);
    }
    catch (std::exception &e)
    {
        LogError(QString("VlcMediaPlayer: ") + e.what());
    }

    setWindowTitle("");
    hide();
}
Exemplo n.º 2
0
void VlcVideoWidget::InternalRender(void* picture) 
{
    bool paused = false;
    QSize sourceSize = QSize();
    if (statusAccess.tryLock(5))
    {
        paused = status.paused;
        sourceSize = status.sourceSize;
        statusAccess.unlock();
    }
    else
        return;

    // Lock on screen pixmap and update it.
    // It is ok to miss some frames, so use tryLock() instead.
    // Otherwise paintEvent and this may trigger some nasty dead locks.
    if (onScreenPixmapMutex_.tryLock())
    {
        hasVideoOut_ = true;
        onScreenPixmap_ = QPixmap::fromImage(renderPixmap_);
        rgbaBuffer_ = renderPixmap_.convertToFormat(QImage::Format_ARGB32);

        // Paused
        if (paused)
        {
            QPainter p(&rgbaBuffer_);
            p.drawPixmap(QPoint(10, 10), pausePixmap_, pausePixmap_.rect());
            p.end();
        }
        // Waiting to determine true size.
        else if (sourceSize.isNull())
        {
            rgbaBuffer_.fill(QColor(242,242,242).rgb());
            QPoint centerPos = rgbaBuffer_.rect().center();
            QRect center(centerPos.x() - (bufferingPixmap_.width()/2), centerPos.y() - (bufferingPixmap_.height()/2),
                         bufferingPixmap_.width(), bufferingPixmap_.height());
            QPainter p(&rgbaBuffer_);
            p.setPen(Qt::black);
            p.drawPixmap(center, bufferingPixmap_, bufferingPixmap_.rect());
            p.drawText(5, 12, "Loading Media");
            p.end();
        }

        emit FrameUpdate(rgbaBuffer_);
        onScreenPixmapMutex_.unlock();

        // Ask the widget to render itself, should trigger paintEvent
        update();
    }  
}
Exemplo n.º 3
0
void VlcVideoWidget::ForceUpdateImage()
{
    QImage image;
    QPixmap addition;
    QPoint additionPos(10, 10);

    // No media or stopped
    statusAccess.tryLock();
    bool paused = status.paused;
    bool buffering = status.buffering;
    bool stopped = status.stopped;
    QString source = status.source;
    statusAccess.unlock();

    onScreenPixmapMutex_.lock();
    if (source.isEmpty() || stopped)
        image = idleLogo_;
    // Has media and is being played/paused/buffered
    else
    {
        // Has video
        if (hasVideoOut_)
            image = rgbaBuffer_;
        // Has audio
        else
            image = audioLogo_;
        // Addition
        if (paused)
            addition = pausePixmap_;
        if (buffering)
            addition = bufferingPixmap_;
    }
    onScreenPixmapMutex_.unlock();

    // Add additional image if there is one
    if (!addition.isNull())
    {
        QPainter p(&image);
        p.drawPixmap(additionPos, addition, addition.rect());
        p.end();
    }
    // Emit image
    emit FrameUpdate(image);

    update();
}
Exemplo n.º 4
0
//重写绘图事件
void DeskTopSprite::paintEvent(QPaintEvent *)
{
	float nowTime = timer.elapsed()/1000.f;
	deltaTime = nowTime - lastTime;
	FrameUpdate();
	QPainter painter(this);

	for (size_t i = 0;i< renderQueue.size();i++)
	{
		RenderData& data = renderQueue[i];
		QImage img = data.pic->toImage();
		painter.drawImage(data.x,data.y,img.mirrored(data.bMirror, false));
	}

	renderQueue.clear();

	lastTime = nowTime;
}
Exemplo n.º 5
0
EC_MediaPlayer::EC_MediaPlayer(Scene* scene) :
    IComponent(scene),
    mediaPlayer_(0),
    componentPrepared_(false),
    pendingMediaDownload_(false),
    sourceRef(this, "Media Source", AssetReference("", "")),
    renderSubmeshIndex(this, "Render Submesh", 0),
    interactive(this, "Interactive", false),
    illuminating(this, "Illuminating", true),
    streamingAllowed(this, "Streaming Allowed", true),
    enabled(this, "Enabled", true)
{
    if (!ViewEnabled() || GetFramework()->IsHeadless())
        return;

    // Set metadata min/max/step
    static AttributeMetadata submeshMetaData;
    static bool metadataInitialized = false;
    if (!metadataInitialized)
    {
        submeshMetaData.minimum = "0";
        submeshMetaData.step = "1";
        metadataInitialized = true;
    }
    renderSubmeshIndex.SetMetadata(&submeshMetaData);

    // Init our internal media player
    mediaPlayer_ = new VlcMediaPlayer();
    connect(mediaPlayer_, SIGNAL(FrameUpdate(QImage)), SLOT(OnFrameUpdate(QImage)), Qt::UniqueConnection);

    // Connect signals from IComponent
    connect(this, SIGNAL(ParentEntitySet()), SLOT(PrepareComponent()), Qt::UniqueConnection);

    // Connect window size changes to update rendering as the ogre textures go black.
    if (GetFramework()->Ui()->MainWindow())
        connect(GetFramework()->Ui()->MainWindow(), SIGNAL(WindowResizeEvent(int,int)), SLOT(RenderWindowResized()), Qt::UniqueConnection);

    resizeRenderTimer_ = new QTimer(this);
    resizeRenderTimer_->setSingleShot(true);
    connect(resizeRenderTimer_, SIGNAL(timeout()), mediaPlayer_, SLOT(ForceUpdateImage()), Qt::UniqueConnection);

    // Prepare scene interactions
    SceneInteract *sceneInteract = GetFramework()->GetModule<SceneInteract>();
    if (sceneInteract)
    {
        connect(sceneInteract, SIGNAL(EntityClicked(Entity*, Qt::MouseButton, RaycastResult*)), 
                SLOT(EntityClicked(Entity*, Qt::MouseButton, RaycastResult*)));
    }

    // Prepare media downloader
    mediaDownloader_ = new AssetRefListener();
    connect(mediaDownloader_, SIGNAL(Loaded(AssetPtr)), SLOT(OnMediaLoaded(AssetPtr)));
    connect(mediaDownloader_, SIGNAL(TransferFailed(IAssetTransfer*, QString)), SLOT(OnMediaFailed(IAssetTransfer*, QString)));

    // Construct loading image
    downloadingLogo_ = QImage(500, 300, QImage::Format_ARGB32);
    downloadingLogo_.fill(Qt::black);
    QPixmap bufferingIcon(":/images/buffering.png");
    QPoint centerPos = downloadingLogo_.rect().center();
    QRect target(centerPos.x() - (bufferingIcon.width()/2), centerPos.y() - (bufferingIcon.height()/2), bufferingIcon.width(), bufferingIcon.height());
    QPainter p(&downloadingLogo_);
    p.setPen(Qt::white);
    p.drawPixmap(target, bufferingIcon, bufferingIcon.rect());
    p.drawText(5, 12, "Downloading media...");
    p.end();
}
Exemplo n.º 6
0
void SATURN3D_main (void) {
	SATURN3D_Init_Pins();
	mLED_1_Off();
	mLED_2_On();

	while(1) {
		while (!SATURN3D_SEL || !SATURN3D_REQ) { } //initial sync- both TR and TH are high 
		while (SATURN3D_SEL) { } //wait for this controller to be selected (active low)
		while (SATURN3D_REQ) { } //wait for data request

		mLED_1_Toggle();

		//first send the peripheral id
		//3D controller in digital mode id = 0000
		SATURN3D_D0 = SATURN3D_D1 = SATURN3D_D2 = SATURN3D_D3 = 0;
		SATURN3D_ACK = 0; //tell saturn we're clear to send

		mLED_2_Toggle();

		while (!SATURN3D_REQ && !SATURN3D_SEL) {} //wait for data request toggle

		//now send the data size
		//only 2 bytes of data for digital, so = 0010
		SATURN3D_D1 = 1;
		SATURN3D_ACK = 1; //tell saturn we're clear to send first nibble

		while (SATURN3D_REQ && !SATURN3D_SEL) {} //wait for data request toggle

		//now send directions, UDLR
		SATURN3D_D0 = Stick_Up;
		SATURN3D_D1 = Stick_Down;
		SATURN3D_D2 = Stick_Left;
		SATURN3D_D3 = Stick_Right;
		SATURN3D_ACK = 0;

		while (!SATURN3D_REQ && !SATURN3D_SEL) {} //wait for data request toggle

		//now send kick buttons, in order B/C/A/Start
		SATURN3D_D0 = Stick_Forward;
		SATURN3D_D1 = Stick_Roundhouse;
		SATURN3D_D2 = Stick_Short;
		SATURN3D_D3 = Stick_Start;
		SATURN3D_ACK = 1;
			
		while (SATURN3D_REQ && !SATURN3D_SEL) {} //wait for data request toggle

		//now send punch buttons, in order ZYXR
		SATURN3D_D0 = Stick_Fierce;
		SATURN3D_D1 = Stick_Strong;
		SATURN3D_D2 = Stick_Jab;
#ifdef EXTRA_BUTTONS
		SATURN3D_D3 = Stick_Extra1; //R
#else
		SATURN3D_D3 = 1;
#endif
		SATURN3D_ACK = 0;
		
		while (!SATURN3D_REQ && !SATURN3D_SEL) {} //wait for data request toggle

		//now send the final nibble of data
		SATURN3D_D0 = SATURN3D_D1 = SATURN3D_D2 = 1;
#ifdef EXTRA_BUTTONS
		SATURN3D_D3 = Stick_Extra0; //L
#else
		SATURN3D_D3 = 1;
#endif
		SATURN3D_ACK = 1;

		while (SATURN3D_REQ && !SATURN3D_SEL) {} //wait for data request toggle

		//we have an 'end byte' to send now
		//first nibble = 0000
		SATURN3D_D0 = SATURN3D_D1 = SATURN3D_D2 = SATURN3D_D3 = 0;
		SATURN3D_ACK = 0; //tell saturn we're clear to send

		while (!SATURN3D_REQ && !SATURN3D_SEL) {} //wait for data request toggle

		//second nibble = 0001
		SATURN3D_D0 = 1;
		SATURN3D_ACK = 1;

		//and we're done.
		FrameUpdate();
	}
}