CursosEmpresasBlogLiveConfPrecios

VideoPlayer

Clase 21 de 22 • Curso de SwiftUI desde Cero (2021)

Clase anteriorSiguiente clase

Contenido del curso

Introducción a SwiftUI

  • 1
    ¿Qué es SwiftUI?

    ¿Qué es SwiftUI?

    01:43 min
  • 2
    Instalación de Xcode

    Instalación de Xcode

    02:04 min
  • 3
    Uso y características de Xcode

    Uso y características de Xcode

    12:21 min

Las bases de Swift para SwiftUI

  • 4
    Variables y constantes

    Variables y constantes

    13:17 min
  • 5
    Funciones y argument labels

    Funciones y argument labels

    17:10 min
  • 6
    Structs, propiedades y métodos

    Structs, propiedades y métodos

    09:31 min
  • 7
    Diferencia entre struct y class

    Diferencia entre struct y class

    07:56 min
  • 8
    Computed properties

    Computed properties

    03:07 min
  • 9
    Las bases de SwiftUI e introducción a protocolos

    Las bases de SwiftUI e introducción a protocolos

    05:54 min

Vistas y controles

  • 10
    ¿Qué son las vistas y controles en SwiftUI?

    ¿Qué son las vistas y controles en SwiftUI?

    15:44 min
  • 11
    Botones

    Botones

    13:40 min
  • 12
    Imágenes

    Imágenes

    11:39 min
  • 13
    Campos de texto y el property wrapper @state

    Campos de texto y el property wrapper @state

    13:17 min
  • 14
    Divisores

    Divisores

    08:16 min

Contenedores de interfaz de usuario

  • 15
    HStack, VStack y el elemento Spacer

    HStack, VStack y el elemento Spacer

    09:32 min
  • 16
    Resolviendo el reto de contenedores

    Resolviendo el reto de contenedores

    13:20 min
  • 17
    ZStack y el modificador padding

    ZStack y el modificador padding

    18:03 min
  • 18
    Dividir la app en módulos de contenedores

    Dividir la app en módulos de contenedores

    13:10 min

Más vistas y controles

  • 19
    TabView

    TabView

    04:44 min
  • 20
    NavigationView, NavigationLink e introducción a múltiples pantallas

    NavigationView, NavigationLink e introducción a múltiples pantallas

    19:19 min
  • 21
    VideoPlayer

    VideoPlayer

    Viendo ahora

