/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ #include #include #include #include #include #include #include #include #include #include #include "soundplayer.hxx" #include using namespace ::com::sun::star; namespace slideshow { namespace internal { // TODO(Q3): Move the whole SoundPlayer class to avmedia. boost::shared_ptr SoundPlayer::create( EventMultiplexer & rEventMultiplexer, const ::rtl::OUString& rSoundURL, const uno::Reference< uno::XComponentContext>& rComponentContext ) { boost::shared_ptr pPlayer( new SoundPlayer( rEventMultiplexer, rSoundURL, rComponentContext ) ); rEventMultiplexer.addPauseHandler( pPlayer ); pPlayer->mThis = pPlayer; return pPlayer; } bool SoundPlayer::handlePause( bool bPauseShow ) { return bPauseShow ? stopPlayback() : startPlayback(); } void SoundPlayer::dispose() { if( mThis ) { mrEventMultiplexer.removePauseHandler( mThis ); mThis.reset(); } if( mxPlayer.is() ) { mxPlayer->stop(); uno::Reference xComponent( mxPlayer, uno::UNO_QUERY ); if( xComponent.is() ) xComponent->dispose(); mxPlayer.clear(); } } SoundPlayer::SoundPlayer( EventMultiplexer & rEventMultiplexer, const ::rtl::OUString& rSoundURL, const uno::Reference< uno::XComponentContext>& rComponentContext ) : mrEventMultiplexer(rEventMultiplexer), mThis(), mxPlayer() { ENSURE_OR_THROW( rComponentContext.is(), "SoundPlayer::SoundPlayer(): Invalid component context" ); try { const INetURLObject aURL( rSoundURL ); mxPlayer.set( avmedia::MediaWindow::createPlayer( aURL.GetMainURL( INetURLObject::DECODE_UNAMBIGUOUS ) ), uno::UNO_QUERY); } catch( uno::RuntimeException& ) { throw; } catch( uno::Exception& ) { } if( !mxPlayer.is() ) throw lang::NoSupportException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "No sound support for ") ) + rSoundURL, uno::Reference() ); } SoundPlayer::~SoundPlayer() { try { dispose(); } catch (uno::Exception &) { OSL_FAIL( rtl::OUStringToOString( comphelper::anyToString( cppu::getCaughtException() ), RTL_TEXTENCODING_UTF8 ).getStr() ); } } double SoundPlayer::getDuration() const { if( !mxPlayer.is() ) return 0.0; const double nDuration( mxPlayer->getDuration() ); if( mxPlayer->isPlaying() ) return ::std::max( 0.0, nDuration - mxPlayer->getMediaTime() ); else return nDuration; } bool SoundPlayer::startPlayback() { if( !mxPlayer.is() ) return false; if( mxPlayer->isPlaying() ) mxPlayer->stop(); mxPlayer->start(); return true; } bool SoundPlayer::stopPlayback() { if( mxPlayer.is() ) mxPlayer->stop(); return true; } void SoundPlayer::setPlaybackLoop( bool bLoop ) { if( mxPlayer.is() ) mxPlayer->setPlaybackLoop( bLoop ); } } } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ on value='distro/lhm/libreoffice-4-1-6+backports'>distro/lhm/libreoffice-4-1-6+backports LibreOffice 核心代码仓库文档基金会
summaryrefslogtreecommitdiff
path: root/udm
vate/mst/sw_redlinehide&id=61d16504fc1aac2545589a85660c1c89aedbc372'>API CHANGE: remove com.sun.star.beans.XIntroTest
AgeCommit message (Expand)Author
2013-01-26gbuild: fix silly "expandtabs" in makefile VIM modelinesMichael Stahl
2012-10-31add missing deps on sal headersDavid Tardon
2012-09-29add missing dep on cosv headersDavid Tardon
2012-08-14these are needed only for odkMatúš Kukan
2012-08-02make sure headers are in place when the libs are usedDavid Tardon
2012-08-02gbuildize udmCaolán McNamara
Michael Stahl
2012-11-28API CHANGE: remove com.sun.star.test moduleMichael Stahl
2012-11-28API CHANGE: remove com.sun.star.corba moduleMichael Stahl
2012-11-28fdo#46808, Adapt reflection::ProxyFactory UNO service to new styleNoel Grandin
2012-11-26API CHANGE: com.sun.star.lang.IllegalArgumentExceptionMichael Stahl