repair video playback

This commit is contained in:
LubuWest 2024-05-01 21:23:16 +02:00
parent b59513ab91
commit 0dc0ce7f35
21 changed files with 133 additions and 143 deletions

View file

@ -13,7 +13,7 @@ if(CMAKE_VERSION VERSION_LESS "3.7.0")
set(CMAKE_INCLUDE_CURRENT_DIR ON)
endif()
find_package(Qt6 REQUIRED COMPONENTS Core Widgets Quick QuickControls2 Sql DBus NetworkAuth Multimedia REQUIRED)
find_package(Qt6 REQUIRED COMPONENTS Core Quick QuickControls2 Widgets Sql DBus NetworkAuth Multimedia REQUIRED)
qt_standard_project_setup()

View file

@ -355,7 +355,7 @@ void XHR::onReplyError(QNetworkReply::NetworkError code)
void XHR::onReplySuccess()
{
qDebug() << "!";
QHashIterator<QString, QString> i(params);
//QHashIterator<QString, QString> i(params);
// while(i.hasNext()) {
// i.next();
// //qDebug() << i.key()<< " " << i.value();

View file

@ -41,40 +41,42 @@ function requestFriends(login,database,rootwindow,callback){
var result2 = tx.executeSql('DELETE from groups where username="'+login.username+'"'); // clean old groups
})
// /api/statuses/friends not working in Friendica 2/2022 , switching to api/v1/lists and download of all list members
// Helperjs.friendicaRequest(login,"/api/statuses/friends?count=9999", rootwindow,function (obj){
var allfriends=[];
Helperjs.friendicaRequest(login,"/api/v1/lists",rootwindow,function(listsobj){
var lists=JSON.parse(listsobj)
for (var list in lists){
Helperjs.friendicaRequest(login,"/api/v1/lists/"+lists[list].id+"/accounts?limit=0", rootwindow,function (obj){
var friends=JSON.parse(obj);
var memberarray=[];
Helperjs.friendicaRequest(login,"/api/statuses/friends?count=9999", rootwindow,function (obj){
//var allfriends=[];
//Helperjs.friendicaRequest(login,"/api/v1/lists",rootwindow,function(listsobj){
// var lists=JSON.parse(listsobj)
// for (var list in lists){
// Helperjs.friendicaRequest(login,"/api/v1/lists/"+lists[list].id+"/accounts?limit=0", rootwindow,function (obj){
let friendsobj=JSON.parse(obj);
let friends=friendsobj.users;
//var memberarray=[];
for (var i=0;i<friends.length;i++){
if (friends[i].note!=null){
friends[i].description=friends[i].note;}
else{friends[i].description=""}
friends[i].name=friends[i].display_name;
friends[i].screen_name=friends[i].acct;
friends[i].location="";
friends[i].profile_image=friends[i].avatar_static;
friends[i].profile_image_url=friends[i].avatar;
friends[i].protected=false;
friends[i].friends_count=friends[i].following_count;
friends[i].created_at=Date.parse(friends[i].created_at);
friends[i].favorites_count=0;
friends[i].utc_offset=0;
// if (friends[i].note!=null){
// friends[i].description=friends[i].note;}
// else{friends[i].description=""}
// friends[i].name=friends[i].display_name;
// friends[i].screen_name=friends[i].acct;
// friends[i].location="";
// friends[i].profile_image=friends[i].avatar_static;
// friends[i].profile_image_url=friends[i].avatar;
// friends[i].protected=false;
// friends[i].friends_count=friends[i].following_count;
friends[i].created_at=Date.parse(cleanDate(friends[i].created_at));
// friends[i].favorites_count=0;
// friends[i].utc_offset=0;
friends[i].isFriend=1
friends[i].cid=0
friends[i].following=true
memberarray.push(parseInt(friends[i].id))
// friends[i].cid=0
// friends[i].following=true
//memberarray.push(parseInt(friends[i].id))
}
//requestGroups() not working with Friendica 02/2022
db.transaction( function(tx) {
var result3 = tx.executeSql('INSERT INTO groups VALUES (?,?,?,?)', [login.username,lists[list].title,lists[list].id,JSON.stringify(memberarray)])
})
// db.transaction( function(tx) {
// var result3 = tx.executeSql('INSERT INTO groups VALUES (?,?,?,?)', [login.username,lists[list].title,lists[list].id,JSON.stringify(memberarray)])
// })
callback(friends)
})};
});
})
//};
//});
}

