1763 MPX_DEBUG(_L("CMPXVideoPlaybackController::IsKeyLocked(%d)"), keylock); |
1767 MPX_DEBUG(_L("CMPXVideoPlaybackController::IsKeyLocked(%d)"), keylock); |
1764 |
1768 |
1765 return keylock; |
1769 return keylock; |
1766 } |
1770 } |
1767 |
1771 |
|
1772 // ------------------------------------------------------------------------------------------------- |
|
1773 // CMPXVideoPlaybackController::SendTvOutEventL |
|
1774 // ------------------------------------------------------------------------------------------------- |
|
1775 // |
|
1776 void CMPXVideoPlaybackController::SendTvOutEventL( TBool aConnected, TBool aPlaybackAllowed ) |
|
1777 { |
|
1778 MPX_ENTER_EXIT(_L("CMPXVideoPlaybackController::SendTvOutEventL()")); |
|
1779 |
|
1780 // |
|
1781 // Send notice to the playback view with TV-Out connection status |
|
1782 // and TV-Out playback allowed flag |
|
1783 // |
|
1784 CMPXMessage* message = CMPXMessage::NewL(); |
|
1785 CleanupStack::PushL( message ); |
|
1786 |
|
1787 message->SetTObjectValueL<TMPXMessageId>( KMPXMessageGeneralId, KMPXMediaIdVideoPlayback ); |
|
1788 message->SetTObjectValueL<TMPXVideoPlaybackCommand> |
|
1789 ( KMPXMediaVideoPlaybackCommand, EPbCmdTvOutEvent ); |
|
1790 message->SetTObjectValueL<TInt>( KMPXMediaVideoTvOutConnected, aConnected ); |
|
1791 message->SetTObjectValueL<TInt>( KMPXMediaVideoTvOutPlayAllowed, aPlaybackAllowed ); |
|
1792 |
|
1793 iMPXPluginObs->HandlePlaybackMessage( message, KErrNone ); |
|
1794 |
|
1795 CleanupStack::PopAndDestroy( message ); |
|
1796 } |
|
1797 |
|
1798 // ------------------------------------------------------------------------------------------------- |
|
1799 // CMPXVideoPlaybackController::SendHideControlsEventL |
|
1800 // ------------------------------------------------------------------------------------------------- |
|
1801 // |
|
1802 void CMPXVideoPlaybackController::SendHideControlsEventL() |
|
1803 { |
|
1804 MPX_ENTER_EXIT(_L("CMPXVideoPlaybackController::SendHideControlsEventL()")); |
|
1805 |
|
1806 // |
|
1807 // Send notice to the playback view to hide the controls |
|
1808 // when key lock |
|
1809 // |
|
1810 CMPXMessage* message = CMPXMessage::NewL(); |
|
1811 CleanupStack::PushL( message ); |
|
1812 |
|
1813 message->SetTObjectValueL<TMPXMessageId>( KMPXMessageGeneralId, KMPXMediaIdVideoPlayback ); |
|
1814 |
|
1815 message->SetTObjectValueL<TMPXVideoPlaybackCommand> |
|
1816 ( KMPXMediaVideoPlaybackCommand, EPbCmdHideControls ); |
|
1817 |
|
1818 iMPXPluginObs->HandlePlaybackMessage( message, KErrNone ); |
|
1819 |
|
1820 CleanupStack::PopAndDestroy( message ); |
|
1821 } |
|
1822 |
1768 // ------------------------------------------------------------------------------------------------ |
1823 // ------------------------------------------------------------------------------------------------ |
1769 // CMPXVideoPlaybackController::HandleTvOutEventL() |
1824 // CMPXVideoPlaybackController::HandleTvOutEventL() |
1770 // ------------------------------------------------------------------------------------------------ |
1825 // ------------------------------------------------------------------------------------------------ |
1771 // |
1826 // |
1772 void CMPXVideoPlaybackController::HandleTvOutEventL( TBool aConnected ) |
1827 void CMPXVideoPlaybackController::HandleTvOutEventL( TBool aConnected ) |
1773 { |
1828 { |
1774 MPX_ENTER_EXIT( _L("CMPXVideoPlaybackController::HandleTvOutEventL()"), |
1829 MPX_ENTER_EXIT( _L("CMPXVideoPlaybackController::HandleTvOutEventL()"), |
1775 _L("aConnected = %d"), aConnected ); |
1830 _L("aConnected = %d"), aConnected ); |
1776 |
1831 |
1777 TBool playbackAllowed = ETrue; |
1832 TBool playbackAllowed = iAccessoryMonitor->IsTvOutPlaybackAllowed(); |
1778 |
1833 |
|
1834 SendTvOutEventL( aConnected, playbackAllowed ); |
|
1835 |
|
1836 // |
|
1837 // Check playback status of clip with new Tv-Out status |
|
1838 // |
1779 if ( aConnected ) |
1839 if ( aConnected ) |
1780 { |
1840 { |
1781 // |
1841 // |
1782 // TV-Out accessory connected |
1842 // TV-Out accessory connected |
1783 // |
1843 // |
1784 if ( ! iAccessoryMonitor->IsTvOutPlaybackAllowed() ) |
1844 if ( ! playbackAllowed ) |
1785 { |
1845 { |
1786 // |
1846 // |
1787 // Clip has DRM protection and TV-Out is connected |
1847 // Clip has DRM protection and TV-Out is connected |
1788 // Pause playback and display info note |
1848 // Pause playback and display info note |
1789 // |
1849 // |
1790 DoHandleCommandL( EPbCmdPause ); |
1850 DoHandleCommandL( EPbCmdPause ); |
1791 |
1851 |
1792 playbackAllowed = EFalse; |
|
1793 |
|
1794 iState->SendErrorToViewL( KMPXVideoTvOutPlaybackNotAllowed ); |
1852 iState->SendErrorToViewL( KMPXVideoTvOutPlaybackNotAllowed ); |
1795 } |
1853 } |
1796 else |
1854 else |
1797 { |
1855 { |
1798 // If lights are being controlled enable display timer so that screen backlight will be turned |
1856 // If lights are being controlled enable display timer so that screen backlight will be turned |
1799 // of after timeout. |
1857 // of after timeout. |
1800 if ( iBackLightTimer->IsActive() ) |
1858 if ( iBackLightTimer->IsActive() ) |
1801 { |
1859 { |
1802 RestartDisplayTimer(); |
1860 RestartDisplayTimer(); |
1803 } |
1861 } |
1804 } |
1862 } |
1805 } |
1863 } |
1806 else |
1864 else |
1807 { |
1865 { |
1808 // TV out disconnected |
1866 // TV out disconnected |
1809 CancelDisplayTimer(); |
1867 CancelDisplayTimer(); |
1810 |
1868 |
1811 // Ensure that lights are on after this |
1869 // Ensure that lights are on after this |
1812 ReleaseLights(); |
1870 ReleaseLights(); |
1813 |
1871 |
1814 // Pause playback since TV-Out accessory has been disconnected. |
1872 // Pause playback since TV-Out accessory has been disconnected. |
1815 DoHandleCommandL( EPbCmdPause ); |
1873 DoHandleCommandL( EPbCmdPause ); |
1816 } |
1874 } |
1817 |
|
1818 // |
|
1819 // Send notice to the playback view with TV-Out connection status |
|
1820 // and TV-Out playback allowed flag |
|
1821 // |
|
1822 CMPXMessage* message = CMPXMessage::NewL(); |
|
1823 CleanupStack::PushL( message ); |
|
1824 |
|
1825 message->SetTObjectValueL<TMPXMessageId>( KMPXMessageGeneralId, KMPXMediaIdVideoPlayback ); |
|
1826 message->SetTObjectValueL<TMPXVideoPlaybackCommand> |
|
1827 ( KMPXMediaVideoPlaybackCommand, EPbCmdTvOutEvent ); |
|
1828 message->SetTObjectValueL<TInt>( KMPXMediaVideoTvOutConnected, aConnected ); |
|
1829 message->SetTObjectValueL<TInt>( KMPXMediaVideoTvOutPlayAllowed, playbackAllowed ); |
|
1830 |
|
1831 iMPXPluginObs->HandlePlaybackMessage( message, KErrNone ); |
|
1832 |
|
1833 CleanupStack::PopAndDestroy( message ); |
|
1834 } |
1875 } |
1835 |
1876 |
1836 // ------------------------------------------------------------------------------------------------ |
1877 // ------------------------------------------------------------------------------------------------ |
1837 // CMPXVideoPlaybackController::CancelBackLightTimer |
1878 // CMPXVideoPlaybackController::CancelBackLightTimer |
1838 // ------------------------------------------------------------------------------------------------ |
1879 // ------------------------------------------------------------------------------------------------ |
1931 // ----------------------------------------------------------------------------- |
1970 // ----------------------------------------------------------------------------- |
1932 // |
1971 // |
1933 void CMPXVideoPlaybackController::CancelLightsControl() |
1972 void CMPXVideoPlaybackController::CancelLightsControl() |
1934 { |
1973 { |
1935 MPX_ENTER_EXIT(_L("CMPXVideoPlaybackController::CancelLightsControl()")); |
1974 MPX_ENTER_EXIT(_L("CMPXVideoPlaybackController::CancelLightsControl()")); |
1936 |
1975 |
1937 // This is called whenever there is no need to keep screensaver of anymore |
1976 // This is called whenever there is no need to keep screensaver of anymore |
1938 // This means that also displaytimer and activity monitoring can be stopped. |
1977 // This means that also displaytimer and activity monitoring can be stopped. |
1939 // This method is not correct place for these calls |
1978 // This method is not correct place for these calls |
1940 CancelBackLightTimer(); |
1979 CancelBackLightTimer(); |
1941 |
1980 |
1942 CancelUserActivityTimer(); |
1981 CancelUserActivityTimer(); |
1943 |
1982 |
1944 CancelDisplayTimer(); |
1983 CancelDisplayTimer(); |
1945 |
1984 |
1946 // Ensure that lights are on |
1985 // Ensure that lights are on |
1947 EnableDisplayBacklight(); |
1986 EnableDisplayBacklight(); |
1948 |
1987 |
1949 // Release lights if releserved |
1988 // Release lights if releserved |
1950 ReleaseLights(); |
1989 ReleaseLights(); |
1951 } |
1990 } |
1952 |
1991 |
1953 |
1992 |
1954 // ----------------------------------------------------------------------------- |
1993 // ----------------------------------------------------------------------------- |
1955 // CMPXVideoPlaybackController::InitDisplayTimerL |
1994 // CMPXVideoPlaybackController::InitDisplayTimerL |
1956 // ----------------------------------------------------------------------------- |
1995 // ----------------------------------------------------------------------------- |
1957 // |
1996 // |
1958 TTimeIntervalMicroSeconds32 CMPXVideoPlaybackController::InitDisplayTimerL() |
1997 TTimeIntervalMicroSeconds32 CMPXVideoPlaybackController::InitDisplayTimerL() |
1959 { |
1998 { |
1960 MPX_ENTER_EXIT(_L("CMPXVideoPlaybackController::InitDisplayTimerL()")); |
1999 MPX_ENTER_EXIT(_L("CMPXVideoPlaybackController::InitDisplayTimerL()")); |
1961 |
2000 |
1962 if ( !iDisplayTimer ) |
2001 if ( !iDisplayTimer ) |
1963 { |
2002 { |
1964 iDisplayTimer = CPeriodic::NewL( CPeriodic::EPriorityStandard ); |
2003 iDisplayTimer = CPeriodic::NewL( CPeriodic::EPriorityStandard ); |
1965 |
2004 |
1966 MPX_DEBUG(_L("CMPXVideoPlaybackController::InitDisplayTimerL() - created") ); |
2005 MPX_DEBUG(_L("CMPXVideoPlaybackController::InitDisplayTimerL() - created") ); |
1967 |
2006 } |
1968 } |
2007 |
1969 |
|
1970 if ( iDisplayTimerTimeout.Int() == 0 ) |
2008 if ( iDisplayTimerTimeout.Int() == 0 ) |
1971 { |
2009 { |
1972 // Get the display light time-out value from CenRep |
2010 // Get the display light time-out value from CenRep |
1973 CRepository* repository = CRepository::NewLC( KCRUidLightSettings ); |
2011 CRepository* repository = CRepository::NewLC( KCRUidLightSettings ); |
1974 // What's the timeout value (in seconds ) for the display light? |
2012 // What's the timeout value (in seconds ) for the display light? |
1975 TInt displayTimeOut ( 0 ); |
2013 TInt displayTimeOut ( 0 ); |
1976 repository->Get( KDisplayLightsTimeout, displayTimeOut ); |
2014 repository->Get( KDisplayLightsTimeout, displayTimeOut ); |
1977 |
2015 |
1978 if ( ( displayTimeOut * KMPXMicroSecondsInASecond ) > KMaxTInt ) |
2016 if ( ( displayTimeOut * KMPXMicroSecondsInASecond ) > KMaxTInt ) |
1979 { |
2017 { |
1980 iDisplayTimerTimeout = KMaxTInt; |
2018 iDisplayTimerTimeout = KMaxTInt; |
1981 } |
2019 } |
1982 else |
2020 else |
1983 { |
2021 { |
1984 iDisplayTimerTimeout = displayTimeOut * KMPXMicroSecondsInASecond; |
2022 iDisplayTimerTimeout = displayTimeOut * KMPXMicroSecondsInASecond; |
1985 } |
2023 } |
1986 |
2024 |
1987 CleanupStack::PopAndDestroy( repository ); |
2025 CleanupStack::PopAndDestroy( repository ); |
1988 } |
2026 } |
1989 |
2027 |
1990 |
|
1991 MPX_DEBUG( _L("CMPXVideoPlaybackController::InitDisplayTimerL Timeout(%d)"), iDisplayTimerTimeout.Int() ); |
2028 MPX_DEBUG( _L("CMPXVideoPlaybackController::InitDisplayTimerL Timeout(%d)"), iDisplayTimerTimeout.Int() ); |
1992 |
2029 |
1993 // Convert the timeout value to microseconds |
2030 // Convert the timeout value to microseconds |
1994 return iDisplayTimerTimeout; |
2031 return iDisplayTimerTimeout; |
1995 } |
2032 } |
1996 |
2033 |
1997 // ----------------------------------------------------------------------------- |
2034 // ----------------------------------------------------------------------------- |
1998 // CMPXVideoPlaybackController::RestartDisplayTimer |
2035 // CMPXVideoPlaybackController::RestartDisplayTimer |
1999 // ----------------------------------------------------------------------------- |
2036 // ----------------------------------------------------------------------------- |
2004 |
2041 |
2005 TTimeIntervalMicroSeconds32 displayTimeOut(0); |
2042 TTimeIntervalMicroSeconds32 displayTimeOut(0); |
2006 // Leave system to safe state if following leaves. Lights stay on |
2043 // Leave system to safe state if following leaves. Lights stay on |
2007 MPX_TRAPD(err, displayTimeOut=InitDisplayTimerL(); ) |
2044 MPX_TRAPD(err, displayTimeOut=InitDisplayTimerL(); ) |
2008 if ( err == KErrNone ) |
2045 if ( err == KErrNone ) |
2009 { |
2046 { |
2010 // check if the display timer is running and cancel it |
2047 // check if the display timer is running and cancel it |
2011 if ( iDisplayTimer->IsActive() ) |
2048 if ( iDisplayTimer->IsActive() ) |
2012 { |
2049 { |
2013 iDisplayTimer->Cancel(); |
2050 iDisplayTimer->Cancel(); |
2014 } |
2051 } |
2015 |
2052 |
2016 MPX_DEBUG( _L("CMPXVideoPlaybackController::RestartDisplayTimer() restarting displayTimer to=%d ms"), displayTimeOut.Int() ); |
2053 MPX_DEBUG( _L("CMPXVideoPlaybackController::RestartDisplayTimer() restarting displayTimer to=%d ms"), displayTimeOut.Int() ); |
2017 |
2054 |
2018 iDisplayTimer->Start( displayTimeOut, displayTimeOut, |
2055 iDisplayTimer->Start( displayTimeOut, displayTimeOut, |
2019 TCallBack( CMPXVideoPlaybackController::HandleDisplayTimeout, this ) ); |
2056 TCallBack( CMPXVideoPlaybackController::HandleDisplayTimeout, this ) ); |
2020 } |
2057 } |
2021 |
|
2022 } |
2058 } |
2023 |
2059 |
2024 // ----------------------------------------------------------------------------- |
2060 // ----------------------------------------------------------------------------- |
2025 // CMPXVideoPlaybackController::CancelDisplayTimer |
2061 // CMPXVideoPlaybackController::CancelDisplayTimer |
2026 // ----------------------------------------------------------------------------- |
2062 // ----------------------------------------------------------------------------- |
2027 // |
2063 // |
2028 void CMPXVideoPlaybackController::CancelDisplayTimer() |
2064 void CMPXVideoPlaybackController::CancelDisplayTimer() |
2029 { |
2065 { |
2030 MPX_ENTER_EXIT(_L("CMPXVideoPlaybackController::CancelDisplayTimer")); |
2066 MPX_ENTER_EXIT(_L("CMPXVideoPlaybackController::CancelDisplayTimer")); |
2031 |
2067 |
2032 if ( iDisplayTimer ) |
2068 if ( iDisplayTimer ) |
2033 { |
2069 { |
2034 if ( iDisplayTimer->IsActive() ) |
2070 if ( iDisplayTimer->IsActive() ) |
2035 { |
2071 { |
2036 iDisplayTimer->Cancel(); |
2072 iDisplayTimer->Cancel(); |
2069 |
2105 |
2070 |
2106 |
2071 // ------------------------------------------------------------------------------------------------ |
2107 // ------------------------------------------------------------------------------------------------ |
2072 // CMPXVideoPlaybackController::EnableDisplayBacklight |
2108 // CMPXVideoPlaybackController::EnableDisplayBacklight |
2073 // ------------------------------------------------------------------------------------------------ |
2109 // ------------------------------------------------------------------------------------------------ |
2074 // |
2110 // |
2075 void CMPXVideoPlaybackController::EnableDisplayBacklight() |
2111 void CMPXVideoPlaybackController::EnableDisplayBacklight() |
2076 { |
2112 { |
2077 MPX_ENTER_EXIT(_L("CMPXVideoPlaybackController::EnableDisplayBacklight()")); |
2113 MPX_ENTER_EXIT(_L("CMPXVideoPlaybackController::EnableDisplayBacklight()")); |
2078 |
2114 |
2079 // ELightStatusUnknown - We are not controlling lights and we don't care about lights |
2115 // ELightStatusUnknown - We are not controlling lights and we don't care about lights |
2080 // ELightOn - Ligths are certainly on |
2116 // ELightOn - Ligths are certainly on |
2081 MPX_DEBUG(_L("CMPXVideoPlaybackController::EnableDisplayBacklight() iLightStatus=%d"), iLightStatus ); |
2117 MPX_DEBUG(_L("CMPXVideoPlaybackController::EnableDisplayBacklight() iLightStatus=%d"), iLightStatus ); |
2082 |
2118 |
2083 // We are responsible of turning lights on only if we have switched them off. |
2119 // We are responsible of turning lights on only if we have switched them off. |
2084 if ( iLightStatus == CHWRMLight::ELightOff ) |
2120 if ( iLightStatus == CHWRMLight::ELightOff ) |
2085 { |
2121 { |
2086 |
2122 |
2087 MPX_TRAPD( err, |
2123 MPX_TRAPD( err, |
2088 { |
2124 { |
2089 // Following GetLightsL() call will not leave. |
2125 // Following GetLightsL() call will not leave. |
2090 // This call should not result to creation of CHWRMLight in this case |
2126 // This call should not result to creation of CHWRMLight in this case |
2091 // because CHWRMLight was created when lights were turned off. |
2127 // because CHWRMLight was created when lights were turned off. |
2092 CHWRMLight* lights= GetLightsL(); |
2128 CHWRMLight* lights= GetLightsL(); |
2093 if ( lights->LightStatus(CHWRMLight::EPrimaryDisplay) == CHWRMLight::ELightOff ) |
2129 if ( lights->LightStatus(CHWRMLight::EPrimaryDisplay) == CHWRMLight::ELightOff ) |
2094 { |
2130 { |
2095 MPX_DEBUG(_L("CMPXVideoPlaybackController::EnableDisplayBacklight() enabling") ); |
2131 MPX_DEBUG(_L("CMPXVideoPlaybackController::EnableDisplayBacklight() enabling") ); |
2096 |
2132 |
2097 lights->LightOnL( CHWRMLight::EPrimaryDisplay, 0 ); |
2133 lights->LightOnL( CHWRMLight::EPrimaryDisplay, 0 ); |
2098 iLightStatus = CHWRMLight::ELightOn; |
2134 iLightStatus = CHWRMLight::ELightOn; |
2099 } |
2135 } |
2100 } ); |
2136 } ); |
2101 |
2137 } |
2102 } |
|
2103 |
|
2104 } |
2138 } |
2105 |
2139 |
2106 // ------------------------------------------------------------------------------------------------ |
2140 // ------------------------------------------------------------------------------------------------ |
2107 // CMPXVideoPlaybackController::DisableDisplayBacklight |
2141 // CMPXVideoPlaybackController::DisableDisplayBacklight |
2108 // ------------------------------------------------------------------------------------------------ |
2142 // ------------------------------------------------------------------------------------------------ |
2109 // |
2143 // |
2110 void CMPXVideoPlaybackController::DisableDisplayBacklight() |
2144 void CMPXVideoPlaybackController::DisableDisplayBacklight() |
2111 { |
2145 { |
2112 MPX_ENTER_EXIT(_L("CMPXVideoPlaybackController::DisableDisplayBacklight()")); |
2146 MPX_ENTER_EXIT(_L("CMPXVideoPlaybackController::DisableDisplayBacklight()")); |
2113 |
2147 |
2114 // No major harm done if following block leaves. Lights are left on |
2148 // No major harm done if following block leaves. Lights are left on |
2115 MPX_TRAPD( err, |
2149 MPX_TRAPD( err, |
2116 { |
2150 { |
2117 CHWRMLight* lights = GetLightsL(); |
2151 CHWRMLight* lights = GetLightsL(); |
2118 if ( lights->LightStatus(CHWRMLight::EPrimaryDisplay) == CHWRMLight::ELightOn ) |
2152 if ( lights->LightStatus(CHWRMLight::EPrimaryDisplay) == CHWRMLight::ELightOn ) |
2119 { |
2153 { |
2120 MPX_DEBUG(_L("CMPXVideoPlaybackController::DisableDisplayBacklight() disabling") ); |
2154 MPX_DEBUG(_L("CMPXVideoPlaybackController::DisableDisplayBacklight() disabling") ); |
2121 |
2155 |
2122 lights->LightOffL( CHWRMLight::EPrimaryDisplay, 0 ); |
2156 lights->LightOffL( CHWRMLight::EPrimaryDisplay, 0 ); |
2123 iLightStatus = CHWRMLight::ELightOff; |
2157 iLightStatus = CHWRMLight::ELightOff; |
2124 } |
2158 } |
2125 } ); |
2159 } ); |
2126 |
|
2127 } |
2160 } |
2128 |
2161 |
2129 |
2162 |
2130 // ------------------------------------------------------------------------------------------------ |
2163 // ------------------------------------------------------------------------------------------------ |
2131 // CMPXVideoPlaybackController::InitUserActivityTimer |
2164 // CMPXVideoPlaybackController::InitUserActivityTimer |
2132 // ------------------------------------------------------------------------------------------------ |
2165 // ------------------------------------------------------------------------------------------------ |
2133 // |
2166 // |
2134 void CMPXVideoPlaybackController::InitUserActivityTimerL() |
2167 void CMPXVideoPlaybackController::InitUserActivityTimerL() |
2135 { |
2168 { |
2136 MPX_ENTER_EXIT(_L("CMPXVideoPlaybackController::InitUserActivityTimerL()")); |
2169 MPX_ENTER_EXIT(_L("CMPXVideoPlaybackController::InitUserActivityTimerL()")); |
2137 |
2170 |
2138 iUserActivityTimer = CPeriodic::NewL( CActive::EPriorityStandard); |
2171 iUserActivityTimer = CPeriodic::NewL( CActive::EPriorityStandard); |
2139 |
2172 |
2140 // This timer will not run to the end. Timer will be canceled and reset at backlight timeout. |
2173 // This timer will not run to the end. Timer will be canceled and reset at backlight timeout. |
2141 iUserActivityTimer->Start( |
2174 iUserActivityTimer->Start( |
2142 0, |
2175 0, |
2143 KMPXInactivityTimeout, |
2176 KMPXInactivityTimeout, |
2144 TCallBack( CMPXVideoPlaybackController::HandleUserActivityTimeout, this )); |
2177 TCallBack( CMPXVideoPlaybackController::HandleUserActivityTimeout, this )); |
2145 |
|
2146 } |
2178 } |
2147 |
2179 |
2148 // ------------------------------------------------------------------------------------------------ |
2180 // ------------------------------------------------------------------------------------------------ |
2149 // CMPXVideoPlaybackController::RestartUserActivityTimer |
2181 // CMPXVideoPlaybackController::RestartUserActivityTimer |
2150 // ------------------------------------------------------------------------------------------------ |
2182 // ------------------------------------------------------------------------------------------------ |
2151 // |
2183 // |
2152 void CMPXVideoPlaybackController::RestartUserActivityTimer() |
2184 void CMPXVideoPlaybackController::RestartUserActivityTimer() |
2153 { |
2185 { |
2154 MPX_ENTER_EXIT(_L("CMPXVideoPlaybackController::RestartUserActivityTimer()")); |
2186 MPX_ENTER_EXIT(_L("CMPXVideoPlaybackController::RestartUserActivityTimer()")); |
2155 |
2187 |
2156 if ( !iUserActivityTimer ) |
2188 if ( !iUserActivityTimer ) |
2157 { |
2189 { |
2158 // This is first call. Create and initialize timer |
2190 // This is first call. Create and initialize timer |
2159 MPX_TRAPD( err, |
2191 MPX_TRAPD( err, |
2160 { |
2192 { |
2161 InitUserActivityTimerL(); |
2193 InitUserActivityTimerL(); |
2162 } ); |
2194 } ); |
2163 // If user activity timer creation fails we can't detect user activity and |
2195 |
2164 // get lights back on when user taps screen. |
2196 // If user activity timer creation fails we can't detect user activity and |
|
2197 // get lights back on when user taps screen. |
2165 // Leave lights on. |
2198 // Leave lights on. |
2166 if ( err != KErrNone ) |
2199 if ( err != KErrNone ) |
2167 { |
2200 { |
2168 EnableDisplayBacklight(); |
2201 EnableDisplayBacklight(); |
2169 } |
2202 } |
2170 } |
2203 } |
2171 |
2204 |
2172 if ( iUserActivityTimer ) |
2205 if ( iUserActivityTimer ) |
2173 { |
2206 { |
2174 if ( iUserActivityTimer->IsActive() ) |
2207 if ( iUserActivityTimer->IsActive() ) |
2175 { |
2208 { |
2176 iUserActivityTimer->Cancel(); |
2209 iUserActivityTimer->Cancel(); |
2177 } |
2210 } |
|
2211 |
2178 // Not interested about inactivity callback, only activity |
2212 // Not interested about inactivity callback, only activity |
2179 // If CPeriodic::Inactivity is started with argument 0 |
2213 // If CPeriodic::Inactivity is started with argument 0 |
2180 // timer will fire when system's user inactivity timer resets. |
2214 // timer will fire when system's user inactivity timer resets. |
2181 iUserActivityTimer->Inactivity( 0 ); |
2215 iUserActivityTimer->Inactivity( 0 ); |
2182 } |
2216 } |
2183 } |
2217 } |
2184 |
2218 |
2185 // ------------------------------------------------------------------------------------------------ |
2219 // ------------------------------------------------------------------------------------------------ |
2186 // CMPXVideoPlaybackController::CancelUserActivityTimer |
2220 // CMPXVideoPlaybackController::CancelUserActivityTimer |
2187 // ------------------------------------------------------------------------------------------------ |
2221 // ------------------------------------------------------------------------------------------------ |
2188 // |
2222 // |
2189 void CMPXVideoPlaybackController::CancelUserActivityTimer() |
2223 void CMPXVideoPlaybackController::CancelUserActivityTimer() |
2190 { |
2224 { |
2191 MPX_ENTER_EXIT(_L("CMPXVideoPlaybackController::CancelUserActivityTimer()")); |
2225 MPX_ENTER_EXIT(_L("CMPXVideoPlaybackController::CancelUserActivityTimer()")); |
2192 |
2226 |
2193 if ( iUserActivityTimer ) |
2227 if ( iUserActivityTimer ) |
2194 { |
2228 { |
2195 if ( iUserActivityTimer->IsActive() ) |
2229 if ( iUserActivityTimer->IsActive() ) |
2196 { |
2230 { |
2197 iUserActivityTimer->Cancel(); |
2231 iUserActivityTimer->Cancel(); |
2198 } |
2232 } |
2199 } |
2233 } |
2200 } |
2234 } |
2201 |
2235 |
2202 // ------------------------------------------------------------------------------------------------ |
2236 // ------------------------------------------------------------------------------------------------ |
2203 // CMPXVideoPlaybackController::HandleUserActivityTimeout |
2237 // CMPXVideoPlaybackController::HandleUserActivityTimeout |
2204 // ------------------------------------------------------------------------------------------------ |
2238 // ------------------------------------------------------------------------------------------------ |
2205 // |
2239 // |
2206 TInt CMPXVideoPlaybackController::HandleUserActivityTimeout( TAny* aPtr ) |
2240 TInt CMPXVideoPlaybackController::HandleUserActivityTimeout( TAny* aPtr ) |
2207 { |
2241 { |
2208 MPX_ENTER_EXIT(_L("CMPXVideoPlaybackController::HandleUserActivityTimeout()")); |
2242 MPX_ENTER_EXIT(_L("CMPXVideoPlaybackController::HandleUserActivityTimeout()")); |
2209 |
2243 |
2210 static_cast<CMPXVideoPlaybackController*>(aPtr)->DoHandleUserActivityTimeout(); |
2244 static_cast<CMPXVideoPlaybackController*>(aPtr)->DoHandleUserActivityTimeout(); |
2211 return KErrNone; |
2245 return KErrNone; |
2212 } |
2246 } |
2213 |
2247 |
2214 // ------------------------------------------------------------------------------------------------ |
2248 // ------------------------------------------------------------------------------------------------ |
2215 // CMPXVideoPlaybackController::DoHandleUserActivityTimeout |
2249 // CMPXVideoPlaybackController::DoHandleUserActivityTimeout |
2216 // ------------------------------------------------------------------------------------------------ |
2250 // ------------------------------------------------------------------------------------------------ |
2217 // |
2251 // |
2218 void CMPXVideoPlaybackController::DoHandleUserActivityTimeout() |
2252 void CMPXVideoPlaybackController::DoHandleUserActivityTimeout() |
2219 { |
2253 { |
2220 MPX_ENTER_EXIT(_L("CMPXVideoPlaybackController::DoHandleUserActivityTimeout()")); |
2254 MPX_ENTER_EXIT(_L("CMPXVideoPlaybackController::DoHandleUserActivityTimeout()")); |
2221 |
2255 |
2222 // Act only once for detected activity. |
2256 // Act only once for detected activity. |
2223 if ( iUserActivityTimer->IsActive() ) |
2257 if ( iUserActivityTimer->IsActive() ) |
2224 { |
2258 { |
2225 iUserActivityTimer->Cancel(); |
2259 iUserActivityTimer->Cancel(); |
2226 } |
2260 } |
2227 |
2261 |
2228 // iUserActivityTimer runs when TV-out is connected and playback with video is going on |
2262 // iUserActivityTimer runs when TV-out is connected and playback with video is going on |
2229 // This timer fires in two situations. |
2263 // This timer fires in two situations. |
2230 // a) Lights are off and user activity is detected - Turn lights on and restart display timer |
2264 // a) Lights are off and user activity is detected - Turn lights on and restart display timer |
2231 // b) Lights are on and user activity is detected - restart display timer to prevent lights go off |
2265 // b) Lights are on and user activity is detected - restart display timer to prevent lights go off |
2232 EnableDisplayBacklight(); |
2266 EnableDisplayBacklight(); |
2233 |
2267 |
2234 // Start counting down to next lights off |
2268 // Start counting down to next lights off |
2235 RestartDisplayTimer(); |
2269 RestartDisplayTimer(); |
2236 } |
2270 } |
2237 |
2271 |
2238 // ------------------------------------------------------------------------------------------------ |
2272 // ------------------------------------------------------------------------------------------------ |