Las posibilidades de SwiftUI

  • 22
    Las posibilidades de SwiftUI

    Las posibilidades de SwiftUI

    03:44 min
  • Tomar el examen del curso
    • Joaquin Segovia

      Joaquin Segovia

      student•
      hace 4 años

      Dejo mi Reto, donde le agregue la misma imagen en Z0 en blur y expandida a tope, y la vista del reproductor de fondo todo negro Imagen y código debajo

      // // Players.swift // Platzi // // Created by Joaquin Segovia on 9/2/22. // import SwiftUI import AVKit struct Players: View { @State var isPlayerActive:Bool = false var body: some View { NavigationView{ ZStack { Image("cuphead").resizable() .aspectRatio(contentMode: .fill).frame(width: 400, height: 868, alignment: .center) .blur(radius: /*@START_MENU_TOKEN@*/8.0/*@END_MENU_TOKEN@*/) VStack{ Button(action: { isPlayerActive.toggle() }, label: { ZStack { Image("cuphead").resizable().aspectRatio(contentMode:.fit) Image(systemName: "play.circle").resizable().aspectRatio( contentMode: .fit).foregroundColor(.white).frame(width: 50, height: 50, alignment: .center) } })//Button NavigationLink( destination: reproductor(), isActive: $isPlayerActive, label:{ EmptyView() } )//NavigationLink }//VStack }.ignoresSafeArea()//ZStack }//NavigationView }//Body } struct reproductor:View{ var body: some View{ ZStack { Color.black VideoPlayer(player: AVPlayer(url: URL(string: "https://cdn.cloudflare.steamstatic.com/steam/apps/256705156/movie480.mp4")!)) .frame(width: 420, height: 360, alignment: .center) }.ignoresSafeArea() } } struct Players_Previews: PreviewProvider { static var previews: some View { Players() } }
      Froylan Almeida

      Froylan Almeida

      student•
      hace 4 años

      Por qué no funcionan links de YouTube?

        Juan Villalvazo

        Juan Villalvazo

        teacher•
        hace 4 años

        Ya que la librería utilizada no implementa el navegador completamente, no es su función. Saludos : )

        Joaquin Segovia

        Joaquin Segovia

        student•
        hace 4 años

        La Lbereria solo te dejaría archivos en concreto, no links sueltos.Podrias probar el iframe que te deja YouTube copiar y compartir pero no e si eso funciona.

      Fernando Florez

      Fernando Florez

      student•
      hace 4 años

      Reto!

      // // CustomPlayer.swift // Platzi // // Created by Fernando Florez on 11/08/21. // import SwiftUI import AVKit struct URLS { static let main = "https://cdn.cloudflare.steamstatic.com/steam/apps/256705156/movie480.mp4" } struct CustomPlayer: View { @State var isPlayerActive: Bool = false var body: some View { NavigationView { VStack { Button(action: { isPlayerActive.toggle() }) { ZStack { Image("cuphead") .resizable() .aspectRatio(contentMode: .fit) Image(systemName: "play.fill") .font(.system(size: 80)) .foregroundColor(.white) } } NavigationLink( destination: VideoModule(videoUrl: URLS.main), isActive: $isPlayerActive, label: { EmptyView() } ) } } .accentColor(.red) } } struct VideoModule: View { var videoUrl: String var body: some View { ZStack { Color.black VideoPlayer(player: AVPlayer(url: URL(string: videoUrl)! )) .aspectRatio(contentMode: .fit) Spacer() } .ignoresSafeArea() } } struct CustomPlayer_Previews: PreviewProvider { static var previews: some View { CustomPlayer() VideoModule(videoUrl: URLS.main) } }
      Diego Andrés Beltrán Garavito

      Diego Andrés Beltrán Garavito

      student•
      hace 4 años

      Se queda la pantalla en negro, no reproduce video, me da lo siguiente en consola.

      021-08-12 23:07:59.235612-0500 Platzi[13885:739750] [] nw_protocol_get_quic_image_block_invoke dlopen libquic failed 2021-08-12 23:08:01.095616-0500 Platzi[13885:739801] [plugin] AddInstanceForFactory: No factory registered for id <CFUUID 0x600001b37e40> F8BB1C28-BAE8-11D6-9C31-00039315CD46 2021-08-12 23:08:01.449227-0500 Platzi[13885:739118] <CATransformLayer: 0x600001b18940> - changing property masksToBounds in transform-only layer, will have no effect 2021-08-12 23:08:01.451437-0500 Platzi[13885:739118] <CATransformLayer: 0x600001b01ca0> - changing property masksToBounds in transform-only layer, will have no effect 2021-08-12 23:08:01.457892-0500 Platzi[13885:739118] <CATransformLayer: 0x600001b1dee0> - changing property masksToBounds in transform-only layer, will have no effect 2021-08-12 23:08:01.465774-0500 Platzi[13885:739118] <CATransformLayer: 0x600001b18fc0> - changing property masksToBounds in transform-only layer, will have no effect 2021-08-12 23:08:01.469751-0500 Platzi[13885:739118] <CATransformLayer: 0x600001b02160> - changing property masksToBounds in transform-only layer, will have no effect 2021-08-12 23:08:01.554058-0500 Platzi[13885:739118] <CATransformLayer: 0x600001b1dee0> - changing property allowsGroupBlending in transform-only layer, will have no effect 2021-08-12 23:08:01.554385-0500 Platzi[13885:739118] <CATransformLayer: 0x600001b18fc0> - changing property allowsGroupBlending in transform-only layer, will have no effect

        Héctor Eduardo López Carballo

        Héctor Eduardo López Carballo

        student•
        hace 4 años

        Hola!

        Pudiste resolverlo? Podrías compartir tu solución?

        Joaquin Segovia

        Joaquin Segovia

        student•
        hace 4 años

        Que versiones de OS, Xcode y simulador esta usando

      Juan Sebastián Vargas Castañeda

      Juan Sebastián Vargas Castañeda

      student•
      hace 4 años
      • Reto
      struct Player: View { var body: some View { NavigationView { VideoButton() } } }

      Video Button Struct

      struct VideoButton: View { @State var isPlayerActive:Bool = false var body: some View { VStack { Button(action: {isPlayerActive = true}, label: { ZStack { Image("cuphead").resizable().aspectRatio(contentMode: .fit) Image(systemName: "play.fill").foregroundColor(.white) } }) NavigationLink( destination: PlayerSection(), isActive: $isPlayerActive, label: { EmptyView() }) } } }

      Player Section struct

      struct PlayerSection: View { var body: some View { ZStack { Color.black VideoPlayer(player: AVPlayer( url: URL(string: "https://cdn.cloudflare.steamstatic.com/steam/apps/256705156/movie480.mp4")!)).frame(width: 420, height: 360, alignment: .center)// Hay que ponerle ! un wrap, dado que URL podría arrojar excepción. }.ignoresSafeArea() } }
      Nicolas Silva

      Nicolas Silva

      student•
      hace 3 años

      Aca va el mio, tuve un problema con el resize de la imagen del videoplayer, pero en general todo bien

      // // Player.swift // Platzi // // Created by Nicolas Silva Aravena on 05-06-23. // import SwiftUI import AVKit struct Player: View { var body: some View { NavigationStack { VStack { NavigationLink(destination: VideoPlayerComponent(), label: { ZStack { Image("cuphead").resizable().aspectRatio(contentMode: .fill).ignoresSafeArea().blur(radius: 10) Image("cuphead").aspectRatio(contentMode: .fit).clipShape(RoundedRectangle(cornerRadius: 25)) Circle().frame(width: 100, height: 100, alignment: .center).foregroundColor(Color.gray.opacity(0.8)) Image(systemName: "play.fill").resizable().aspectRatio(contentMode: .fit).frame(width: 50, height: 50, alignment: .center).padding(.leading, 10).foregroundColor(Color.white) } }) } } } } struct VideoPlayerComponent: View { var videoURL = "https://cdn.cloudflare.steamstatic.com/steam/apps/256705156/movie480.mp4" var body: some View { ZStack { VideoPlayer(player: AVPlayer(url: URL(string: videoURL)!)) }.ignoresSafeArea() } } struct Player_Previews: PreviewProvider { static var previews: some View { Player() } }
      Nicolas Vezzali Dussio

      Nicolas Vezzali Dussio

      student•
      hace 3 años

      Reto (Actualizado a iOS 16+):

      import SwiftUI import AVKit struct VideoPlayers: View { @State var isPlayerActive: Bool = false var body: some View { NavigationView { ZStack { Image("cupHead").resizable() .aspectRatio(contentMode: .fill).frame(width: 400, height: 868, alignment: .center) .blur(radius: /*@START_MENU_TOKEN@*/8.0/*@END_MENU_TOKEN@*/) NavigationLink { ReproductorVideo() } label: { ZStack { Image("cupHead") .resizable() .aspectRatio(contentMode: .fit) Image(systemName: "play.circle") .resizable() .frame(width: 100, height: 100, alignment: .center) .foregroundColor(Color.white) } } } } } } struct ReproductorVideo: View { private var vm = AVPlayer(url: URL(string: "https://cdn.cloudflare.steamstatic.com/steam/apps/256705156/movie480.mp4")!) var body: some View { VideoPlayer(player: vm).onAppear{ vm.play() }.onDisappear{ vm.pause() } .aspectRatio(contentMode: .fit) } } struct VideoPlayers_Previews: PreviewProvider { static var previews: some View { VideoPlayers() ReproductorVideo() } }
      Andrea stefanny García mejia

      Andrea stefanny García mejia

      student•
      hace 3 años
      Captura de pantalla 2023-02-02 a la(s) 9.47.23 a.m..png
      Juan Salvador Vilca Paredes

      Juan Salvador Vilca Paredes

      student•
      hace 3 años

      el navigation link que usa es bastante útil, aunque no es necesario en algunos casos como este, podrian simplificar su codigo asi:

      NavigationLink { PlayerView() // destino: vista } label: { SomeView() // label: Image, Text o cualquier vista }
      christian hernández rivera

      christian hernández rivera

      student•
      hace 4 años

      No es necesario poner el botón para cambiar de vista

      import SwiftUI import AVKit struct VideoPlayers: View { @State var isPlayerActive: Bool = false var body: some View { NavigationView { VStack { NavigationLink { ReproductorVideo() } label: { ZStack { Image("cuphead") .resizable() .aspectRatio(contentMode: .fit) Image(systemName: "play.circle") .resizable() .frame(width: 100, height: 100, alignment: .center) .foregroundColor(Color.white) } } } } } } struct ReproductorVideo: View { var body: some View { VideoPlayer(player: AVPlayer(url: URL(string: "https://cdn.cloudflare.steamstatic.com/steam/apps/256705156/movie480.mp4")! )) .aspectRatio(contentMode: .fit) } } struct VideoPlayers_Previews: PreviewProvider { static var previews: some View { VideoPlayers() .previewInterfaceOrientation(.portraitUpsideDown) ReproductorVideo() } }
      Andrés Antonio Azuara Portillo

      Andrés Antonio Azuara Portillo

      student•
      hace 4 años

      Estaba checando y hay otro inicializador para NavigationLink en el cual solamente necesita el destino o lo que renderizara al presionarlo y un label, siento que puede ayudar porque así evitas tener un botón el cual tiene la imagen, y aparte tener un NavigationLink con un EmptyView, y solamente se necesita crear el NavigationLink

      NavigationLink(destination: View(), label: {})
      Ricardo Saenz Salazar

      Ricardo Saenz Salazar

      student•
      hace 4 años

      Reto

      import SwiftUI import AVKit struct Retovideoplayer: View { @State var isPlayerActive: Bool = false var body: some View { NavigationView{ VStack{ Button(action: {isPlayerActive = true }, label: { ZStack { Image("cuphead").resizable().aspectRatio(contentMode: .fit) Image(systemName: "play.fill").foregroundColor(.white) } }) NavigationLink( destination: VideoCup(), isActive: $isPlayerActive, label: { EmptyView() }) } } } } struct VideoCup: View { var body: some View { ZStack{ Color.black VStack{ Text("Cuphead Trailer").foregroundColor(.white) VideoPlayer(player: AVPlayer(url: URL(string: "https://cdn.cloudflare.steamstatic.com/steam/apps/256705156/movie480.mp4")!)).frame(width: 420, height: 360, alignment: .center) } }.ignoresSafeArea() } } struct Retovideoplayer_Previews: PreviewProvider { static var previews: some View { Retovideoplayer() } }
      Emilio Yoltic

      Emilio Yoltic

      student•
      hace 4 años
      struct players: View { @State var moving : Bool = false var body: some View { NavigationView{ VStack{ Button(action:{moving.toggle()},label:{ ZStack{ Color.black Image("platzi").resizable().aspectRatio(contentMode:.fit) Image(systemName: "play.fill").foregroundColor(Color.white).frame(width: 100, height: 100, alignment: .center) }.ignoresSafeArea() }) NavigationLink(destination:video(), isActive: $moving, label: {EmptyView()}) } } } } struct video: View{ var body : some View{ ZStack{ Color.black VideoPlayer(player:AVPlayer(url: URL(string: "https://cdn.cloudflare.steamstatic.com/steam/apps/256705156/movie480.mp4")!)) }.ignoresSafeArea() } }

    Escuelas

    • Desarrollo Web
      • Fundamentos del Desarrollo Web Profesional
      • Diseño y Desarrollo Frontend
      • Desarrollo Frontend con JavaScript
      • Desarrollo Frontend con Vue.js
      • Desarrollo Frontend con Angular
      • Desarrollo Frontend con React.js
      • Desarrollo Backend con Node.js
      • Desarrollo Backend con Python
      • Desarrollo Backend con Java
      • Desarrollo Backend con PHP
      • Desarrollo Backend con Ruby
      • Bases de Datos para Web
      • Seguridad Web & API
      • Testing Automatizado y QA para Web
      • Arquitecturas Web Modernas y Escalabilidad
      • DevOps y Cloud para Desarrolladores Web
    • English Academy
      • Inglés Básico A1
      • Inglés Básico A2
      • Inglés Intermedio B1
      • Inglés Intermedio Alto B2
      • Inglés Avanzado C1
      • Inglés para Propósitos Específicos
      • Inglés de Negocios
    • Marketing Digital
      • Fundamentos de Marketing Digital
      • Marketing de Contenidos y Redacción Persuasiva
      • SEO y Posicionamiento Web
      • Social Media Marketing y Community Management
      • Publicidad Digital y Paid Media
      • Analítica Digital y Optimización (CRO)
      • Estrategia de Marketing y Growth
      • Marketing de Marca y Comunicación Estratégica
      • Marketing para E-commerce
      • Marketing B2B
      • Inteligencia Artificial Aplicada al Marketing
      • Automatización del Marketing
      • Marca Personal y Marketing Freelance
      • Ventas y Experiencia del Cliente
      • Creación de Contenido para Redes Sociales
    • Inteligencia Artificial y Data Science
      • Fundamentos de Data Science y AI
      • Análisis y Visualización de Datos
      • Machine Learning y Deep Learning
      • Data Engineer
      • Inteligencia Artificial para la Productividad
      • Desarrollo de Aplicaciones con IA
      • AI Software Engineer
    • Ciberseguridad
      • Fundamentos de Ciberseguridad
      • Hacking Ético y Pentesting (Red Team)
      • Análisis de Malware e Ingeniería Forense
      • Seguridad Defensiva y Cumplimiento (Blue Team)
      • Ciberseguridad Estratégica
    • Liderazgo y Habilidades Blandas
      • Fundamentos de Habilidades Profesionales
      • Liderazgo y Gestión de Equipos
      • Comunicación Avanzada y Oratoria
      • Negociación y Resolución de Conflictos
      • Inteligencia Emocional y Autogestión
      • Productividad y Herramientas Digitales
      • Gestión de Proyectos y Metodologías Ágiles
      • Desarrollo de Carrera y Marca Personal
      • Diversidad, Inclusión y Entorno Laboral Saludable
      • Filosofía y Estrategia para Líderes
    • Diseño de Producto y UX
      • Fundamentos de Diseño UX/UI
      • Investigación de Usuarios (UX Research)
      • Arquitectura de Información y Usabilidad
      • Diseño de Interfaces y Prototipado (UI Design)
      • Sistemas de Diseño y DesignOps
      • Redacción UX (UX Writing)
      • Creatividad e Innovación en Diseño
      • Diseño Accesible e Inclusivo
      • Diseño Asistido por Inteligencia Artificial
      • Gestión de Producto y Liderazgo en Diseño
      • Diseño de Interacciones Emergentes (VUI/VR)
      • Desarrollo Web para Diseñadores
      • Diseño y Prototipado No-Code
    • Contenido Audiovisual
      • Fundamentos de Producción Audiovisual
      • Producción de Video para Plataformas Digitales
      • Producción de Audio y Podcast
      • Fotografía y Diseño Gráfico para Contenido Digital
      • Motion Graphics y Animación
      • Contenido Interactivo y Realidad Aumentada
      • Estrategia, Marketing y Monetización de Contenidos
    • Desarrollo Móvil
      • Fundamentos de Desarrollo Móvil
      • Desarrollo Nativo Android con Kotlin
      • Desarrollo Nativo iOS con Swift
      • Desarrollo Multiplataforma con React Native
      • Desarrollo Multiplataforma con Flutter
      • Arquitectura y Patrones de Diseño Móvil
      • Integración de APIs y Persistencia Móvil
      • Testing y Despliegue en Móvil
      • Diseño UX/UI para Móviles
    • Diseño Gráfico y Arte Digital
      • Fundamentos del Diseño Gráfico y Digital
      • Diseño de Identidad Visual y Branding
      • Ilustración Digital y Arte Conceptual
      • Diseño Editorial y de Empaques
      • Motion Graphics y Animación 3D
      • Diseño Gráfico Asistido por Inteligencia Artificial
      • Creatividad e Innovación en Diseño
    • Programación
      • Fundamentos de Programación e Ingeniería de Software
      • Herramientas de IA para el trabajo
      • Matemáticas para Programación
      • Programación con Python
      • Programación con JavaScript
      • Programación con TypeScript
      • Programación Orientada a Objetos con Java
      • Desarrollo con C# y .NET
      • Programación con PHP
      • Programación con Go y Rust
      • Programación Móvil con Swift y Kotlin
      • Programación con C y C++
      • Administración Básica de Servidores Linux
    • Negocios
      • Fundamentos de Negocios y Emprendimiento
      • Estrategia y Crecimiento Empresarial
      • Finanzas Personales y Corporativas
      • Inversión en Mercados Financieros
      • Ventas, CRM y Experiencia del Cliente
      • Operaciones, Logística y E-commerce
      • Gestión de Proyectos y Metodologías Ágiles
      • Aspectos Legales y Cumplimiento
      • Habilidades Directivas y Crecimiento Profesional
      • Diversidad e Inclusión en el Entorno Laboral
      • Herramientas Digitales y Automatización para Negocios
    • Blockchain y Web3
      • Fundamentos de Blockchain y Web3
      • Desarrollo de Smart Contracts y dApps
      • Finanzas Descentralizadas (DeFi)
      • NFTs y Economía de Creadores
      • Seguridad Blockchain
      • Ecosistemas Blockchain Alternativos (No-EVM)
      • Producto, Marketing y Legal en Web3
    • Recursos Humanos
      • Fundamentos y Cultura Organizacional en RRHH
      • Atracción y Selección de Talento
      • Cultura y Employee Experience
      • Gestión y Desarrollo de Talento
      • Desarrollo y Evaluación de Liderazgo
      • Diversidad, Equidad e Inclusión
      • AI y Automatización en Recursos Humanos
      • Tecnología y Automatización en RRHH
    • Finanzas e Inversiones
      • Fundamentos de Finanzas Personales y Corporativas
      • Análisis y Valoración Financiera
      • Inversión y Mercados de Capitales
      • Finanzas Descentralizadas (DeFi) y Criptoactivos
      • Finanzas y Estrategia para Startups
      • Inteligencia Artificial Aplicada a Finanzas
      • Domina Excel
      • Financial Analyst
      • Conseguir trabajo en Finanzas e Inversiones
    • Startups
      • Fundamentos y Validación de Ideas
      • Estrategia de Negocio y Product-Market Fit
      • Desarrollo de Producto y Operaciones Lean
      • Finanzas, Legal y Fundraising
      • Marketing, Ventas y Growth para Startups
      • Cultura, Talento y Liderazgo
      • Finanzas y Operaciones en Ecommerce
      • Startups Web3 y Blockchain
      • Startups con Impacto Social
      • Expansión y Ecosistema Startup
    • Cloud Computing y DevOps
      • Fundamentos de Cloud y DevOps
      • Administración de Servidores Linux
      • Contenerización y Orquestación
      • Infraestructura como Código (IaC) y CI/CD
      • Amazon Web Services
      • Microsoft Azure
      • Serverless y Observabilidad
      • Certificaciones Cloud (Preparación)
      • Plataforma Cloud GCP

    Platzi y comunidad

    • Platzi Business
    • Live Classes
    • Lanzamientos
    • Executive Program
    • Trabaja con nosotros
    • Podcast

    Recursos

    • Manual de Marca

    Soporte

    • Preguntas Frecuentes
    • Contáctanos

    Legal

    • Términos y Condiciones
    • Privacidad
    • Tyc promociones
    Reconocimientos
    Reconocimientos
    Logo reconocimientoTop 40 Mejores EdTech del mundo · 2024
    Logo reconocimientoPrimera Startup Latina admitida en YC · 2014
    Logo reconocimientoPrimera Startup EdTech · 2018
    Logo reconocimientoCEO Ganador Medalla por la Educación T4 & HP · 2024
    Logo reconocimientoCEO Mejor Emprendedor del año · 2024
    De LATAM conpara el mundo
    YoutubeInstagramLinkedInTikTokFacebookX (Twitter)Threads