iMessage extension add video to MSConversation and play directly

Viewed 472

I've found that there are basically to way to add a video into an MSConversation.

  1. Create an MSMessage instance and add the file URL as the mediaFileURL property from the MSMessageTemplateLayout

    let layout = MSMessageTemplateLayout()
    layout.imageTitle = caption
    layout.mediaFileURL = media
    layout.caption = nil
    layout.subcaption = nil
    layout.imageSubtitle = nil
    layout.subcaption = nil
    layout.trailingSubcaption = nil
    let message = MSMessage(session: session ?? MSSession())
    message.layout = layout
    
  2. Add it as an attachment using the method insertAttachment(_:withAlternateFilename:completionHandler:)

The first one creates a preview of the video with the symbol of the message application and it starts automatically to play but with no sound, at the top left you can see a small icon of a speaker.
It doesn't seems to be a way to play the audio, because right after I click on the message it opens the Appstore or the same message application in expanded mode. Sendvideo as message

The latter sends correctly the video but it doesn't start automatically it is required for the user to press the play button over it.

Is there any way to make the video play with audio in the first case? or the only way is to open a specific view controller that plays the video once selected?

1 Answers

I got solution:-

self.activeConversation?.insertAttachment(videoURL, withAlternateFilename: "fileName", completionHandler: { (errir) in

 })
Related