|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Implementation of VideoPlaybackWrapper |
|
15 * |
|
16 */ |
|
17 |
|
18 // Version : %version: 6 % |
|
19 |
|
20 |
|
21 #include "mpxvideo_debug.h" |
|
22 #include "videoplaybackwrapper.h" |
|
23 #include "mpxvideoplayerappuiengine.h" |
|
24 |
|
25 |
|
26 // ------------------------------------------------------------------------------------------------- |
|
27 // VideoPlaybackWrapper::VideoPlaybackWrapper() |
|
28 // ------------------------------------------------------------------------------------------------- |
|
29 // |
|
30 VideoPlaybackWrapper::VideoPlaybackWrapper() |
|
31 { |
|
32 MPX_ENTER_EXIT(_L("VideoPlaybackWrapper::VideoPlaybackWrapper()")); |
|
33 |
|
34 initializePlugins(); |
|
35 } |
|
36 |
|
37 // ------------------------------------------------------------------------------------------------- |
|
38 // VideoPlaybackWrapper::~VideoPlaybackWrapper() |
|
39 // ------------------------------------------------------------------------------------------------- |
|
40 // |
|
41 VideoPlaybackWrapper::~VideoPlaybackWrapper() |
|
42 { |
|
43 MPX_ENTER_EXIT(_L("VideoPlaybackWrapper::~VideoPlaybackWrapper()")); |
|
44 |
|
45 if ( mUiEngine ) |
|
46 { |
|
47 delete mUiEngine; |
|
48 mUiEngine = NULL; |
|
49 } |
|
50 } |
|
51 |
|
52 // ------------------------------------------------------------------------------------------------- |
|
53 // VideoPlaybackWrapper::initializePlugins() |
|
54 // ------------------------------------------------------------------------------------------------- |
|
55 // |
|
56 void VideoPlaybackWrapper::initializePlugins() |
|
57 { |
|
58 MPX_ENTER_EXIT(_L("VideoPlaybackWrapper::initializePlugins()")); |
|
59 |
|
60 TRAPD( err, mUiEngine = CMpxVideoPlayerAppUiEngine::NewL( this ) ); |
|
61 MPX_DEBUG(_L("VideoPlaybackWrapper::initializePlugins err = %d"), err); |
|
62 Q_UNUSED(err); |
|
63 } |
|
64 |
|
65 // ------------------------------------------------------------------------------------------------- |
|
66 // VideoPlaybackWrapper::playMedia() |
|
67 // ------------------------------------------------------------------------------------------------- |
|
68 // |
|
69 int VideoPlaybackWrapper::playMedia( QString aFileName ) |
|
70 { |
|
71 MPX_DEBUG(_L("VideoPlaybackWrapper::playMedia( %s )"), aFileName.data() ); |
|
72 |
|
73 TBuf<KMaxFileName> filename( aFileName.utf16() ); |
|
74 int error = openFileWithNativePath( filename ); |
|
75 |
|
76 MPX_DEBUG(_L("VideoPlaybackWrapper::playMedia err = %d"), error); |
|
77 |
|
78 return error; |
|
79 } |
|
80 |
|
81 // ------------------------------------------------------------------------------------------------- |
|
82 // VideoPlaybackWrapper::playMedia() |
|
83 // ------------------------------------------------------------------------------------------------- |
|
84 // |
|
85 int VideoPlaybackWrapper::playMedia( RFile aFile ) |
|
86 { |
|
87 MPX_ENTER_EXIT(_L("VideoPlaybackWrapper::playMedia( aFile )")); |
|
88 |
|
89 TRAPD( error, mUiEngine->OpenFileL( aFile ) ); |
|
90 |
|
91 MPX_DEBUG(_L("VideoPlaybackWrapper::playMedia err = %d"), error); |
|
92 |
|
93 return error; |
|
94 } |
|
95 |
|
96 // ------------------------------------------------------------------------------------------------- |
|
97 // VideoPlaybackWrapper::openPlaybackView() |
|
98 // ------------------------------------------------------------------------------------------------- |
|
99 // |
|
100 void VideoPlaybackWrapper::openPlaybackView() |
|
101 { |
|
102 MPX_ENTER_EXIT(_L("VideoPlaybackWrapper::openPlaybackView()")); |
|
103 |
|
104 emit handlePlaybackView( MpxHbVideoCommon::ActivatePlaybackView ); |
|
105 } |
|
106 |
|
107 // ------------------------------------------------------------------------------------------------- |
|
108 // VideoPlaybackWrapper::postInit() |
|
109 // ------------------------------------------------------------------------------------------------- |
|
110 // |
|
111 void VideoPlaybackWrapper::lateInit() |
|
112 { |
|
113 MPX_ENTER_EXIT(_L("VideoPlaybackWrapper::lateInit()")); |
|
114 |
|
115 TRAP_IGNORE( mUiEngine->LateInitL() ); |
|
116 } |
|
117 |
|
118 // ------------------------------------------------------------------------------------------------- |
|
119 // VideoPlaybackWrapper::openFileWithNativePath() |
|
120 // ------------------------------------------------------------------------------------------------- |
|
121 // |
|
122 int VideoPlaybackWrapper::openFileWithNativePath(const TDesC& aFileName) |
|
123 { |
|
124 MPX_DEBUG(_L("VideoPlaybackWrapper::openFileWithNativePath()")); |
|
125 |
|
126 int err = KErrNone; |
|
127 |
|
128 int fwdSlashPos = aFileName.LocateF('/'); |
|
129 |
|
130 if( fwdSlashPos == KErrNotFound ) |
|
131 { |
|
132 // no fwd slashes found => filepath is already in |
|
133 // preferred format eg. c:\\data\\videos\\test.3gp |
|
134 // |
|
135 TRAP( err, mUiEngine->OpenFileL( aFileName ) ); |
|
136 } |
|
137 else |
|
138 { |
|
139 HBufC* fileName = NULL; |
|
140 |
|
141 TRAP( err, fileName = aFileName.AllocL() ); |
|
142 |
|
143 if ( err == KErrNone ) |
|
144 { |
|
145 int count( fileName->Des().Length() ); |
|
146 |
|
147 for ( int j = fwdSlashPos ; j < count; ++j ) |
|
148 { |
|
149 if ( fileName->Des()[j]== '/' ) |
|
150 { |
|
151 fileName->Des()[j]='\\'; |
|
152 } |
|
153 } |
|
154 |
|
155 } |
|
156 |
|
157 TRAP( err, mUiEngine->OpenFileL( fileName->Des() ) ); |
|
158 |
|
159 if ( fileName ) |
|
160 { |
|
161 delete fileName; |
|
162 fileName = NULL; |
|
163 } |
|
164 } |
|
165 |
|
166 return err; |
|
167 } |
|
168 |
|
169 |
|
170 // End of File |