View file

@ -548,7 +548,7 @@ function showGroups(){
Helperjs.readData(db,"groups",login.username,function(groups){
var groupitems="";
for (var i=0;i<groups.length;i++){
groupitems=groupitems+"MenuItem{text:'"+groups[i].groupname+"'; onTriggered: {print('getGroupnews');Service.getGroupnews("+groups[i].gid+")}}"
groupitems=groupitems+"MenuItem{text:'"+groups[i].groupname+"'; onTriggered: {Service.getGroupnews("+groups[i].gid+")}}"
}
var menuString="import QtQuick.Controls 6.3; import 'qrc:/js/service.js' as Service; Menu {"+groupitems+"}";
var grouplistObject=Qt.createQmlObject(menuString,newstabitem,"groupmenuOutput");
@ -564,7 +564,7 @@ function setBackgroundsync(){
},"k","lastsync")
}
function getGroupnews(list){print("Liste "+list);
function getGroupnews(list){
newstab.newstabstatus="Group news";
newsBusy.running=true;
xhr.setAccount(login);

View file

@ -102,7 +102,7 @@ Rectangle{
}
}
onClicked:{print (JSON.stringify(event))
onClicked:{
if (status==""){
rootstackView.push("qrc:/qml/calendarqml/EventList.qml",{"dayint": event.startday, "events":[event]});
} else {rootstackView.pop()}

View file

@ -62,7 +62,7 @@ Page{
Helperjs.friendicaRequest(userconfig,"/api/v1/accounts/verify_credentials",root,function(obj){
accountBusy.running=false;
try{var credentials=JSON.parse(obj);
if (credentials.hasOwnProperty('error')){print("error "+credentials.error);
if (credentials.hasOwnProperty('error')){
Helperjs.showMessage(qsTr("Error"),qsTr("Wrong password or 2FA enabled!"),root)
}
else{
@ -479,13 +479,13 @@ Page{
function onSuccess(text,api){
if(api=="/api/v1/instance/rules"){
let rulestext="";
let rulesarray=JSON.parse(text)
try{let rulesarray=JSON.parse(text)
for (let rule in rulesarray){
rulestext=rulestext+rulesarray[rule].text+"\n"
}
var component = Qt.createComponent("qrc:/qml/configqml/AcceptRules.qml");
var rulesdialog = component.createObject(accountPage,{"rules": rulestext});
rulesdialog.open();
rulesdialog.open();}catch(e){print("/api/v1/instance/rules" +e)}
}
else if(api=="/api/statusnet/config"){
try{let serverdata = JSON.parse(text);
@ -505,9 +505,6 @@ Page{
oauth2.grant();
}
}
function onError(text,api){
print(api + " Error "+ text)
}
}
Connections{
@ -588,7 +585,7 @@ Page{
}
]
Component.onCompleted: { //print("filesystem.osType " +filesystem.osType)
Component.onCompleted: {
try{Helperjs.readData(db,"config","",function(storedUsers){
storedUsers.sort(function(obj1, obj2) {
return obj1.isActive - obj2.isActive;
@ -615,7 +612,6 @@ Page{
},"isActive",0)
})}
catch (e){//print("onCompleted" +users.count +e)
}
catch (e){print(e)}
}
}

View file

@ -42,7 +42,6 @@ import "qrc:/qml/genericqml"
Rectangle {
y:1
color: osSettings.backgroundColor
function showContactdetails(contact){
root.contactdetailsSignal(contact)
}

View file

@ -63,7 +63,7 @@ Item{
Connections{
target:xhr
function onError(data,url,api,code){print(data)}//if (data=="image"){Helperjs.showMessage()}}
//function onError(data,url,api,code){print(data)}
function onSuccess(data,api){
if(api.startsWith("/api/friendica/group")){
Newsjs.requestGroups(root.login,root.db,root,function(){

View file

@ -92,7 +92,7 @@ ApplicationWindow{
if(newContacts.length>0){// download contact images and update db
var contacturls=[];
var contactnames=[];
for (var link in newContacts){//print("new contact " +newContacts[link].screen_name);
for (var link in newContacts){
contacturls.push(newContacts[link].profile_image_url);
contactnames.push(newContacts[link].screen_name);
Service.updateContactInDB(login,db,newContacts[link].isFriend,newContacts[link])
@ -311,7 +311,7 @@ ApplicationWindow{
systemTray.visible=true
systemTray.show();
}
root.contactdetailsSignal.connect(showContact);
if(osSettings.osType=="Android"){
var component = Qt.createComponent("qrc:/qml/genericqml/IntentReceiver.qml");
var IntentReceiverQml = component.createObject(root);

View file

@ -181,8 +181,6 @@ Page {
MButton{
id:dmbutton
// height: 6*mm
// width: 8*mm
visible: (contact.following=="true")
text: qsTr("Direct Message")
display: AbstractButton.IconOnly
@ -211,7 +209,7 @@ Page {
MButton{
id:approvebutton
visible:(contact.hasOwnProperty("acct")&&!contact.searchContact)
//height: 6*mm
width: implicitWidth
text:qsTr("Approve")
onClicked:{
xhr.setAccount(login);
@ -225,7 +223,7 @@ Page {
MButton{
id:rejectbutton
visible:(contact.hasOwnProperty("acct")&&!contact.searchContact)
//height: 6*mm
width: implicitWidth
text:qsTr("Reject")
onClicked:{
xhr.setAccount(login);
@ -239,7 +237,7 @@ Page {
MButton{
id:ignorebutton
visible:(contact.hasOwnProperty("acct")&&!contact.searchContact)
//height: 6*mm
width: implicitWidth
text:qsTr("Ignore")
onClicked:{
xhr.setAccount(login);
@ -253,7 +251,7 @@ Page {
MButton{
id:followbutton
visible:(contact.isFriend==0 || !contact.hasOwnProperty("isFriend"))
//height: 6*mm
width: implicitWidth
text:qsTr("Follow")
onClicked:{
contactBusy.running=true;
@ -269,7 +267,7 @@ Page {
MButton{
id:unfollowbutton
visible:(contact.isFriend==1)
//height: 6*mm
width: implicitWidth
text:qsTr("Unfollow")
onClicked:{
contactBusy.running=true;
@ -284,7 +282,7 @@ Page {
MButton{
id: blockbutton
visible:(contact.statusnet_blocking!=1)
//height: 6*mm
width: implicitWidth
text:qsTr("Block")
onClicked:{
contactBusy.running=true;
@ -300,7 +298,7 @@ Page {
MButton{
id: unblockbutton
visible:(contact.statusnet_blocking==1)
//height: 6*mm
width: implicitWidth
text:qsTr("Unblock")
onClicked:{
contactBusy.running=true;
@ -358,12 +356,10 @@ Page {
}
function onSuccess(data,api){
if (api=="/api/statuses/user_timeline"){
Service.processNews(api,data)
if (data!=""){
Service.processNews(api,data)
}else{contactBusy.running=false}
}
else if (api=="/api/statuses/user_timeline"){
Service.processNews(api,data)
}
}
}

View file

@ -292,11 +292,11 @@ Window{
enabled: bodyField.canPaste
action: pasteAction
}
MenuItem {
text: qsTr("Text")
enabled: bodyField.selectedText
onTriggered: print(bodyField.getFormattedText(bodyField.selectionStart,bodyField.selectionEnd))
}
// MenuItem {
// text: qsTr("Text")
// enabled: bodyField.selectedText
// onTriggered: print(bodyField.getFormattedText(bodyField.selectionStart,bodyField.selectionEnd))
// }
}
DocumentHandler { id: document
document: bodyField.textDocument

View file

@ -266,7 +266,7 @@ Rectangle{
Connections{
target:xhr
function onError(data,url,api,code){print("api "+api+" code "+code+"data"+data)
function onError(data,url,api,code){print("api "+api+" code "+code)
newsBusy.running=false;
expectScreenUpdate=false;
}
@ -314,7 +314,7 @@ Rectangle{
}
Timer {id:replytimer; interval: 1000; running: false; repeat: false
onTriggered: {print("replytimer")
onTriggered: {//print("replytimer")
newsBusy.running=true;
if(newstab.newstabstatus=="Conversation"){
showConversation(newsStack.timelineIndex-1,newsModel.get(0).newsitemobject)}
@ -556,7 +556,6 @@ Rectangle{
}
Component.onCompleted: {
root.contactdetailsSignal.connect(showContact);
root.newsSignal.connect(showNews);
root.searchSignal.connect(search);
try{newsModel.clear()} catch(e){}

View file

@ -32,24 +32,14 @@
import QtQuick 6.3
Rectangle{
color:"grey"
width:toprow.width/2;
height:toprow.width/3
color:"light grey"
width: 7*root.fontFactor*osSettings.bigFontSize
height: 7*root.fontFactor*osSettings.bigFontSize
property var attachment:({})
Image{
anchors.fill: parent
source: "qrc:/assets/icons/play.svg"
}
// Text{
// id:noticeText
// text:"\uf144";
// color:"light grey"
// width:parent.width
// font.pixelSize: parent.height/2
// x: (parent.width-contentWidth)/2
// y:parent.height/5
// }
MouseArea {anchors.fill:parent;
onClicked:{
rootstackView.push("qrc:/qml/newsqml/NewsVideoLarge.qml",{"source": Qt.resolvedUrl(attachment.url),"mimetype": attachment.mimetype});

View file

@ -38,8 +38,14 @@ Page{
id:newsvideofullscreen
width:root.width;
height:root.height-3*root.fontFactor*osSettings.bigFontSize
property alias source:video.source
property alias source: video.source
property string mimetype:""
Rectangle{
anchors.fill: newsvideofullscreen
color: "black"
}
Text{
id:noticeText
text:""
@ -52,72 +58,83 @@ Page{
visible: video.playbackState!=MediaPlayer.PlayingState
}
Video {
id:video;
anchors.fill:parent
onErrorChanged:{
noticeText.font.pointSize=osSettings.bigFontSize;
noticeText.text=errorString;
Qt.openUrlExternally(source)
}
fillMode: Image.PreserveAspectFit;
// autoLoad: true
// autoPlay: true
// audioRole: MediaPlayer.VideoRole
MediaPlayer {
id: video
audioOutput: AudioOutput {}
videoOutput: videoOutput
Component.onCompleted: {play()}
onErrorChanged: {noticeText.text=errorString;Qt.openUrlExternally(source)}
}
ProgressBar{
id: videoProgress
width: parent.width
height: 2*mm
anchors.bottom: video.bottom
z:2
visible:video.playbackState!=MediaPlayer.StoppedState
value: video.position/video.duration
VideoOutput {
id: videoOutput
anchors.fill: parent
MouseArea {
anchors.fill:parent;
onClicked:{
if(video.playbackState!=MediaPlayer.PlayingState){
video.play()} else{video.pause()
}
if(Math.round(video.position/video.duration*1000) == 1000){
video.position=0;video.play()
}
}
}
Rectangle{
color:"light grey"
visible: video.playbackState!=MediaPlayer.PlayingState || (Math.round(video.position/video.duration*1000) == 1000)
opacity: 0.5
anchors.centerIn: videoOutput
width: 5*root.fontFactor*osSettings.bigFontSize
height: 5*root.fontFactor*osSettings.bigFontSize
Image{
anchors.fill: parent
source: "qrc:/assets/icons/play.svg"
}
}
}
ProgressBar{
id: videoBuffer
width: parent.width
height: 2*mm
anchors.bottom: video.bottom
visible:video.playbackState!=MediaPlayer.StoppedState
width: parent.width-4*mm
x: 2*mm
height: mm
contentItem: Item {
Rectangle {
width: videoBuffer.visualPosition * parent.width
height: parent.height
color: "light blue"
}
}
anchors.bottom: parent.bottom
value: video.bufferProgress
}
MButton {
id: closeButton
z:2
anchors.top: parent.top
anchors.topMargin: 1*mm
anchors.right: parent.right
anchors.rightMargin: 1*mm
text: qsTr("Close")
display: AbstractButton.IconOnly
icon.name: "dialog-close"
icon.source: "qrc:/assets/icons/times-circle.svg"
onClicked: {if (rootstackView.depth>1){ rootstackView.pop()}
}
}
Slider{
id: videoSlider
width: parent.width
height: 3*mm
anchors.top: video.bottom
x: 2*mm
width: parent.width-4*mm
height: 2*mm
z: 2
anchors.bottom: parent.bottom
visible:video.playbackState!=MediaPlayer.StoppedState && video.seekable
value: video.position/video.duration
onMoved: video.seek(value*video.duration)
onMoved: video.position=value*video.duration
}
MButton {
id: closeButton
z:2
anchors.top: parent.top
anchors.topMargin: 1*mm
anchors.right: parent.right
anchors.rightMargin: 1*mm
opacity: 0.6
text: qsTr("Close")
display: AbstractButton.IconOnly
icon.name: "dialog-close"
icon.source: "qrc:/assets/icons/times-circle.svg"
onClicked: {if (rootstackView.depth>1){ rootstackView.pop()}
}
}
}

View file

@ -73,8 +73,8 @@ Item {
Column {
id:toprow
width: newsitemobject.hasOwnProperty("indent")?newsitem.width-(newsitem.width/20 *(newsitemobject.indent+1)):newsitem.width//-8*mm
x:newsitemobject.hasOwnProperty("indent")?newsitem.width/20*(newsitemobject.indent):0
width: newsitemobject.hasOwnProperty("indent")?newsitem.width-(newsitem.width/20 *(newsitemobject.indent+1))-mm:newsitem.width-mm
x:newsitemobject.hasOwnProperty("indent")?newsitem.width/20*(newsitemobject.indent)+0.5*mm:0.5*mm
height: newsitemobject.nsfw?5*mm:Math.min(implicitHeight,3/4*root.height)
clip: true
Item{id:itemHeader
@ -190,19 +190,11 @@ Item {
height:5*mm
anchors.bottom: toprow.bottom
visible: toprow.implicitHeight>3/4*root.height || newsitemobject.nsfw
//text:"\uf078"
// fontColor: osSettings.secondaryTextColor
// border.color: "transparent"
// color: osSettings.backgroundColor
// gradient: Gradient {
// GradientStop { position: 0.0; color: "transparent" }
// GradientStop { position: 0.5; color: osSettings.backgroundDimColor}
// }
//radius:0
icon.name:"arrow-down"
icon.source: "qrc:/assets/icons/chevron-down.svg"
icon.width: 2*root.fontFactor*osSettings.bigFontSize
icon.height: 2*root.fontFactor*osSettings.bigFontSize
icon.color:"transparent"
background: Rectangle{
gradient: Gradient {
GradientStop { position: 0.0; color: "transparent" }
@ -216,7 +208,7 @@ Item {
} else {
toprow.height=Math.min(toprow.implicitHeight,3/4*root.height);
icon.name="arrow-down";icon.source="qrc:/assets/icons/chevron-down.svg";
newsView.positionViewAtIndex(index,ListView.Beginning);
newsitem.ListView.view.positionViewAtIndex(index,ListView.Beginning);
}
}
}

View file

@ -113,7 +113,6 @@ Package {
enabled: false
}
// onStateChanged: print("State"+photoWrapper.state+index)
states: [
State {
name: 'stacked'; when: albumWrapper.state == ''

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.