Skip to content

Commit c605a09

Browse files
committed
Receive/play video attachments
1 parent fead038 commit c605a09

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ This setup requires a jailbroken iPhone with root access. For my tests and devel
8686
- See *Note 1*.
8787
- [ ] Send
8888
- Video
89-
- [ ] Receive/display
89+
- [x] Receive/display
90+
- See *Note 1*.
9091
- [ ] Send
9192
- Other media types
9293
- [ ] Receive/display

scripts/iMessage.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -540,17 +540,25 @@ const CreateMessageBubble = (TypingIndicator = false, MessageJSON = {}, Message
540540
if (MessageJSON.text == "\ufffc") {
541541
const Attachments = MessageJSON.attachments
542542
for (const Attachment of Attachments) {
543-
let MessageContentItem = document.createElement("img")
543+
let Type = Attachment[1].includes("image") ? "img" : (Attachment[1].includes("video") ? "video" : "div");
544+
let MessageContentItem = document.createElement(Type)
544545
MessageContentItem.addEventListener("load", () => {
545546
MessageContainer.scrollTop = MessageContainer.scrollHeight;
546547
})
547548
MessageContentItem.setAttribute("rawJSON", JSON.stringify(MessageJSON))
548549
MessageContentItem.className = "message"
549550
MessageContentItem.classList.add("message-media")
550551
MessageContentItem.classList.add(Sender ? "message-sender" : "message-recipient")
551-
if (ServerSettings) {
552+
if (ServerSettings && Type == "img") {
552553
MessageContentItem.src = `${ServerSettings.useHttps ? "https" : "http"}://${ServerSettings.host}:${ServerSettings.port}/attachments?path=${encodeURIComponent(Attachment[0])}&type=${encodeURIComponent(Attachment[1])}&auth=${ServerSettings.password}&transcode=1`
553554
}
555+
else if (ServerSettings && Type == "video") {
556+
let SourceObject = document.createElement("source")
557+
SourceObject.src = `${ServerSettings.useHttps ? "https" : "http"}://${ServerSettings.host}:${ServerSettings.port}/attachments?path=${encodeURIComponent(Attachment[0])}&type=${encodeURIComponent(Attachment[1])}&auth=${ServerSettings.password}&transcode=1`
558+
SourceObject.type = Attachment[1]
559+
MessageContentItem.appendChild(SourceObject)
560+
MessageContentItem.setAttribute("controls", true)
561+
}
554562
OutMessages.push(MessageContentItem)
555563
}
556564
}

0 commit comments

Comments
 (0)