Incorrect resolution in Qt Quick application
-
I run a simple app using Mediaplayer and VideoOutput to showing a HD video on Android TV.
I use Screen.width and Screen.height for my Window object. But detected screen is 1280x720.My main.qml is:
import QtQuick import QtQuick.Window import QtMultimedia Window { id: mainWindow width: Screen.width height: Screen.height visible: true Rectangle { id: mw anchors.fill: parent color: "red" focus: true VideoOutput { id: videoOutput anchors.fill: parent } MediaPlayer { id: item_id audioOutput: AudioOutput {} videoOutput: videoOutput } Keys.onReturnPressed: { if (item_id.playbackState == MediaPlayer.PlayingState) { item_id.pause() console.log("Qt Player: "+videoOutput.width); console.log("Qt Player: "+videoOutput.height); } else if (item_id.playbackState == MediaPlayer.PausedState) { item_id.play() } else { item_id.source = "file:///storage/emulated/0/download/371.mp4" item_id.play(); console.log("Starting ...") console.log("Qt Scene: "+mainWindow.width); console.log("Qt Scene: "+mainWindow.height); } } Keys.onLeftPressed: item_id.setPosition(item_id.position-3000) Keys.onRightPressed: item_id.setPosition(item_id.position+3000) } Component.onCompleted: { // showFullScreen() show() } }
I tested my Android TV with a simple app with the same structure written in Android Studio and detected resolution is 1920x1080.
My Mainactivity.java is:
public class MainActivity extends Activity { public static VideoView videoView; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // Native Player MainActivity.videoView = (VideoView) findViewById(R.id.videoView); String videoURL = "file:///storage/emulated/0/download/371.mp4"; Uri uri = Uri.parse(videoURL); MainActivity.videoView.setVideoURI(uri); MainActivity.videoView.start(); MainActivity.videoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() { @Override public void onPrepared(MediaPlayer mp) { Log.e("> ", "Media is prepared. Playing ..."); Log.e("> ", "W: "+MainActivity.videoView.getWidth()); Log.e("> ", "H: "+MainActivity.videoView.getHeight()); } }); } }
What is the problem?