示例#1
0
Smt_Uint TBaseDevice::OnCmdPlay(Smt_Pdu &pdu)
{
	Smt_Uint channel;
	Smt_Uint type;
	Smt_String termkey;
	Smt_String content;
	Smt_Kvset* kvTTS = new Smt_Kvset[MAX_TTSMEMARRAYNUM];
	Smt_Uint nTTSCount = 0;
	pdu.GetUint(Key_IVR_ChannelID, &channel);
	pdu.GetUint(Key_IVR_ContentType, &type);
	pdu.GetString(Key_IVR_TermKey, &termkey);
	pdu.GetString(Key_IVR_PlayContent, &content);	
	pdu.GetKvsetArray( Key_IVR_TTSMemArray, &kvTTS, &nTTSCount );	
	
	if(!CheckUserAndChannel(channel))
	{
		if(kvTTS != NULL)
		{
			delete [] kvTTS;
			kvTTS = NULL;
		}
		return Smt_Fail;
	}
	
	PlayMedia(channel, type, termkey, content, kvTTS, nTTSCount, pdu);
	
	if(kvTTS !=NULL )
	{
		delete [] kvTTS;
		kvTTS = NULL;
	}
	return Smt_Success;
}
示例#2
0
/*----------------------------------------------------------------------
|   CUPnPRenderer::OnSetAVTransportURI
+---------------------------------------------------------------------*/
NPT_Result
CUPnPRenderer::OnSetAVTransportURI(PLT_ActionReference& action)
{
    NPT_String uri, meta;
    PLT_Service* service;
    NPT_CHECK_SEVERE(FindServiceByType("urn:schemas-upnp-org:service:AVTransport:1", service));

    NPT_CHECK_SEVERE(action->GetArgumentValue("CurrentURI", uri));
    NPT_CHECK_SEVERE(action->GetArgumentValue("CurrentURIMetaData", meta));

    // if not playing already, just keep around uri & metadata
    // and wait for play command
    if (!g_application.m_pPlayer->IsPlaying() && g_windowManager.GetActiveWindow() != WINDOW_SLIDESHOW) {
        service->SetStateVariable("TransportState", "STOPPED");
        service->SetStateVariable("TransportStatus", "OK");
        service->SetStateVariable("TransportPlaySpeed", "1");
        service->SetStateVariable("AVTransportURI", uri);
        service->SetStateVariable("AVTransportURIMetaData", meta);
        service->SetStateVariable("NextAVTransportURI", "");
        service->SetStateVariable("NextAVTransportURIMetaData", "");

        NPT_CHECK_SEVERE(action->SetArgumentsOutFromStateVariable());
        return NPT_SUCCESS;
    }

    return PlayMedia(uri, meta, action.AsPointer());
}
示例#3
0
HRESULT PlayCutscene(LPTSTR szMovie, HINSTANCE hInstance)
{
    HRESULT hr;

    // Create the main hidden window to field keyboard input
    if (!CreateHiddenWindow(hInstance, szMovie))
        return E_FAIL;

    // Initialize COM
    if (FAILED(hr = CoInitialize(NULL)))
        return hr;

    // Get DirectShow interfaces
    if (FAILED(hr = GetInterfaces()))
    {
        CoUninitialize();
        return hr;
    }

    // Play the movie / cutscene
    hr = PlayMedia(szMovie, hInstance);

    // If the user interrupted playback and there was no other error,
    // return S_FALSE.
    if ((hr == S_OK) && g_bUserInterruptedPlayback)
        hr = S_FALSE;

    // Release DirectShow interfaces
    CleanupInterfaces();
    CoUninitialize();

    return hr;
}
示例#4
0
bool TorcPlayerInterface::HandleEvent(QEvent *Event)
{
    TorcEvent* torcevent = dynamic_cast<TorcEvent*>(Event);
    if (!torcevent)
        return false;

    QVariantMap data = torcevent->Data();
    int event = torcevent->GetEvent();
    switch (event)
    {
        case Torc::Exit:
            if (m_standalone)
            {
                TorcReferenceCounter::EventLoopEnding(true);
                QCoreApplication::quit();
            }
            break;
        case Torc::Suspending:
        case Torc::Hibernating:
            {
                TorcEvent e(Torc::Pause);
                m_pausedForSuspend = HandlePlayerEvent(&e);
                if (m_pausedForSuspend)
                    LOG(VB_GENERAL, LOG_INFO, "Playback paused while suspending");
            }
            break;
        case Torc::WokeUp:
            if (m_pausedForSuspend)
            {
                TorcEvent e(Torc::Unpause);
                HandlePlayerEvent(&e);
                LOG(VB_GENERAL, LOG_INFO, "Playback unpaused after suspension");
                m_pausedForSuspend = false;
            }
            break;
        case Torc::ShuttingDown:
        case Torc::Restarting:
            {
                TorcEvent e(Torc::Stop);
                HandlePlayerEvent(&e);
            }

            break;
        case Torc::PlayMedia:
            if (data.contains("uri"))
            {
                bool paused = data.value("paused", false).toBool();
                SetURI(data.value("uri").toString());
                PlayMedia(paused);
            }
            break;
         case Torc::DisplayDeviceReset: // is this needed anymore?
            HandlePlayerEvent(Event);
            break;
        default: break;
    }

    return false;
}
示例#5
0
int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
#endif
{
	if (__argc != 2)
		usage();

	try
	{
		PlayMedia(__argv[1]);
		return 0;
	}
	catch (_com_error e)
	{
		Message(true, "Cannot play media: %s\n", e.ErrorMessage());
		return 1;
	}
}
示例#6
0
/*----------------------------------------------------------------------
|   CUPnPRenderer::OnPlay
+---------------------------------------------------------------------*/
NPT_Result
CUPnPRenderer::OnPlay(PLT_ActionReference& action)
{
    if (g_windowManager.GetActiveWindow() == WINDOW_SLIDESHOW) {
        return NPT_SUCCESS;
    } else if (g_application.m_pPlayer->IsPausedPlayback()) {
      CApplicationMessenger::GetInstance().SendMsg(TMSG_MEDIA_PAUSE);
    } else if (!g_application.m_pPlayer->IsPlaying()) {
        NPT_String uri, meta;
        PLT_Service* service;
        // look for value set previously by SetAVTransportURI
        NPT_CHECK_SEVERE(FindServiceByType("urn:schemas-upnp-org:service:AVTransport:1", service));
        NPT_CHECK_SEVERE(service->GetStateVariableValue("AVTransportURI", uri));
        NPT_CHECK_SEVERE(service->GetStateVariableValue("AVTransportURIMetaData", meta));

        // if not set, use the current file being played
        PlayMedia(uri, meta);
    }
    return NPT_SUCCESS;
}
示例#7
0
bool TorcPlayerInterface::HandlePlayerEvent(QEvent *Event)
{
    if (!m_player || !Event)
        return false;

    int action = Torc::None;
    TorcEvent *torcevent = NULL;

    if (Event->type() == TorcEvent::TorcEventType)
    {
        torcevent = static_cast<TorcEvent*>(Event);
        action = torcevent->GetEvent();
    }

    TorcPlayer::PlayerState state  = m_player->GetState();

    if (action == Torc::Play && (state == TorcPlayer::Stopped || m_player->GetState() == TorcPlayer::None))
    {
        m_player->Reset();
        PlayMedia(false);
        return true;
    }

    if (state == TorcPlayer::Errored)
    {
        LOG(VB_GENERAL, LOG_ERR, "Ignoring action while player is errored");
        return false;
    }

    if (m_player->HandleDecoderEvent(Event))
        return true;

    if (action == Torc::Play)
    {
        m_player->Play();
        return true;
    }
    else if (action == Torc::Pause)
    {
        if (!(state == TorcPlayer::Paused || state == TorcPlayer::Pausing || state == TorcPlayer::Opening))
            return m_player->Pause();
        return false;
    }
    else if (action == Torc::Stop)
    {
        m_player->Stop();
        return true;
    }
    else if (action == Torc::Unpause)
    {
        m_player->Unpause();
        return true;
    }
    else if (action == Torc::TogglePlayPause)
    {
        m_player->TogglePause();
        return true;
    }

    return false;
}