shogo4405 / HaishinKit.swift

Camera and Microphone streaming library via RTMP and SRT for iOS, macOS, tvOS and visionOS.
BSD 3-Clause "New" or "Revised" License
2.75k stars 610 forks source link

HLSStream to chromcast is not working. #487

Closed andreyjin closed 5 years ago

andreyjin commented 5 years ago

I tried to connect hls stream to chromcast. But I cannot connect to chromcast. my code is as follows:

    let httpStream:HTTPStream = HTTPStream()
    httpStream.attachCamera(DeviceUtil.device(withPosition: .back))

// httpStream.attachAudio(AVCaptureDevice.default(for: AVMediaType.audio)) httpStream.publish("hello")

    let hkView = HKView(frame: cameraView.bounds)
    hkView.videoGravity = AVLayerVideoGravity.resizeAspectFill
    hkView.attachStream(httpStream)

    let httpService:HLSService = HLSService(domain: "", type: "_http._tcp", name: "lf", port: 8080)
    httpService.startRunning()
    httpService.addHTTPStream(httpStream)

    cameraView.addSubview(hkView)
    ...
    GCKMediaMetadata *metadata =
[[GCKMediaMetadata alloc] initWithMetadataType:GCKMediaMetadataTypeMovie];
[metadata setString:@"Live Class" forKey:kGCKMetadataKeyTitle];
[metadata setString:@"STUDIO" forKey:kGCKMetadataKeyStudio];

location = @"http://192.168.5.100:8080/hello/playlist.m3u8";

GCKMediaInformation *mediaInfo = [[GCKMediaInformation alloc]
                                  initWithContentID:location
                                  streamType:GCKMediaStreamTypeNone
                                  contentType:@"application/X-mpegURL"
                                  metadata:metadata
                                  streamDuration:INFINITY
                                  mediaTracks:nil
                                  textTrackStyle:nil
                                  customData:nil];

GCKCastSession *session =
[GCKCastContext sharedInstance].sessionManager.currentCastSession;
if (session) {
    [session.remoteMediaClient addListener:self];
    [session.remoteMediaClient loadMedia: mediaInfo
                                autoplay:YES];
}

After soon connected to chromcast, connect failed. MediaData is lost.

I hope your help.

phamhuudai commented 5 years ago

I also had the same issue. Have you played HLS Stream to ChromeCast successfully ?

stale[bot] commented 5 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Midas322 commented 2 years ago

I have same problem, does somebody find solution?

quanlv9695 commented 1 year ago

has anyone solved it yet? Thanks.