Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/video/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
根文件系统的Qt QML Mediaplayer源地址_Qt_Video_Qml - Fatal编程技术网

根文件系统的Qt QML Mediaplayer源地址

根文件系统的Qt QML Mediaplayer源地址,qt,video,qml,Qt,Video,Qml,我尝试使用QML Mediaplayer播放视频。我的Qt版本是5.3.1,我使用的代码是: MediaPlayer { id: mediaplayer source: ./video.mp4 loops: MediaPlayer.Infinite onError: { console.debug("mediaplayer video error\n"); console.debug(err

我尝试使用QML Mediaplayer播放视频。我的Qt版本是5.3.1,我使用的代码是:

 MediaPlayer {

       id: mediaplayer
       source: ./video.mp4
       loops: MediaPlayer.Infinite

       onError: {
           console.debug("mediaplayer video error\n");
           console.debug(errorString);
       }

       onPlaying: {
           console.debug("mediplayer plays, hasVideo: ", hasVideo, "\n");
           console.debug("videoplayer source address: ", source, "\n");
       }
     }
我想播放与Qt应用程序位于同一目录下的视频。但当播放开始时,我得到:

mediplayer播放,hasVideo:错误 视频播放器源地址:qrc:///video.mp4

我试图给出如下的源路径:

source: Qt.resolvedUrl("./video.mp4")
但结果并没有改变

如果我尝试通过提供源url从qrc播放视频:

source: "qrc:///video.mp4"
它记录:

mediplayer播放,hasVideo:错误 视频播放器源地址:qrc:///video.mp4


但视频不会播放。如何使mediaplayer的“hasVideo:true”播放该视频?

是否已将视频添加到qt资源?我建议在qt资源编辑器中使用QtCreator上下文菜单元素“将资源路径复制到剪贴板”。在我看来,您提供的资源路径不正确(在我看来也应该是“video.mp4”),我也尝试过,但没有成功。您是否已将视频添加到qt资源?我建议在qt资源编辑器中使用QtCreator上下文菜单元素“将资源路径复制到剪贴板”。在我看来,您提供的资源路径是不正确的(在我看来,它应该只是“video.mp4”),我也尝试过,但它不起作用。