如何在SwiftUI项目中播放来自Google Drive的视频?

huangapple go评论61阅读模式
英文:

How to play video from Google Drive in SwiftUI project?

问题

I have a JSON file stored on a server that contains a list of lessons. Each lesson has a Google Drive link to a video. I'm currently building a SwiftUI video player, and I'm looking for assistance on how to play the video directly from the Google Drive link.

Here's an example of the Google Drive link format:
"https://drive.google.com/file/d/xxxxxxxxxxx/view?usp=share_link"

I'm seeking guidance on how to extract the video URL from the Google Drive link and play it using the SwiftUI video player.

When I'm trying to implement a simple player, it's not working. I've also tried to use a direct link, like that: https://drive.google.com/uc?export=download&id=xxxxxxxx, it's not working either. There was also an old method from here, but it didn't work too. Is it even possible to stream and play in AVPlayer from Google Drive?

Any help would be appreciated. Thank you!

英文:

I have a JSON file stored on a server that contains a list of lessons. Each lesson has a Google Drive link to a video. I'm currently building a SwiftUI video player, and I'm looking for assistance on how to play the video directly from the Google Drive link.

Here's an example of the Google Drive link format:
"https://drive.google.com/file/d/xxxxxxxxxxx/view?usp=share_link"

I'm seeking guidance on how to extract the video URL from the Google Drive link and play it using the SwiftUI video player.

When I'm trying to implement a simple player, it's not working. I've also tried to use direct link, like that: https://drive.google.com/uc?export=download&id=xxxxxxxx, it's not working either. There was also an old method from here, but it didn't work too. Is it even possible to stream and play in AVPlayer from Google Drive?

Any help would be appreciated. Thank you!

答案1

得分: 1

我可以建议您一个替代方案,即在您的SwiftUI应用程序中嵌入YouTube。为此,您可以利用WebViewContainer来嵌入YouTube视频层到您的应用程序中。以下是一个您可以参考的资源链接:https://blog.devgenius.io/embedded-youtube-videos-in-swiftui-900d3a0e80d4

英文:

I can suggest you an alternative solution which is to embed youtube in your SwiftUI app. For that you can utilize WebViewContainer to embed youtube video layer in you app. Here is a resource you may follow. https://blog.devgenius.io/embedded-youtube-videos-in-swiftui-900d3a0e80d4

huangapple
  • 本文由 发表于 2023年5月17日 17:15:59
  • 转载请务必保留本文链接:https://go.coder-hub.com/76270442.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定