Skip to content

Commit

Permalink
fix publish tracks
Browse files Browse the repository at this point in the history
  • Loading branch information
ShengQiangLiu committed Oct 31, 2024
1 parent 7222a98 commit 24452ad
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 19 deletions.
8 changes: 0 additions & 8 deletions ApiExample/build-profile.json5
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
{
"app": {
"signingConfigs": [
{
"name": "default",
"type": "HarmonyOS",
"material": {
}
}
],
"products": [
{
"name": "default",
Expand Down
12 changes: 6 additions & 6 deletions ApiExample/entry/oh-package-lock.json5

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion ApiExample/entry/oh-package.json5
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"author": "",
"license": "",
"dependencies": {
"qnrtckit": "file:library/QNRTCKit.har"
"qnrtckit": "file:library/qnrtckit.har"
},
"devDependencies": {},
"dynamicDependencies": {}
Expand Down
7 changes: 6 additions & 1 deletion ApiExample/entry/src/main/ets/pages/Index.ets
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ struct Index {
itemTitleSize: number = 15
titleBackgroundColor: ResourceColor = '#fff0f0f0'
egDivider: DividerList = new DividerList(1, 10, 10, '#ffd0d0d0')
private pushClicked : boolean = false;
token: string = ""

aboutToAppear(): void {
Expand All @@ -59,7 +60,7 @@ struct Index {
didShow: (from: NavDestinationContext | "navBar", to: NavDestinationContext | "navBar",
operation: NavigationOperation, animated: boolean) => {
if (operation == NavigationOperation.POP) {

this.pushClicked = false;
}
}
})
Expand All @@ -85,7 +86,11 @@ struct Index {
}
}.padding(5)
.onClick(() => {
if (this.pushClicked){
return;
}
if (this.token) {
this.pushClicked = true;
this.pathStack.pushPathByName(pathName, this.token);
} else {
prompt.showToast({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,20 @@ export struct CameraVideoExample {
private cameraTrack: QNCameraVideoTrack | null = null;
private localRenderComponentCtrl: QNComponentController = new QNComponentController();
private remoteRenderComponentCtrl: QNComponentController = new QNComponentController();
private connectionState: QNConnectionState = QNConnectionState.Disconnected;
@State localRendervisibility: Visibility = Visibility.Hidden;
@State remoteRendervisibility: Visibility = Visibility.Hidden;

private clientListener: QNClientEventListener = {
OnConnectionStateChanged: (state: QNConnectionState, info: QNConnectionDisconnectedInfo) => {
this.connectionState = state;
if (state == QNConnectionState.Connected) {
// set local render
this.cameraTrack!.Play(this.localRenderComponentCtrl);
this.localRendervisibility = Visibility.Visible;
// publish local tracks
this.client!.Publish(this.localTracks, null);
if (this.client) {
this.client.Publish(this.localTracks, null);
}
}
},
OnSubscribed: (userid: string, remoteAudioTrackList: QNRemoteAudioTrack[],
Expand Down Expand Up @@ -90,7 +93,9 @@ export struct CameraVideoExample {
}

aboutToDisappear(): void {
this.client!.Leave();
if (this.client && this.connectionState == QNConnectionState.Connected) {
this.client!.Leave();
}
QNRTC.DeInit();
}

Expand All @@ -114,6 +119,13 @@ export struct CameraVideoExample {
videoTrackConfig.encoderConfig = videoEncodeConfig;
videoTrackConfig.captureConfig = videoCaptureConfig;
this.cameraTrack = QNRTC.CreateCameraVideoTrack(videoTrackConfig)
// set local track
if (this.micTrack) {
this.localTracks.push(this.micTrack);
}
if (this.cameraTrack) {
this.localTracks.push(this.cameraTrack);
}
}

join(): void {
Expand Down

0 comments on commit 24452ad

Please sign in to comment.